PHP style checking gradually (gradually)

I like the automatic checks of my codebase so that I don't violate style rules. When I worked in Perl, I would use Perl :: Critic to test my style, and Test :: Perl :: Critic :: Progressive for grandfather with any existing violations, so I could apply it to existing codes.

Now I am in a PHP project. PHP CodeSniffer seems to be a tool of choice in the community, but I don't see any progressive mode on it.

Is there a "Progressive" mode for any PHP style check?

(A “progressive” check first captures a list of all existing violations and then prevents them from appearing in subsequent checks. This means that existing violations are allowed to remain, but new ones cannot be added.)

+3
source share
2 answers

As you know, de facto PHP style checking is PHP CodeSniffer. This does not support progressive mode.

However, running this with grep on the command line is trivial so that you can start with errors and then take care of the warnings “gradually” at a later stage of progress.

Eclipse code integration (Screenshot and links) is also good and will allow you to do something similar, but only from the IDE.

- , IDE PHPStorm, - . , .

+1

script, :

SRCDIR=/Users/smcmillan/Documents/Development/project
WWWDIR=$SRCDIR/www

phpcs --extensions=php --report=csv "$WWWDIR" | awk -F, '{print $1, $3, $4, $5;}' > "$SRCDIR/.newerrs"

rm "$SRCDIR/.errfiles"

diff -c "$SRCDIR/.olderrs" "$SRCDIR/.newerrs" | grep ^+ | awk '{print $2}' | uniq > "$SRCDIR/.errfiles"

xargs phpcs < $SRCDIR/.errfiles 

, csv , , . phpcs.

-, - , .

+1

All Articles