Skip to content

Commit

Permalink
Merge pull request #96 from PHPCSStandards/feature/qa-remove-unreacha…
Browse files Browse the repository at this point in the history
…ble-code

QA: remove unreachable code
  • Loading branch information
jrfnl authored Dec 4, 2023
2 parents bc001b0 + 2f77a2a commit 931f475
Show file tree
Hide file tree
Showing 27 changed files with 59 additions and 82 deletions.
5 changes: 5 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
<type>error</type>
</rule>

<!-- Do not allow unreachable code. -->
<rule ref="Squiz.PHP.NonExecutableCode">
<type>error</type>
</rule>

<!-- The testing bootstrap file uses string concats to stop IDEs seeing the class aliases -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<exclude-pattern>tests/bootstrap\.php</exclude-pattern>
Expand Down
2 changes: 0 additions & 2 deletions src/Sniffs/AbstractScopeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ final public function process(File $phpcsFile, $stackPtr)
return min($skipTokens);
}

return;

}//end process()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,26 @@ public function getWarningList($testFile='')
12 => 1,
13 => 1,
];
break;

case 'DuplicateClassNameUnitTest.2.inc':
return [
2 => 1,
3 => 1,
4 => 1,
5 => 1,
];
break;

case 'DuplicateClassNameUnitTest.5.inc':
return [
3 => 1,
7 => 1,
];
break;

case 'DuplicateClassNameUnitTest.6.inc':
return [10 => 1];
break;

default:
return [];
break;
}//end switch

}//end getWarningList()
Expand Down
7 changes: 3 additions & 4 deletions src/Standards/Generic/Tests/Files/InlineHTMLUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ public function getErrorList($testFile='')
switch ($testFile) {
case 'InlineHTMLUnitTest.3.inc':
return [4 => 1];
break;

case 'InlineHTMLUnitTest.4.inc':
return [1 => 1];
break;

case 'InlineHTMLUnitTest.7.inc':
return [1 => 1];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
12 changes: 5 additions & 7 deletions src/Standards/Generic/Tests/Files/LineLengthUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ public function getErrorList($testFile='')
45 => 1,
82 => 1,
];
break;

case 'LineLengthUnitTest.2.inc':
case 'LineLengthUnitTest.3.inc':
return [7 => 1];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down Expand Up @@ -89,20 +88,19 @@ public function getWarningList($testFile='')
75 => 1,
84 => 1,
];
break;

case 'LineLengthUnitTest.2.inc':
case 'LineLengthUnitTest.3.inc':
return [6 => 1];
break;

case 'LineLengthUnitTest.4.inc':
return [
10 => 1,
14 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getWarningList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc
499 => 1,
500 => 1,
];
break;

case 'MultipleStatementAlignmentUnitTest.js':
return [
11 => 1,
Expand Down Expand Up @@ -154,10 +154,9 @@ public function getWarningList($testFile='MultipleStatementAlignmentUnitTest.inc
114 => 1,
117 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getWarningList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ public function getErrorList($testFile='')
switch ($testFile) {
case 'CharacterBeforePHPOpeningTagUnitTest.1.inc':
return [2 => 1];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
4 changes: 2 additions & 2 deletions src/Standards/Generic/Tests/PHP/ClosingPHPTagUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public function getErrorList($testFile='')
switch ($testFile) {
case 'ClosingPHPTagUnitTest.1.inc':
return [9 => 1];

case 'ClosingPHPTagUnitTest.2.inc':
return [5 => 1];
break;

default:
return [];
break;
}

}//end getErrorList()
Expand Down
5 changes: 2 additions & 3 deletions src/Standards/Generic/Tests/PHP/LowerCaseConstantUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc')
95 => 1,
100 => 2,
];
break;

case 'LowerCaseConstantUnitTest.js':
return [
2 => 1,
Expand All @@ -64,10 +64,9 @@ public function getErrorList($testFile='LowerCaseConstantUnitTest.inc')
13 => 1,
14 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function getErrorList($testFile='')
switch ($testFile) {
case 'RequireStrictTypesUnitTest.1.inc':
return [];
break;
}

return [1 => 1];
Expand Down
3 changes: 1 addition & 2 deletions src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ public function getErrorList($testFile='')
case 'SyntaxUnitTest.1.inc':
case 'SyntaxUnitTest.2.inc':
return [3 => 1];
break;

default:
return [];
break;
}

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getErrorList($testFile='UnnecessaryStringConcatUnitTest.inc')
19 => 1,
20 => 1,
];
break;

case 'UnnecessaryStringConcatUnitTest.js':
return [
1 => 1,
Expand All @@ -46,10 +46,9 @@ public function getErrorList($testFile='UnnecessaryStringConcatUnitTest.inc')
14 => 1,
15 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getErrorList($testFile='DisallowSpaceIndentUnitTest.1.inc')
117 => 1,
118 => 1,
];
break;

case 'DisallowSpaceIndentUnitTest.3.inc':
return [
2 => 1,
Expand All @@ -96,16 +96,15 @@ public function getErrorList($testFile='DisallowSpaceIndentUnitTest.1.inc')
14 => 1,
15 => 1,
];
break;

case 'DisallowSpaceIndentUnitTest.js':
return [3 => 1];
break;

case 'DisallowSpaceIndentUnitTest.css':
return [2 => 1];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
return $endOfStatement;
}

return;

}//end processMemberVar()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getErrorList($testFile='LongConditionClosingCommentUnitTest.inc'
1008 => 1,
1032 => 1,
];
break;

case 'LongConditionClosingCommentUnitTest.js':
return [
47 => 1,
Expand All @@ -76,10 +76,9 @@ public function getErrorList($testFile='LongConditionClosingCommentUnitTest.inc'
439 => 1,
444 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getErrorList($testFile='OperatorBracketUnitTest.inc')
193 => 1,
194 => 2,
];
break;

case 'OperatorBracketUnitTest.js':
return [
5 => 1,
Expand All @@ -90,10 +90,9 @@ public function getErrorList($testFile='OperatorBracketUnitTest.inc')
63 => 1,
108 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc')
131 => 1,
135 => 1,
];
break;

case 'ComparisonOperatorUsageUnitTest.js':
return [
5 => 1,
Expand All @@ -74,10 +74,9 @@ public function getErrorList($testFile='ComparisonOperatorUsageUnitTest.inc')
67 => 1,
71 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
5 changes: 2 additions & 3 deletions src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ public function getWarningList($testFile='CommentedOutCodeUnitTest.inc')
147 => 1,
158 => 1,
];
break;

case 'CommentedOutCodeUnitTest.css':
return [
7 => 1,
16 => 1,
];
break;

default:
return [];
break;
}//end switch

}//end getWarningList()
Expand Down
5 changes: 2 additions & 3 deletions src/Standards/Squiz/Tests/PHP/DisallowInlineIfUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ public function getErrorList($testFile='DisallowInlineIfUnitTest.inc')
8 => 1,
18 => 1,
];
break;

case 'DisallowInlineIfUnitTest.js':
return [1 => 1];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public function getErrorList($testFile='DisallowSizeFunctionsInLoopsUnitTest.inc
44 => 1,
46 => 1,
];
break;

case 'DisallowSizeFunctionsInLoopsUnitTest.js':
return [1 => 1];
break;

default:
return [];
break;
}//end switch

}//end getErrorList()
Expand Down
Loading

0 comments on commit 931f475

Please sign in to comment.