PHP_CodeSniffer-显示失败的嗅探 [英] PHP_CodeSniffer - Show Sniff that failed

查看:99
本文介绍了PHP_CodeSniffer-显示失败的嗅探的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP_CodeSniffer中是否有设置可以显示失败的嗅探?我正在将输出结果与我们的编码标准进行比较,并且很难一一使用来判断哪个测试失败,以查看我们可能要忽略的测试.

Is there a setting in the PHP_CodeSniffer to show the sniff that failed? I am comparing the output to our coding standards, and using one by one is tough to decipher which test is failing, to see which we may want to ignore.

如果有一种简单的方法来显示故障嗅探,那么我可以更轻松,更快速地完成配置.

If there was a simple method to show the failure sniff, then I could complete the configuration a lot easier and quicker.

推荐答案

您可以使用-s命令行参数显示错误消息的来源.

You can use the -s command line argument to show the source for an error message.

$ 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

您还可以使用源报告显示所有失败的嗅探列表.

You can also use the source report to show a list of all failed sniffs.

$ 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

这篇关于PHP_CodeSniffer-显示失败的嗅探的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆