mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Remove trivial cases of unreachable code
Summary: Static code analysis can detect `Unreachable statement - code above always terminates.` The vast majority of occurrences in the Arcanist codebase are due to an unreachable `break` within a `case` after a `return` or after an all-covering `if/else`. All this noise makes it harder to spot real logic issues (there are some!), thus fix these trivial cases. Test Plan: Examine the code; run static code analysis. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25803
This commit is contained in:
parent
201fc1d981
commit
b888963f6f
5 changed files with 0 additions and 10 deletions
|
@ -236,7 +236,6 @@ final class ArcanistSettings extends Phobject {
|
|||
throw new Exception(
|
||||
pht(
|
||||
'Use "arc alias" to configure aliases, not "arc set-config".'));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -336,7 +336,6 @@ final class PhutilTypeSpec extends Phobject {
|
|||
$obj->subtypes[] = $r;
|
||||
return $obj;
|
||||
}
|
||||
break;
|
||||
case 'map_type':
|
||||
$obj = new PhutilTypeSpec();
|
||||
$obj->type = 'map';
|
||||
|
@ -355,7 +354,6 @@ final class PhutilTypeSpec extends Phobject {
|
|||
} else {
|
||||
return $tokens[0];
|
||||
}
|
||||
break;
|
||||
case 'maybe_comment':
|
||||
if ($production == 'yes') {
|
||||
$tokens[0]->comment = $tokens[1];
|
||||
|
|
|
@ -610,7 +610,6 @@ EOTEXT
|
|||
break;
|
||||
default:
|
||||
throw new Exception(pht('No test block for diff file %s.', $diff_file));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ final class XHPASTNode extends AASTNode {
|
|||
switch ($this->getTypeName()) {
|
||||
case 'n_STATEMENT':
|
||||
return $this->getChildByIndex(0)->evalStatic();
|
||||
break;
|
||||
case 'n_STRING_SCALAR':
|
||||
return phutil_string_cast($this->getStringLiteralValue());
|
||||
case 'n_HEREDOC':
|
||||
|
@ -61,22 +60,18 @@ final class XHPASTNode extends AASTNode {
|
|||
default:
|
||||
throw new Exception(pht('Unrecognized symbol name.'));
|
||||
}
|
||||
break;
|
||||
case 'n_UNARY_PREFIX_EXPRESSION':
|
||||
$operator = $this->getChildOfType(0, 'n_OPERATOR');
|
||||
$operand = $this->getChildByIndex(1);
|
||||
switch ($operator->getSemanticString()) {
|
||||
case '-':
|
||||
return -$operand->evalStatic();
|
||||
break;
|
||||
case '+':
|
||||
return $operand->evalStatic();
|
||||
break;
|
||||
default:
|
||||
throw new Exception(
|
||||
pht('Unexpected operator in static expression.'));
|
||||
}
|
||||
break;
|
||||
case 'n_ARRAY_LITERAL':
|
||||
$result = array();
|
||||
$values = $this->getChildOfType(0, 'n_ARRAY_VALUE_LIST');
|
||||
|
|
|
@ -68,7 +68,6 @@ function xsprintf_terminal($userdata, &$pattern, &$pos, &$value, &$length) {
|
|||
'Unsupported escape sequence "%s" found in pattern: %s',
|
||||
$type,
|
||||
$pattern));
|
||||
break;
|
||||
}
|
||||
|
||||
$pattern[$pos] = $type;
|
||||
|
|
Loading…
Reference in a new issue