Question

I have sniffed my plugin code using CodeSniffer with WordPress standard as mentioned at following link:-

https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

I got a ton of issues. Now I want to fix these with help of some tool because fixing these issues manually is going to take considerable amount of time. I found such a tool here:

https://github.com/fabpot/PHP-CS-Fixer

List of CodeSniffer issues went even longer when I used this tool to fix the issues. I used following code from command prompt:

php php-cs-fixer.phar fix /path/to/dir

It is because of the differences in the coding standard that this Fixer is using and the WordPress standard that I am using to sniff my plugin code using CodeSniffer.

So how can I fix the CodeSniffer issues in my plugin using the PHP-CS-Fixer, complying with the same WordPress standard that is used in CodeSniffer to sniff the code?

Was it helpful?

Solution

Have a look at the CodeSniffer. The new version implements a feature to fix violation to a coding standard automatically. But only if the particular standard already support that. For more informations please read the documentation of this feature at https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top