Describe the bug
Apologies if this is not a bug, but I do not understand what is happening here. I have an exclude-pattern rule that is excluding a file, and I cannot understand why.
This rule:
<exclude-pattern>*.js</exclude-pattern>
Leads to this file being excluded:
<file>app/Services/JsonLdProcessingService.php</file>
I have read the documentation and I understand that the exclude-pattern uses regex, and also that * is converted to .* for convenience. I also understand that . should be escaped if you wish it to be treated like a literal dot (so my rule is flawed).
However the regex pattern /.*.js/ still does not match app/Services/JsonLdProcessingService.php so what is going on?
Custom ruleset
<?xml version="1.0"?>
<ruleset name="My Custom Standard">
<rule ref="PSR12"/>
<file>app/Services/JsonLdProcessingService.php</file>
<exclude-pattern>*.js</exclude-pattern>
</ruleset>
To reproduce
Steps to reproduce the behavior:
- Create a file called
app/Services/JsonLdProcessingService.php with the code sample above...
- Run
vendor/bin/phpcs -vv app/Services/JsonLdProcessingService.php
- See error message displayed
ERROR: No files were checked.
All specified files were excluded or did not match filtering rules.
Expected behavior
I'd expect the file to be checked?
Versions (please complete the following information)
|
|
| Operating System |
macOS Tahoe 26.4 |
| PHP version |
8.4.19 |
| PHP_CodeSniffer version |
4.0.1 |
| Standard |
PSR12 |
| Install type |
Composer (global) |
Additional context
Apologies if this is my misunderstanding!
Please confirm
- [*] I have searched the issue list and am not opening a duplicate issue.
- [*] I have read the Contribution Guidelines and this is not a support question.
- [*] I confirm that this bug is a bug in PHP_CodeSniffer and not in one of the external standards.
- [*] I have verified the issue still exists in the
4.x branch of PHP_CodeSniffer.
Describe the bug
Apologies if this is not a bug, but I do not understand what is happening here. I have an
exclude-patternrule that is excluding a file, and I cannot understand why.This rule:
<exclude-pattern>*.js</exclude-pattern>Leads to this file being excluded:
<file>app/Services/JsonLdProcessingService.php</file>I have read the documentation and I understand that the
exclude-patternuses regex, and also that*is converted to.*for convenience. I also understand that.should be escaped if you wish it to be treated like a literal dot (so my rule is flawed).However the regex pattern
/.*.js/still does not matchapp/Services/JsonLdProcessingService.phpso what is going on?Custom ruleset
To reproduce
Steps to reproduce the behavior:
app/Services/JsonLdProcessingService.phpwith the code sample above...vendor/bin/phpcs -vv app/Services/JsonLdProcessingService.phpExpected behavior
I'd expect the file to be checked?
Versions (please complete the following information)
Additional context
Apologies if this is my misunderstanding!
Please confirm
4.xbranch of PHP_CodeSniffer.