Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
sed -i 's/Drupal.Classes.ClassCreateInstance/SlevomatCodingStandard.ControlStructures.NewWithParentheses/g' phpcs.xml.dist
sed -i 's/Drupal.Classes.UnusedUseStatement/SlevomatCodingStandard.Namespaces.UnusedUses/g' phpcs.xml.dist
sed -i '/<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" \/>/a \ <rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>' phpcs.xml.dist
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
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' {} +
find . -type f -name "*.php" -exec sed -i 's#// @codingStandardsIgnoreLine#// phpcs:ignore#g' {} +
find . -type f -name "*.php" -exec sed -i 's#// @codingStandardsIgnoreFile#// phpcs:ignoreFile#g' {} +
Expand All @@ -95,4 +96,4 @@ jobs:
sed -i '/<rule ref="Drupal.Functions.FunctionDeclaration"\/>/d' phpcs.xml.dist
sed -i 's/DrupalPractice.CodeAnalysis.VariableAnalysis/VariableAnalysis.CodeAnalysis.VariableAnalysis/g' phpcs.xml.dist
find .. -type f -name "*.php" -exec sed -i 's#// phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis#// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis#g' {} +
../../vendor/bin/phpcs -p -s --parallel=$(nproc) --ignore=lib/Drupal/Core/Command/GenerateTheme.php,modules/mysql/tests/src/Kernel/mysql/Console/DbDumpCommandTest.php
../../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
90 changes: 0 additions & 90 deletions coder_sniffer/Drupal/Sniffs/Classes/ClassFileNameSniff.php

This file was deleted.

4 changes: 4 additions & 0 deletions coder_sniffer/Drupal/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@

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

<rule ref="Squiz.Classes.ClassFileName">
<!-- Disable class name to file name matching in Test files. -->
<exclude-pattern>*/tests/*/*(Test|TestBase).php</exclude-pattern>
</rule>
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
<!-- Disable some error messages that we already cover. -->
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

<!-- The following comes from the 3.4.2 PHPCS ruleset.xml { -->
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ parameters:
# Test files that should not be checked.
- 'tests/*/*.tpl.php'
- 'tests/*/*.api.php'
- 'tests/*/good.php'
- 'tests/*/bad.php'
- 'tests/*/good/*.php'
- 'tests/*/bad/*.php'
- 'tests/*/drupal[678]/*.php'
bootstrapFiles:
- tests/Drupal/phpunit-bootstrap.php
Expand Down
69 changes: 0 additions & 69 deletions tests/Drupal/Classes/ClassFileNameUnitTest.php

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Drupal/Classes/drupal7/class_file_name_test.module

This file was deleted.

1 change: 0 additions & 1 deletion tests/Drupal/Classes/drupal7/drupal7.info

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Drupal/Classes/drupal8/ClassFileNameUnitTest.php

This file was deleted.

10 changes: 0 additions & 10 deletions tests/Drupal/Classes/drupal8/drupal8.behat.inc

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Drupal/Classes/drupal8/drupal8.info.yml

This file was deleted.

11 changes: 0 additions & 11 deletions tests/Drupal/Classes/drupal8/markdownFile.md

This file was deleted.

20 changes: 13 additions & 7 deletions tests/Drupal/bad/BadUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function getErrorList(string $testFile): array
case 'bad_crlf.inc':
return [
1 => 1,
7 => 1,
8 => 1,
];
case 'bad.info':
Expand Down Expand Up @@ -245,7 +246,7 @@ protected function getErrorList(string $testFile): array
372 => 3,
375 => 1,
376 => 1,
379 => 1,
379 => 2,
383 => 1,
384 => 1,
385 => 1,
Expand All @@ -265,15 +266,15 @@ protected function getErrorList(string $testFile): array
400 => 1,
401 => 1,
403 => 1,
406 => 1,
406 => 2,
407 => 3,
411 => 2,
417 => 1,
418 => 2,
421 => 1,
422 => 1,
424 => 2,
426 => 2,
424 => 3,
426 => 3,
428 => 1,
436 => 1,
438 => 1,
Expand Down Expand Up @@ -341,7 +342,7 @@ protected function getErrorList(string $testFile): array
750 => 1,
756 => 1,
765 => 1,
791 => 1,
791 => 2,
795 => 4,
796 => 1,
799 => 1,
Expand All @@ -352,13 +353,14 @@ protected function getErrorList(string $testFile): array
805 => 1,
806 => 1,
807 => 1,
809 => 3,
809 => 4,
815 => 1,
820 => 1,
827 => 1,
829 => 1,
836 => 1,
838 => 3,
838 => 4,
844 => 1,
849 => 2,
860 => 2,
867 => 1,
Expand Down Expand Up @@ -402,6 +404,10 @@ protected function getErrorList(string $testFile): array
85 => 1,
98 => 1,
];
case 'WrongClassName.php':
return [
6 => 1,
];
}//end switch

return [];
Expand Down
2 changes: 1 addition & 1 deletion tests/Drupal/bad/ClassCreateInstanceUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $bar = new $foo[$x + 1][$y + 1];
/**
* Test class.
*/
class Test2 {
class ClassCreateInstanceUnitTest {

/**
* Using PHP 7 return type hints is fine.
Expand Down
2 changes: 1 addition & 1 deletion tests/Drupal/bad/ClassCreateInstanceUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $bar = new $foo[$x + 1][$y + 1]();
/**
* Test class.
*/
class Test2 {
class ClassCreateInstanceUnitTest {

/**
* Using PHP 7 return type hints is fine.
Expand Down
2 changes: 1 addition & 1 deletion tests/Drupal/bad/UnusedUseStatementUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use Some\Data\Test10;
/**
* Bla.
*/
class Pum {
class UnusedUseStatementUnitTest {
use TraitTest;
use Test\AnotherTrait;

Expand Down
2 changes: 1 addition & 1 deletion tests/Drupal/bad/UnusedUseStatementUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use MyNamespace\Depth\SomeClass as CoreSomeClass;
/**
* Bla.
*/
class Pum {
class UnusedUseStatementUnitTest {
use TraitTest;
use Test\AnotherTrait;

Expand Down
6 changes: 6 additions & 0 deletions tests/Drupal/bad/WrongClassName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

/**
* Class name does not match file name.
*/
class NotMatchingClassName {}
24 changes: 24 additions & 0 deletions tests/Drupal/good/GoodAlignment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* Nice alignment is allowed for assignments.
*/
class GoodAlignment {
const INFO = 0;
const WARNING = 1;
const ERROR = 2;
const EMERGENCY = 3;

/**
* Empty method implementation is allowed.
*/
public function emptyMethod() {}

/**
* Protected functions are allowed.
*/
protected function protectedTest() {

}

}
Loading