JonoB
JonoB

Reputation: 5887

Override ruleset in PHP CodeSniffer

I am trying to override a rule in PHP CodeSniffer as follows:

<rule ref="Squiz.WhiteSpace.FunctionSpacing.Before">
    <properties>
        <property name="spacing" value="1"/>
    </properties>
</rule>

However, the overridden value of 1 is not being recognised at all, and it is still defaulting to 2.

Upvotes: 0

Views: 297

Answers (1)

Greg Sherwood
Greg Sherwood

Reputation: 7222

The rule ref you have in that sample code is for a specific message rather than the sniff itself. The 4-part message code is used to do things like override the message itself, mute the message, or change its severity. The sniff code is the 3-part code used for properties.

So in this case, you just need to do this:

<rule ref="Squiz.WhiteSpace.FunctionSpacing">
    <properties>
        <property name="spacing" value="1"/>
    </properties>
</rule>

Upvotes: 2

Related Questions