Question

I started using the PHP Code Sniffer extension for Eclipse (Kepler SR1 Build id: 20130919-0819) but I'm running in an usability issue. Due to the way code sniffer works on eclipse, it marks a file that has an error with the same icon as file that has a PHP coding error. And same goes for warnings.

My problem is that, due to some things on the codebase I'm working on, we do have a lot of variables (that I can't change) that are not on camel case format, but have an underscore. Because of that, eclipse reports that almost every page on the project has a problem. You can check the assigned image for an example.

So, my question is, how do I disable the check for this SNIFF (Variable not in valid camel case)?

enter image description here

Était-ce utile?

La solution

You can create your own ruleset.xml and not include the sniff you want, but include the others.

<?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> 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top