squizlabs / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
10.68k stars 1.48k forks source link

When I add exclude pattern *.js in xml then it will not working every php file that has json name #2955

Closed pokemonhan closed 4 years ago

pokemonhan commented 4 years ago

phpcs v 3.5.5 <exclude-pattern>*/*.js</exclude-pattern> after adding this and then below files will not able to check errors and show nothing errrors. StaticJsonHandler.php StaticJsonServiceProvider.php static_json.php

jrfnl commented 4 years ago

The exclude patterns are a special kind of regex in which * gets replaced by .*. Other regex special characters - like . - will retain their normal meaning.

This is documented behaviour, see: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders

Try using this instead: <exclude-pattern>*/*\.js$</exclude-pattern>

pokemonhan commented 4 years ago

Thank you, its work.

rmpel commented 5 months ago

It works, but, why does .js which gets expanded to `..jsexclude (for example)index.php, in which there is nojors` to be found?

jrfnl commented 5 months ago

@rmpel See https://github.com/squizlabs/PHP_CodeSniffer/issues/2955#issuecomment-627243324 - might be something in your file path which triggers the rule. See the more stable example to use in the comment.

On another note: This repo is abandoned and https://github.com/PHPCSStandards/PHP_CodeSniffer is its successor. See: #3932. If you need further assistance with this, I suggest you open a discussion item in the new repo.