Skip to content

Ruleset: improve include/exclude patterns #860

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

Merged
merged 1 commit into from
Jul 28, 2025

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jul 26, 2025

include-pattern and exclude-pattern directives are a special flavour of regular expressions.

From the documentation:

Important

The ignore patterns are treated as regular expressions. If you do specify a regular expression, be aware that * is converted to .* for convenience in simple patterns, like those used in the example above. So use * anywhere you would normally use .*. Also ensure you escape any . characters that you want treated as a literal dot, such as when checking file extensions. So if you are checking for .inc in your ignore pattern, use \.inc instead.

This commit fixes unescaped characters which have special meaning in regular expressions to ensure they are interpreted as literals.

Ref: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders

`include-pattern` and `exclude-pattern` directives are a special flavour of regular expressions.

From the documentation:
> Important
>
> The ignore patterns are treated as regular expressions. If you do specify a regular expression, be aware that `*` is converted to `.*` for convenience in simple patterns, like those used in the example above. So use `*` anywhere you would normally use `.*`. Also ensure you escape any `.` characters that you want treated as a literal dot, such as when checking file extensions. So if you are checking for `.inc` in your ignore pattern, use `\.inc` instead.

This commit fixes unescaped characters which have special meaning in regular expressions to ensure they are interpreted as literals.

Ref: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders
@jrfnl jrfnl added this to the 3.1.0 milestone Jul 26, 2025
@jrfnl jrfnl requested a review from a team as a code owner July 26, 2025 23:46
@GaryJones GaryJones merged commit b6ba453 into develop Jul 28, 2025
42 checks passed
@GaryJones GaryJones deleted the feature/ruleset-fix-in-exclude-patterns branch July 28, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants