Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No silencing possible if your custom standard directory name contains underscores #745

Closed
MarcelloPerathoner opened this issue Oct 18, 2015 · 2 comments

Comments

@MarcelloPerathoner
Copy link

If you put your custom standard in a directory called eg. php_coding_standard (which comes naturally because you probably already have node_modules and bower_components) you get silly sniff codes in your report (like php.standard.S.BraceOnSameLine in my case) which you cannot silence with

<rule ref="php.standard.S.BraceOnSameLine">
 <severity>0</severity>
</rule>

see stack trace below.

If I name the directory "phpcs" all is well.

This restriction should at least be documented.

Warning: PHP Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff "php.standard.S.BraceOnSameLine" does not exist' in /usr/share/php/PHP/CodeSniffer.php:1092
Stack trace:

0 /usr/share/php/PHP/CodeSniffer.php(733): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement), '/home/...', 0)

1 /usr/share/php/PHP/CodeSniffer.php(551): PHP_CodeSniffer->processRuleset('/home/...')

2 /usr/share/php/PHP/CodeSniffer/CLI.php(818): PHP_CodeSniffer->initStandard(Array, Array)

3 /usr/share/php/PHP/CodeSniffer/CLI.php(95): PHP_CodeSniffer_CLI->process()

4 /usr/bin/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()

5 {main}

thrown in /usr/share/php/PHP/CodeSniffer.php on line 1092

@aik099
Copy link
Contributor

aik099 commented Oct 18, 2015

Not sure if anything can be done about in 2.x version of PHP_CodeSniffer, because it uses _ in class names as directory separators in class autoloading. The 3.x version (not released) will use namespaces and that shouldn't be a problem.

@gsherwood
Copy link
Member

What @aik099 said is exactly right. You'll need to conform to the directory structure PHPCS uses in version 2. Once I release version 3, you can call your standard and sniffs whatever you want because you'll need to be putting them into namespaces.

There is nothing I can do in version 2 to make this work, so I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants