-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Possible to make PHPCS ignore one given rule for a particular file? #1179
Comments
There is no way to do this using annotations in your files. See issue #604 for a feature request. You can add exclusions for entire files using a ruleset.xml file. See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml for an example of hard-coding exclude patterns for specific sniffs. But you cannot do this for individual lines. |
Put this at the top of the file:
|
@systemovich this does not work for me in combination with slevomat, it will either remove the comment or keep complaining. No other solution than to remove it for me. |
@iltar Not sure about the details of your issue, but...
|
@jrfnl That seems to work, thanks! |
Now we just need the ability to do it at the class and method level |
Can you show a example? |
is the @tags needed? or this is just example of other random tags? I tried without @tags and for me it did not work |
I also cannot make it work with SlevomatCodingStandard.TypeHints.DeclareStrictTypes rule unless I add exclude pattern tag in phpcs.xml |
I wonder if it is possible to make PHPCS ignore one given rule for a particular file or line of code? Sometimes for different reasons I have to use
// @codingStandardsIgnoreLine
but this will make PHPCS completely ignore the line.As a example, I would like to be able to do something like
// @codingStandardsIgnoreLine Generic.WhiteSpace.ScopeIndent
to make PHPCS ignore just indentation for the line. Is there a way to do that?The text was updated successfully, but these errors were encountered: