Skip to content

Commit 7a268e6

Browse files
authored
refactor(ClassFileName): Use upstream Squiz ClassFileName sniff directly (pfrenssen#276)
1 parent 0dbc395 commit 7a268e6

39 files changed

+811
-1025
lines changed

.github/workflows/testing.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
sed -i 's/Drupal.Classes.ClassCreateInstance/SlevomatCodingStandard.ControlStructures.NewWithParentheses/g' phpcs.xml.dist
8787
sed -i 's/Drupal.Classes.UnusedUseStatement/SlevomatCodingStandard.Namespaces.UnusedUses/g' phpcs.xml.dist
8888
sed -i '/<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" \/>/a \ <rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>' phpcs.xml.dist
89+
sed -i 's@<rule ref="Drupal.Classes.ClassFileName"/>@<rule ref="Squiz.Classes.ClassFileName">\n <!-- Disable class name to file name matching for *Test.php files. -->\n <exclude-pattern>*/tests/*/*(Test|TestBase).php</exclude-pattern>\n </rule>@' phpcs.xml.dist
8990
find . -type f -name "*.php" -exec sed -i 's#// phpcs:ignore Drupal.Classes.PropertyDeclaration, Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing#// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName,PSR2.Classes.PropertyDeclaration.Underscore#g' {} +
9091
find . -type f -name "*.php" -exec sed -i 's#// @codingStandardsIgnoreLine#// phpcs:ignore#g' {} +
9192
find . -type f -name "*.php" -exec sed -i 's#// @codingStandardsIgnoreFile#// phpcs:ignoreFile#g' {} +
@@ -95,4 +96,4 @@ jobs:
9596
sed -i '/<rule ref="Drupal.Functions.FunctionDeclaration"\/>/d' phpcs.xml.dist
9697
sed -i 's/DrupalPractice.CodeAnalysis.VariableAnalysis/VariableAnalysis.CodeAnalysis.VariableAnalysis/g' phpcs.xml.dist
9798
find .. -type f -name "*.php" -exec sed -i 's#// phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis#// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis#g' {} +
98-
../../vendor/bin/phpcs -p -s --parallel=$(nproc) --ignore=lib/Drupal/Core/Command/GenerateTheme.php,modules/mysql/tests/src/Kernel/mysql/Console/DbDumpCommandTest.php
99+
../../vendor/bin/phpcs -p -s --parallel=$(nproc) --ignore=lib/Drupal/Core/Command/GenerateTheme.php,modules/mysql/tests/src/Kernel/mysql/Console/DbDumpCommandTest.php,modules/big_pipe/tests/modules/big_pipe_test/src/BigPipePlaceholderTestCases.php,tests/fixtures/plugins/CustomPlugin.php,modules/package_manager/tests/modules/package_manager_test_api/src/ApiController.php

coder_sniffer/Drupal/Sniffs/Classes/ClassFileNameSniff.php

Lines changed: 0 additions & 90 deletions
This file was deleted.

coder_sniffer/Drupal/ruleset.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@
186186

187187
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
188188

189+
<rule ref="Squiz.Classes.ClassFileName">
190+
<!-- Disable class name to file name matching in Test files. -->
191+
<exclude-pattern>*/tests/*/*(Test|TestBase).php</exclude-pattern>
192+
</rule>
189193
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
190194
<!-- Disable some error messages that we already cover. -->
191195
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<!-- Test files that should not be checked. -->
99
<exclude-pattern>tests/*\.(inc|api\.php|tpl\.php)$</exclude-pattern>
10-
<exclude-pattern>tests/*/(good|bad)\.php$</exclude-pattern>
10+
<exclude-pattern>tests/*/(good|bad)/*\.php$</exclude-pattern>
1111
<exclude-pattern>tests/*/drupal(6|7|8)/*\.php$</exclude-pattern>
1212

1313
<!-- The following comes from the 3.4.2 PHPCS ruleset.xml { -->

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ parameters:
77
# Test files that should not be checked.
88
- 'tests/*/*.tpl.php'
99
- 'tests/*/*.api.php'
10-
- 'tests/*/good.php'
11-
- 'tests/*/bad.php'
10+
- 'tests/*/good/*.php'
11+
- 'tests/*/bad/*.php'
1212
- 'tests/*/drupal[678]/*.php'
1313
bootstrapFiles:
1414
- tests/Drupal/phpunit-bootstrap.php

tests/Drupal/Classes/ClassFileNameUnitTest.php

Lines changed: 0 additions & 69 deletions
This file was deleted.

tests/Drupal/Classes/drupal7/class_file_name_test.module

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/Drupal/Classes/drupal7/drupal7.info

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/Drupal/Classes/drupal8/ClassFileNameUnitTest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/Drupal/Classes/drupal8/drupal8.behat.inc

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)