14

失敗したスニフを表示する PHP_CodeSniffer の設定はありますか? 出力をコーディング標準と比較していますが、1 つずつ使用すると、どのテストが失敗しているかを解読し、どれを無視する必要があるかを確認するのが困難です。

失敗のスニフを表示する簡単な方法があれば、構成をはるかに簡単かつ迅速に完了することができます。

4

1 に答える 1

18

-sコマンドライン引数を使用して、エラーメッセージのソースを表示できます。

$ phpcs temp.php -s       

FILE: /Users/gsherwood/Sites/Projects/PHP_CodeSniffer/temp.php
--------------------------------------------------------------------------------
FOUND 4 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
 2 | ERROR | Missing file doc comment (PEAR.Commenting.FileComment.Missing)
 2 | ERROR | Missing class doc comment (PEAR.Commenting.ClassComment.Missing)
 2 | ERROR | Opening brace of a class must be on the line after the definition
   |       | (PEAR.Classes.ClassDeclaration.OpenBraceNewLine)
 3 | ERROR | Missing function doc comment
   |       | (PEAR.Commenting.FunctionComment.Missing)
--------------------------------------------------------------------------------

Time: 0 seconds, Memory: 4.50Mb

ソースレポートを使用して、失敗したすべてのスニフのリストを表示することもできます。

$ phpcs temp.php --report=source

PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
STANDARD  CATEGORY            SNIFF                                        COUNT
--------------------------------------------------------------------------------
PEAR      Commenting          File comment missing                         1
PEAR      Commenting          Class comment missing                        1
PEAR      Classes             Class declaration open brace new line        1
PEAR      Commenting          Function comment missing                     1
--------------------------------------------------------------------------------
A TOTAL OF 4 SNIFF VIOLATION(S) WERE FOUND IN 4 SOURCE(S)
--------------------------------------------------------------------------------

Time: 0 seconds, Memory: 4.75Mb

$ phpcs temp.php --report=source -s

PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
SOURCE                                                                     COUNT
--------------------------------------------------------------------------------
PEAR.Commenting.FileComment.Missing                                        1
PEAR.Commenting.ClassComment.Missing                                       1
PEAR.Classes.ClassDeclaration.OpenBraceNewLine                             1
PEAR.Commenting.FunctionComment.Missing                                    1
--------------------------------------------------------------------------------
A TOTAL OF 4 SNIFF VIOLATION(S) WERE FOUND IN 4 SOURCE(S)
--------------------------------------------------------------------------------

Time: 0 seconds, Memory: 4.75Mb
于 2012-12-05T21:29:19.363 に答える