1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 14:22:40 +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:
Andre Klapper 2024-08-24 10:52:56 +02:00
parent 201fc1d981
commit b888963f6f
5 changed files with 0 additions and 10 deletions

View file

@ -236,7 +236,6 @@ final class ArcanistSettings extends Phobject {
throw new Exception(
pht(
'Use "arc alias" to configure aliases, not "arc set-config".'));
break;
}

View file

@ -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];

View file

@ -610,7 +610,6 @@ EOTEXT
break;
default:
throw new Exception(pht('No test block for diff file %s.', $diff_file));
break;
}
}

View file

@ -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');

View file

@ -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;