6

using codesniffer with pear standard. I got over 20tsd errors cause of line indents. I use tab-stops for indenting. I try to disable that check but I failed.

I removed the last rule from the generic standards in the ruleset.xml for the pear standard. Yet the indenting is still considered an error.

How do I remove the indention checks completely for the pear standard?

steros
  • 1,794
  • 2
  • 26
  • 60

2 Answers2

5

It should work, so you should definitely try to understand why tweaking your ruleset.xml file doesn't work in your environment, otherwise you'll be missing many features from CodeSniffer.

As a reminder, here are the two options:

  1. Either you explicitly exclude the sniff in your ruleset :

    <rule ref="PEAR">
        <exclude name="PEAR.WhiteSpace.ScopeIndent" />
    </rule>
    
  2. Or you mute down a specific error message, resulting in the rule actually being executed for potential other error messages :

    <rule ref="PEAR.WhiteSpace.ScopeIndent.Incorrect">
        <severity>0</severity>
    </rule>
    
Tom Desp
  • 911
  • 6
  • 19
  • What do you mean by *You should defenitely understand why you can't tweak your `ruleset.xml` file.*? Do you mean, *it is not possible to tweak `ruleset.xml`, and you should understand why.* ? Or do you mean, *you should understand how to tweak your `ruleset.xml` file.* ? – Cheeso Mar 10 '12 at 20:40
  • Sorry if it's not clear enough. I meant: *You should investigate further and try to understand why it's not working in your environment as it should be* – Tom Desp Mar 11 '12 at 10:08
0

You can achieve this by searching for the following file "ScopeIndentSniff.php" this must be in a folder called "WhiteSpace" under "standards". Just rename it. Be aware that applications may have their own folder with standards. Eclipse for example has an own folder where standards rest. So if you edit your share folder this might not apply. But you can setup Eclipse to use your share folder too. (Preferences -> PHP Tools -> CodeSniffer -> CodeSniffer Standards)

  • Tom's answer might be more appropriate for editing the ruleset itself. But the case that eclipse has its own folder was the actually problem in my case. – steros Mar 29 '12 at 18:15
  • 1
    How do you manage this when CodeSniffer is managed as an external dependency? You don't. This definitely is **a bad practice**. Use a ruleset or command line options as described in the answer of Tom Desp. – i.am.michiel Jan 20 '15 at 09:00