4

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?

Govind Malviya
  • 13,627
  • 17
  • 68
  • 94
Rajat Varlani
  • 456
  • 1
  • 4
  • 19
  • Is anyone there to reply this? – Rajat Varlani Jan 16 '14 at 05:55
  • I am still waiting..... – Rajat Varlani Jan 21 '14 at 04:50
  • 2
    Normally, being sarcastic as your comments are, you will not likely find people willing to help you and spend the time. The problem is, the tool you are looking at only does the PS1-2 standards. As such, Wordpress has different standards. You are either going to need to fork the tool you found and edit it for the WordPress standard as well, or bite the bullet and begin fixing your plugin manually. A plugin should be fairly small, so you could try to correct it bit by bit. You should try to code with a packages standards, if that is what you are building for and looking to follow. – Steven Scott Jan 24 '14 at 17:24
  • Thanks for the heads up. I was looking for someone to shed some light on this problem. – Rajat Varlani Jan 25 '14 at 10:29
  • No problem. As I said, maybe check with the author of the tool you fond to see if they are extending it, or if you could even modify it. – Steven Scott Jan 26 '14 at 18:22

1 Answers1

3

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

common sense
  • 3,775
  • 6
  • 22
  • 31