Skip to content

Commit 0cc9476

Browse files
committed
revert to no acronym check
1 parent 9edfa56 commit 0cc9476

File tree

5 files changed

+18
-24
lines changed

5 files changed

+18
-24
lines changed

coder_sniffer/Drupal/Sniffs/NamingConventions/ValidClassNameSniff.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ public function process(File $phpcsFile, $stackPtr)
7272
$phpcsFile->addError($error, $stackPtr, 'NoUnderscores', $errorData);
7373
}
7474

75-
// Ensure the name does not contain acronyms.
76-
if (preg_match('|[A-Z]{3}|', $name) === 1) {
75+
// Ensure the name is not all uppercase.
76+
// @todo We could make this more strict to check if there are more than
77+
// 2 upper case characters in a row, but not decided yet.
78+
// See https://www.drupal.org/project/coder/issues/3497433
79+
if (strtoupper($name) === $name) {
7780
$error = '%s name must use UpperCamel naming and not contain multiple upper case letters in a row';
7881
$phpcsFile->addError($error, $stackPtr, 'NoUpperAcronyms', $errorData);
7982
}

tests/Drupal/NamingConventions/ValidClassNameUnitTest.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,24 @@
22

33
class CorrectClassName {}
44
class CorrectClassWithAReallyLongName {}
5-
class IncorrectJSONClassName {}
65
class INCORRECT_CLASS_NAME {}
76
class INCORRECTCLASSNAME {}
87
class incorrectLowercaseClassName {}
98

109
interface CorrectInterfaceName {}
1110
interface CorrectInterfaceWithAReallyLongName {}
12-
interface IncorrectJSONInterfaceName {}
1311
interface INCORRECT_INTERFACE_NAME {}
1412
interface INCORRECTINTERFACENAME {}
1513
interface incorrectLowercaseInterfaceName {}
1614

1715
trait CorrectTraitName {}
1816
trait CorrectTraitWithAReallyLongName {}
19-
trait IncorrectJSONTraitName {}
2017
trait INCORRECT_TRAIT_NAME {}
2118
trait INCORRECTTRAITNAME {}
2219
trait incorrectLowercaseTraitName {}
2320

2421
enum CorrectEnumName {}
2522
enum CorrectEnumWithAReallyLongName {}
26-
enum IncorrectJSONEnumName {}
2723
enum INCORRECT_ENUM_NAME {}
2824
enum INCORRECTENUMNAME {}
2925
enum incorrectLowercaseEnumName {}

tests/Drupal/NamingConventions/ValidClassNameUnitTest.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,18 @@ class ValidClassNameUnitTest extends CoderSniffUnitTest
2121
protected function getErrorList(string $testFile): array
2222
{
2323
return [
24-
5 => 1,
25-
6 => 2,
24+
5 => 2,
25+
6 => 1,
2626
7 => 1,
27-
8 => 1,
27+
11 => 2,
2828
12 => 1,
29-
13 => 2,
30-
14 => 1,
31-
15 => 1,
29+
13 => 1,
30+
17 => 2,
31+
18 => 1,
3232
19 => 1,
33-
20 => 2,
34-
21 => 1,
35-
22 => 1,
36-
26 => 1,
37-
27 => 2,
38-
28 => 1,
39-
29 => 1,
33+
23 => 2,
34+
24 => 1,
35+
25 => 1,
4036
];
4137

4238
}//end getErrorList()

tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ enum Test: int {
77
case TWO_TEST = 2;
88
// Must not contain only upper case.
99
case THREE = 3;
10-
// Upper case parts are not allowed.
10+
// Upper case parts are allowed for now.
1111
case FourJSONCase = 4;
1212
case FiveAndAHorseCorrect = 5;
1313
}

tests/Drupal/NamingConventions/ValidEnumCaseUnitTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ class ValidEnumCaseUnitTest extends CoderSniffUnitTest
2121
protected function getErrorList(string $testFile): array
2222
{
2323
return [
24-
5 => 1,
25-
7 => 2,
26-
9 => 1,
27-
11 => 1,
24+
5 => 1,
25+
7 => 2,
26+
9 => 1,
2827
];
2928

3029
}//end getErrorList()

0 commit comments

Comments
 (0)