Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit functionality #33

Closed
swissspidy opened this issue Jun 22, 2018 · 3 comments
Closed

Audit functionality #33

swissspidy opened this issue Jun 22, 2018 · 3 comments

Comments

@swissspidy
Copy link
Member

Just thinking out loud after reading through https://core.trac.wordpress.org/ticket/44139.

We might be able to generate some warnings when a string occurs multiple times in the source code but with multiple translator comments. That‘s usually an indication that these should be separate strings with different contexts.

@swissspidy
Copy link
Member Author

I'm wondering what the best way would be to get these warnings (and other errors) in a machine-readable manner.

Use case: we currently programmatically extract strings from our projects after each push to GitHub and import them into GlotPress. On success, we send a notification to our Slack channel. Now I want to do the same for errors as well.

Do I need to parse the terminal output using regex, or hold the messages in MakePotCommand and print them at the end in the desired format, or is there a better way?

Many commands have a --format argument, but AFAIK this is only used to print things like objects or lists in a specific format, not error messages.

@schlessera Would love to hear your insights on this :-)

@schlessera
Copy link
Member

I've already helped build a similar thing here: https://github.com/fklein-lu/checker-cli/tree/master/src

Basically, it is a generalized pipeline running one or more Checks, and each Check can add issues to a container, like shown here: https://github.com/fklein-lu/checker-cli/blob/master/src/Check/RequiredFilesCheck.php#L34-L42

The Issues contain all the data that is needed for recording problems. Also, they know how to render themselves into text or JSON: https://github.com/fklein-lu/checker-cli/blob/master/src/Issue.php#L76-L101

With this object model, you can easily write multiple ReportGenerators, which could be used for providing different --format=<format> implementations: https://github.com/fklein-lu/checker-cli/tree/master/src/Report

@swissspidy
Copy link
Member Author

Very helpful, thanks!

Will try to explore this concept a bit for the make-pot command so we could eventually add a --format argument to it.

In the mean time I guess we'll resort to parsing the output on our own in our script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants