Skip to content

Commit 40b0dac

Browse files
committed
Ruleset: improve include/exclude patterns
`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
1 parent 1753c9f commit 40b0dac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

WordPressVIPMinimum/ruleset.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</rule>
2929

3030
<rule ref="WordPressVIPMinimum.Security.Twig">
31-
<include-pattern>*.twig</include-pattern>
31+
<include-pattern>*\.twig</include-pattern>
3232
</rule>
3333

3434
<rule ref="WordPress.Security.EscapeOutput"/>
@@ -67,10 +67,10 @@
6767
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
6868
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"/>
6969
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"/>
70-
<include-pattern>*.php</include-pattern>
71-
<include-pattern>*.inc</include-pattern>
72-
<exclude-pattern>*.js</exclude-pattern>
73-
<exclude-pattern>*.css</exclude-pattern>
70+
<include-pattern>*\.php</include-pattern>
71+
<include-pattern>*\.inc</include-pattern>
72+
<exclude-pattern>*\.js</exclude-pattern>
73+
<exclude-pattern>*\.css</exclude-pattern>
7474
</rule>
7575
<rule ref="Squiz.PHP.CommentedOutCode"/>
7676

0 commit comments

Comments
 (0)