codesniffer

Ignore code snippets in PHP_CodeSniffer

£可爱£侵袭症+ 提交于 2019-12-02 17:23:52
It is possible to ignore some parts of code from a php file when it's analyzed by PHP_CodeSniffer ? Anti Veeranna Yes it is possible with @codingStandardsIgnoreStart and @codingStandardsIgnoreEnd annotations <?php some_code(); // @codingStandardsIgnoreStart this_will_be_ignored(); // @codingStandardsIgnoreEnd some_other_code(); It is also described in the documentation. You can either use the combination: @codingStandardsIgnoreStart and @codingStandardsIgnoreEnd or you can use @codingStandardsIgnoreLine . Example: <?php command1(); // @codingStandardsIgnoreStart command2(); // this line will

How useful is PHP CodeSniffer? Code Standards Enforcement in General? [closed]

僤鯓⒐⒋嵵緔 提交于 2019-12-02 14:16:55
I'm dabbling with the idea of setting up PHP CodeSniffer on our continuous integration server in an effort to improve the quality of our code-base. After reading the documentation I'm very excited about the idea of normalizing and enforcing our coding standards. However, I'm left wondering about the actual improvement to our product. I'm well aware that the sniffer only detects violations to a defined coding-standard but what type of benefits does a clean, consistent, code-base provide? Is it worth the extra work to refactor a project with 100k+ lines of code to conform to the PEAR standard?

Using Jenkins and Php Code Sniffer

六眼飞鱼酱① 提交于 2019-12-02 00:34:21
问题 I'm trying to use the Php Code Sniffer plugin in Jenkins. It generates a checkstyle.xml file but there are no errors inside, and I know that I should have. Here's the containt of my checkstyle.xml : <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.0RC2"> </checkstyle> My build.xml file for Jenkins is : <target name="phpcs" > <exec executable="phpcs"> <arg line="--report=checkstyle --report-file=${project.basedir}/build/logs/checkstyle.xml --standard=Zend ${project.basedir}/*

Using Jenkins and Php Code Sniffer

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 22:22:01
I'm trying to use the Php Code Sniffer plugin in Jenkins. It generates a checkstyle.xml file but there are no errors inside, and I know that I should have. Here's the containt of my checkstyle.xml : <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.0RC2"> </checkstyle> My build.xml file for Jenkins is : <target name="phpcs" > <exec executable="phpcs"> <arg line="--report=checkstyle --report-file=${project.basedir}/build/logs/checkstyle.xml --standard=Zend ${project.basedir}/*.php" /> </exec> </target> And when i do it in command line, I have a different result. My command : phpcs

Git pre-receive hook to launch PHP CodeSniffer [closed]

青春壹個敷衍的年華 提交于 2019-11-30 13:48:09
I'd like to check code committed to my remote git repository with PHP CodeSniffer and reject it if there are any problems code standards. Does anyone have an example how to use it on git remote repository or maybe example how to use it with pre-receive hook? Thanks. Maybe this point you in the right direction: (Orginal from: http://www.squatlabs.de/versionierung/arbeiten-git-hooks in German) #!/usr/bin/php <?php $output = array(); $rc = 0; exec('git rev-parse --verify HEAD 2> /dev/null', $output, $rc); if ($rc == 0) $against = 'HEAD'; else $against = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';

Is there a PHPCS standard targeting PHP docblocks?

余生长醉 提交于 2019-11-27 17:28:00
问题 Is there a PHPCS coding standard that would check that proper annotations ( @param , @return , @throws , etc.) are present in a docblock, including the proper spacing between them? 回答1: Try running the following command and see if it produces what you want: phpcs /path/to/code --standard=Squiz --sniffs=Squiz.Commenting.FunctionComment,Squiz.Commenting.FunctionCommentThrowTag,Squiz.Commenting.ClassComment,Squiz.Commenting.FileComment,Squiz.Commenting.VariableComment If it does, you could