Skip to content

Commit bb77a39

Browse files
committed
MM-4941: [EQP][Sniffs Consolidation] Create new GitHub repo and move MEQP2 sniffs
- Removed severity from PHP code and added to the ruleset
1 parent 8b81307 commit bb77a39

21 files changed

+104
-206
lines changed

Magento/Sniffs/Classes/ObjectInstantiationSniff.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class ObjectInstantiationSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 8;
22-
2316
/**
2417
* String representation of warning.
2518
*
@@ -84,8 +77,7 @@ public function process(File $phpcsFile, $stackPtr)
8477
$this->warningMessage,
8578
$classNameStart,
8679
$this->warningCode,
87-
[$className],
88-
$this->severity
80+
[$className]
8981
);
9082
}
9183
}

Magento/Sniffs/Exceptions/DirectThrowSniff.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class DirectThrowSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 8;
22-
2316
/**
2417
* String representation of warning.
2518
*/
@@ -54,8 +47,7 @@ public function process(File $phpcsFile, $stackPtr)
5447
$this->warningMessage,
5548
$stackPtr,
5649
$this->warningCode,
57-
$posOfException,
58-
$this->severity
50+
$posOfException
5951
);
6052
}
6153
}

Magento/Sniffs/Exceptions/NamespaceSniff.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class NamespaceSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 10;
22-
2316
/**
2417
* String representation of error.
2518
*
@@ -63,8 +56,7 @@ public function process(File $phpcsFile, $stackPtr)
6356
$this->errorMessage,
6457
$stackPtr,
6558
$this->errorCode,
66-
$exceptionClassName,
67-
$this->severity
59+
$exceptionClassName
6860
);
6961
}
7062
}

Magento/Sniffs/Legacy/MageEntitySniff.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@
1313
*/
1414
class MageEntitySniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 10;
22-
23-
/**
24-
* String representation of error.
25-
*
26-
* @var string
27-
*/
16+
/**
17+
* String representation of error.
18+
*
19+
* @var string
20+
*/
2821
protected $errorMessage = 'Possible Magento 2 design violation. Detected typical Magento 1.x construction "%s".';
2922

3023
/**
@@ -94,15 +87,12 @@ public function process(File $phpcsFile, $stackPtr)
9487
$entityName = $tokens[$stackPtr]['content'];
9588
$error = [$tokens[$oldPosition]['content'] . ' ' . $entityName];
9689
}
97-
if ($entityName === $this->legacyEntity ||
98-
$this->isPrefixLegacy($entityName)
99-
) {
90+
if ($entityName === $this->legacyEntity || $this->isPrefixLegacy($entityName)) {
10091
$phpcsFile->addError(
10192
$this->errorMessage,
10293
$stackPtr,
10394
$this->errorCode,
104-
$error,
105-
$this->severity
95+
$error
10696
);
10797
}
10898
}

Magento/Sniffs/NamingConvention/InterfaceNameSniff.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class InterfaceNameSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 6;
22-
2316
/**
2417
* String representation of warning.
2518
*
@@ -61,7 +54,7 @@ public function process(File $sourceFile, $stackPtr)
6154
while ($tokens[$stackPtr]['line'] === $declarationLine) {
6255
if ($tokens[$stackPtr]['type'] === 'T_STRING') {
6356
if (substr($tokens[$stackPtr]['content'], 0 - $suffixLength) !== $this->interfaceSuffix) {
64-
$sourceFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode, [], $this->severity);
57+
$sourceFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
6558
}
6659
break;
6760
}

Magento/Sniffs/PHP/DateTimeSniff.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class DateTimeSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 6;
22-
2316
/**
2417
* String representation of warning.
2518
*
@@ -63,7 +56,7 @@ public function process(File $phpcsFile, $stackPtr)
6356
$posOfClassName = $phpcsFile->findNext(T_STRING, $stackPtr);
6457
$posOfNsSeparator = $phpcsFile->findNext(T_NS_SEPARATOR, $stackPtr, $posOfClassName);
6558
if ($posOfNsSeparator !== false && in_array($tokens[$posOfClassName]['content'], $this->dateTimeClasses)) {
66-
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode, [], $this->severity);
59+
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
6760
}
6861
}
6962
}

Magento/Sniffs/PHP/DiscouragedFunctionSniff.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class DiscouragedFunctionSniff extends ForbiddenFunctionsSniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 8;
22-
2316
/**
2417
* Pattern flag.
2518
*
@@ -254,6 +247,6 @@ protected function addError($phpcsFile, $stackPtr, $function, $pattern = null)
254247
$data[] = $this->forbiddenFunctions[$pattern];
255248
$warningMessage .= '; use %s instead.';
256249
}
257-
$phpcsFile->addWarning($warningMessage, $stackPtr, $warningCode, $data, $this->severity);
250+
$phpcsFile->addWarning($warningMessage, $stackPtr, $warningCode, $data);
258251
}
259252
}

Magento/Sniffs/PHP/GotoSniff.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class GotoSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 10;
22-
2316
/**
2417
* String representation of warning.
2518
*
@@ -47,6 +40,6 @@ public function register()
4740
*/
4841
public function process(File $phpcsFile, $stackPtr)
4942
{
50-
$phpcsFile->addError($this->errorMessage, $stackPtr, $this->errorCode, [], $this->severity);
43+
$phpcsFile->addError($this->errorMessage, $stackPtr, $this->errorCode);
5144
}
5245
}

Magento/Sniffs/PHP/ReturnValueCheckSniff.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Sniffs\PHP;
78

89
use PHP_CodeSniffer\Sniffs\Sniff;
@@ -13,13 +14,6 @@
1314
*/
1415
class ReturnValueCheckSniff implements Sniff
1516
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 10;
22-
2317
/**
2418
* String representation of error.
2519
*
@@ -131,7 +125,7 @@ public function process(File $phpcsFile, $stackPtr)
131125
&& (!$this->findIdentical($i - 1, $this->findFunctionParenthesisCloser($i) + 1))
132126
) {
133127
$foundFunctionName = $this->tokens[$i]['content'];
134-
$phpcsFile->addError($this->errorMessage, $i, $this->errorCode, [$foundFunctionName], $this->severity);
128+
$phpcsFile->addError($this->errorMessage, $i, $this->errorCode, [$foundFunctionName]);
135129
}
136130
}
137131
}

Magento/Sniffs/PHP/VarSniff.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@
1313
*/
1414
class VarSniff implements Sniff
1515
{
16-
/**
17-
* Violation severity.
18-
*
19-
* @var int
20-
*/
21-
protected $severity = 8;
22-
2316
/**
2417
* String representation of warning.
2518
*
@@ -47,6 +40,6 @@ public function register()
4740
*/
4841
public function process(File $phpcsFile, $stackPtr)
4942
{
50-
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode, [], $this->severity);
43+
$phpcsFile->addWarning($this->warningMessage, $stackPtr, $this->warningCode);
5144
}
5245
}

0 commit comments

Comments
 (0)