【问题标题】:How to ignore some validations on PHP Code Sniffer on Eclipse?如何忽略 Eclipse 上 PHP Code Sniffer 的一些验证?
【发布时间】:2014-02-05 01:08:10
【问题描述】:

我开始使用 Eclipse 的 PHP Code Sniffer 扩展(Kepler SR1 Build id:20130919-0819),但我遇到了可用性问题。由于代码嗅探器在 Eclipse 上的工作方式,它会用与 PHP 编码错误的文件相同的图标来标记有错误的文件。警告也是如此。

我的问题是,由于我正在处理的代码库中的某些内容,我们确实有很多变量(我无法更改)不是驼峰式格式,但有一个下划线。正因为如此,eclipse 报告说该项目的几乎每个页面都有问题。您可以查看分配的图像作为示例。

所以,我的问题是,如何禁用对这个 SNIFF 的检查(变量不是有效的驼峰式大小写)?

【问题讨论】:

    标签: eclipse codesniffer


    【解决方案1】:

    您可以创建自己的 ruleset.xml 并且不包含您想要的嗅探,但包含其他的。

    <?xml version="1.0"?> 
    <ruleset name="My Standards"> 
        <description>My Coding Standards enforcement rule set for PHP_CodeSniffer</description> 
        <rule ref="PSR2.Classes.PropertyDeclaration" /> 
        <rule ref="PSR2.ControlStructures.ElseIfDeclaration" /> 
        <rule ref="PSR2.Files.EndFileNewline" /> 
        <rule ref="PSR2.Methods.MethodDeclaration" /> 
        <rule ref="PSR2.Namespaces.NamespaceDeclaration" />    
        <rule ref="PSR2.Namespaces.UseDeclaration" />  
    
        <rule ref="Squiz.Arrays.ArrayBracketSpacing" /> 
        <rule ref="Squiz.Arrays.ArrayDeclaration" /> 
    
        <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops" />  
    
    
        <!-- Removing Sniffs from Generic as we do not want these -->
        <rule ref="Generic"> 
            <exclude name="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />       
            <exclude name="Generic.Commenting.Fixme" /> 
            <exclude name="Generic.Commenting.Todo" /> 
            <exclude name="Generic.Files.EndFileNoNewline" /> 
            <exclude name="Generic.Files.LineEndings" /> 
            <exclude name="Generic.Files.LineLength" /> 
            <exclude name="Generic.Files.OneClassPerFile" /> 
            <exclude name="Generic.Files.OneInterfacePerFile" /> 
            <exclude name="Generic.Formatting.NoSpaceAfterCast" /> 
            <exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie" /> 
            <exclude name="Generic.NamingConventions.CamelCapsFunctionName" /> 
            <exclude name="Generic.PHP.ClosingPHPTag" /> 
            <exclude name="Generic.PHP.LowerCaseConstant" /> 
            <exclude name="Generic.VersionControl.SubversionProperties" /> 
            <exclude name="Generic.WhiteSpace.DisallowSpaceIndent" /> 
            <exclude name="Generic.WhiteSpace.DisallowTabIndent" /> 
            <exclude name="Generic.Files.LowercasedFilename" /> 
        </rule> 
    </ruleset> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      • 2019-12-13
      • 2016-09-13
      • 2010-12-22
      • 2013-02-18
      相关资源
      最近更新 更多