Search code examples
phpcodesnifferphpcs

Include Excluded rule


I want to include the PSR12 ruleset (which includes the rule "PSR1.Methods.CamelCapsMethodName.NotCamelCaps") but I don't want that rule to run on a specific file. so I tried the following ruleset:

<rule ref="PSR12">
    <exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>

<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
    <exclude-pattern>packages/test/file</exclude-pattern>
</rule>

Unfortunately, it doesn't run the "PSR1.Methods.CamelCapsMethodName.NotCamelCaps" rule at all (also not in the rest of the code).

Does anyone know how to get this working?


Solution

  • As @Greg Sherwood gave the solution: I could just remove the tag from the PSR12 rule.

    <rule ref="PSR12">
    </rule>
    
    <rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
        <exclude-pattern>packages/test/file</exclude-pattern>
    </rule>