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(
|
throw new Exception(
|
||||||
pht(
|
pht(
|
||||||
'Use "arc alias" to configure aliases, not "arc set-config".'));
|
'Use "arc alias" to configure aliases, not "arc set-config".'));
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,6 @@ final class PhutilTypeSpec extends Phobject {
|
||||||
$obj->subtypes[] = $r;
|
$obj->subtypes[] = $r;
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 'map_type':
|
case 'map_type':
|
||||||
$obj = new PhutilTypeSpec();
|
$obj = new PhutilTypeSpec();
|
||||||
$obj->type = 'map';
|
$obj->type = 'map';
|
||||||
|
@ -355,7 +354,6 @@ final class PhutilTypeSpec extends Phobject {
|
||||||
} else {
|
} else {
|
||||||
return $tokens[0];
|
return $tokens[0];
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 'maybe_comment':
|
case 'maybe_comment':
|
||||||
if ($production == 'yes') {
|
if ($production == 'yes') {
|
||||||
$tokens[0]->comment = $tokens[1];
|
$tokens[0]->comment = $tokens[1];
|
||||||
|
|
|
@ -610,7 +610,6 @@ EOTEXT
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception(pht('No test block for diff file %s.', $diff_file));
|
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()) {
|
switch ($this->getTypeName()) {
|
||||||
case 'n_STATEMENT':
|
case 'n_STATEMENT':
|
||||||
return $this->getChildByIndex(0)->evalStatic();
|
return $this->getChildByIndex(0)->evalStatic();
|
||||||
break;
|
|
||||||
case 'n_STRING_SCALAR':
|
case 'n_STRING_SCALAR':
|
||||||
return phutil_string_cast($this->getStringLiteralValue());
|
return phutil_string_cast($this->getStringLiteralValue());
|
||||||
case 'n_HEREDOC':
|
case 'n_HEREDOC':
|
||||||
|
@ -61,22 +60,18 @@ final class XHPASTNode extends AASTNode {
|
||||||
default:
|
default:
|
||||||
throw new Exception(pht('Unrecognized symbol name.'));
|
throw new Exception(pht('Unrecognized symbol name.'));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 'n_UNARY_PREFIX_EXPRESSION':
|
case 'n_UNARY_PREFIX_EXPRESSION':
|
||||||
$operator = $this->getChildOfType(0, 'n_OPERATOR');
|
$operator = $this->getChildOfType(0, 'n_OPERATOR');
|
||||||
$operand = $this->getChildByIndex(1);
|
$operand = $this->getChildByIndex(1);
|
||||||
switch ($operator->getSemanticString()) {
|
switch ($operator->getSemanticString()) {
|
||||||
case '-':
|
case '-':
|
||||||
return -$operand->evalStatic();
|
return -$operand->evalStatic();
|
||||||
break;
|
|
||||||
case '+':
|
case '+':
|
||||||
return $operand->evalStatic();
|
return $operand->evalStatic();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
pht('Unexpected operator in static expression.'));
|
pht('Unexpected operator in static expression.'));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 'n_ARRAY_LITERAL':
|
case 'n_ARRAY_LITERAL':
|
||||||
$result = array();
|
$result = array();
|
||||||
$values = $this->getChildOfType(0, 'n_ARRAY_VALUE_LIST');
|
$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',
|
'Unsupported escape sequence "%s" found in pattern: %s',
|
||||||
$type,
|
$type,
|
||||||
$pattern));
|
$pattern));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pattern[$pos] = $type;
|
$pattern[$pos] = $type;
|
||||||
|
|
Loading…
Reference in a new issue