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
How can I exclude this rule? #1755
Comments
If you are using a coding standard that enforces this rule but you don't want the rule applied, you'll need to create your own coding standard by writing a ruleset.xml file that excludes this particular check. If you use the You don't say what coding standard you are using, so I'll assume it is PEAR (the default one). To exclude this rule, you'd create a ruleset.xml file with the following content: <?xml version="1.0"?>
<ruleset name="MyStandard">
<description>My custom coding standard.</description>
<rule ref="PEAR">
<exclude name="PEAR.NamingConventions.ValidClassName.Invalid" />
</rule>
</ruleset> Then you run PHPCS using this file: If you instead name the file Once you have your own ruleset, you can customise things a lot more. See this doc for example: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml |
Thanks @gsherwood . This fix the error:
|
Do I have to add <?xml version="1.0"?>
<ruleset name="PSR2">
<description>The PSR2 coding standard.</description>
<rule ref="PSR2">
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.Invalid" />
</rule>
<file>app/</file>
<exclude-pattern>vendor</exclude-pattern>
<exclude-pattern>resources</exclude-pattern>
<exclude-pattern>database/</exclude-pattern>
<exclude-pattern>storage/</exclude-pattern>
<exclude-pattern>node_modules/</exclude-pattern>
</ruleset> |
@andreshg112 What's not working? What version of PHPCS? What does the output (with |
This is just one part of the output for the command
|
This is the output for just one file. The phpcs.xml file is still the same and It's placed in the root directory of the project. andreshg112@andreshg112-HP-240-G4-Notebook-PC:/opt/lampp/htdocs/transito$ phpcs app/Http/Controllers/AdminAgentesController.php
FILE: /opt/lampp/htdocs/transito/app/Http/Controllers/AdminAgentesController.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AND 2 WARNINGS AFFECTING 19 LINES
--------------------------------------------------------------------------------------------------------------------------
89 | WARNING | [ ] Line exceeds 120 characters; contains 192 characters
90 | WARNING | [ ] Line exceeds 120 characters; contains 196 characters
233 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
247 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
256 | ERROR | [ ] Method name "AdminAgentesController::hook_query_index" is not in camel caps format
268 | ERROR | [ ] Method name "AdminAgentesController::hook_row_index" is not in camel caps format
280 | ERROR | [ ] Method name "AdminAgentesController::hook_before_add" is not in camel caps format
284 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
293 | ERROR | [ ] Method name "AdminAgentesController::hook_after_add" is not in camel caps format
297 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
307 | ERROR | [ ] Method name "AdminAgentesController::hook_before_edit" is not in camel caps format
311 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
320 | ERROR | [ ] Method name "AdminAgentesController::hook_after_edit" is not in camel caps format
324 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
333 | ERROR | [ ] Method name "AdminAgentesController::hook_before_delete" is not in camel caps format
337 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
346 | ERROR | [ ] Method name "AdminAgentesController::hook_after_delete" is not in camel caps format
350 | ERROR | [x] Function closing brace must go on the next line following the body; found 1 blank lines before brace
354 | ERROR | [x] The closing brace for the class must go on the next line after the body
--------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------
Time: 171ms; Memory: 6Mb |
If you want to exclude
|
Hello,
Because in my tests I use another way to nameing methods test_myTest() Thank you |
@alessandro-candon You can only exclude entire sniffs (3-part codes) on the command line, not individual error messages (4-part codes). Try this:
|
This is off topic but how do I find rules like Methods.CamelCapsMethodName.NotCamelCaps |
I wanted to use class name
WooCommerce_eSewa
but PHPCS shows this error:The text was updated successfully, but these errors were encountered: