mirror of
https://we.phorge.it/source/phorge.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 Phorge 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/D25802
This commit is contained in:
parent
8c3a62d6af
commit
43539b220c
26 changed files with 0 additions and 55 deletions
|
@ -650,7 +650,6 @@ final class PhabricatorDuoAuthFactor
|
|||
'You denied this request. Wait %s second(s) to try again.',
|
||||
new PhutilNumber($wait_duration)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -79,7 +79,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled this provider.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_LOGIN:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -90,7 +89,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled login.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_REGISTRATION:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -101,7 +99,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled registration.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_LINK:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -112,7 +109,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled account linking.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_UNLINK:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -123,7 +119,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled account unlinking.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_TRUST_EMAILS:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -134,7 +129,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled email trust.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_AUTO_LOGIN:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -145,7 +139,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
'%s disabled auto login.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case self::TYPE_PROPERTY:
|
||||
$provider = $this->getProvider();
|
||||
if ($provider) {
|
||||
|
@ -158,7 +151,6 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
return pht(
|
||||
'%s edited a property of this provider.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
|
|
|
@ -575,7 +575,6 @@ final class PhutilCalendarRecurrenceRule
|
|||
pht(
|
||||
'RRULE specifies BYMONTHDAY with FREQ set to WEEKLY, which '.
|
||||
'violates RFC5545.'));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ final class PhabricatorConfigTransaction
|
|||
'%s edited this configuration entry.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
|
@ -83,7 +82,6 @@ final class PhabricatorConfigTransaction
|
|||
$this->renderHandleLink($author_phid),
|
||||
$this->getObject()->getConfigKey());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
|
@ -145,7 +143,6 @@ final class PhabricatorConfigTransaction
|
|||
} else {
|
||||
return PhabricatorTransactions::COLOR_BLUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ final class ConpherenceCreateThreadConduitAPIMethod
|
|||
switch ($error_code) {
|
||||
case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
|
||||
throw new ConduitException('ERR_EMPTY_PARTICIPANT_PHIDS');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,6 @@ final class ConpherenceUpdateController
|
|||
break;
|
||||
default:
|
||||
throw new Exception(pht('Unknown action: %s', $action));
|
||||
break;
|
||||
}
|
||||
|
||||
if ($xactions) {
|
||||
|
@ -173,19 +172,16 @@ final class ConpherenceUpdateController
|
|||
$latest_transaction_id);
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent($content);
|
||||
break;
|
||||
case 'go-home':
|
||||
$content = array(
|
||||
'href' => $this->getApplicationURI(),
|
||||
);
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent($content);
|
||||
break;
|
||||
case 'redirect':
|
||||
default:
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/'.$conpherence->getMonogram());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,6 @@ final class ConpherenceThread extends ConpherenceDAO
|
|||
switch ($capability) {
|
||||
case PhabricatorPolicyCapability::CAN_VIEW:
|
||||
return pht('Participants in a room can always view it.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||
$viewer,
|
||||
'M jS, Y')),
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
$info = $this->renderTransactionInfo();
|
||||
|
|
|
@ -81,7 +81,6 @@ final class DifferentialCreateCommentConduitAPIMethod
|
|||
pht(
|
||||
'Unsupported action "%s".',
|
||||
$action));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -252,11 +252,9 @@ final class DifferentialTransaction
|
|||
$commit_name,
|
||||
$author_name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return DifferentialAction::getBasicStoryText($new, $author_handle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
|
@ -366,7 +364,6 @@ final class DifferentialTransaction
|
|||
$commit_name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DifferentialAction::ACTION_REQUEST:
|
||||
return pht(
|
||||
|
|
|
@ -162,7 +162,6 @@ abstract class DiffusionQueryConduitAPIMethod
|
|||
break;
|
||||
default:
|
||||
throw new ConduitException('ERR-UNKNOWN-VCS-TYPE');
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -1371,7 +1371,6 @@ final class DiffusionCommitHookEngine extends Phobject {
|
|||
|
||||
return id(new DiffusionCommitRef())
|
||||
->setMessage($message);
|
||||
break;
|
||||
default:
|
||||
throw new Exception(pht("Unknown VCS '%s!'", $vcs));
|
||||
}
|
||||
|
|
|
@ -223,7 +223,6 @@ abstract class PhabricatorFeedStory
|
|||
break;
|
||||
default:
|
||||
throw new Exception(pht('Unknown rendering target: %s', $target));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,5 @@ final class PhabricatorFilesManagementRebuildWorkflow
|
|||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1038,13 +1038,10 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
|||
case 'jpg';
|
||||
case 'jpeg':
|
||||
return function_exists('imagejpeg');
|
||||
break;
|
||||
case 'png':
|
||||
return function_exists('imagepng');
|
||||
break;
|
||||
case 'gif':
|
||||
return function_exists('imagegif');
|
||||
break;
|
||||
default:
|
||||
throw new Exception(pht('Unknown type matched as image MIME type.'));
|
||||
}
|
||||
|
|
|
@ -123,7 +123,6 @@ final class PhabricatorFlagQuery
|
|||
default:
|
||||
throw new Exception(
|
||||
pht('Unknown groupBy parameter: %s', $this->groupBy));
|
||||
break;
|
||||
}
|
||||
|
||||
return $flags;
|
||||
|
|
|
@ -144,7 +144,6 @@ abstract class HeraldField extends Phobject {
|
|||
|
||||
return $tokenizer;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ final class LegalpadDocumentBody extends LegalpadDAO
|
|||
break;
|
||||
default:
|
||||
throw new Exception(pht('Unknown field: %s', $field));
|
||||
break;
|
||||
}
|
||||
|
||||
return $text;
|
||||
|
|
|
@ -130,7 +130,6 @@ final class ManiphestTransaction
|
|||
$this->renderHandleLink($author_phid),
|
||||
$this->renderSubtypeName($old),
|
||||
$this->renderSubtypeName($new));
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
|
|
|
@ -266,7 +266,6 @@ final class NuanceGitHubRawEvent extends Phobject {
|
|||
default:
|
||||
return pht('Ref %s', $ref);
|
||||
}
|
||||
break;
|
||||
case 'PushEvent':
|
||||
$ref = idxv($raw, array('payload', 'ref'));
|
||||
if (preg_match('(^refs/heads/)', $ref)) {
|
||||
|
@ -274,7 +273,6 @@ final class NuanceGitHubRawEvent extends Phobject {
|
|||
} else {
|
||||
return pht('Ref %s', $ref);
|
||||
}
|
||||
break;
|
||||
case 'WatchEvent':
|
||||
$actor = idxv($raw, array('actor', 'login'));
|
||||
return pht('User %s', $actor);
|
||||
|
@ -362,7 +360,6 @@ final class NuanceGitHubRawEvent extends Phobject {
|
|||
default:
|
||||
return pht('"%s"', $action);
|
||||
}
|
||||
break;
|
||||
case 'IssueCommentEvent':
|
||||
$action = idxv($raw, array('payload', 'action'));
|
||||
switch ($action) {
|
||||
|
@ -371,7 +368,6 @@ final class NuanceGitHubRawEvent extends Phobject {
|
|||
default:
|
||||
return pht('"%s"', $action);
|
||||
}
|
||||
break;
|
||||
case 'PullRequestEvent':
|
||||
$action = idxv($raw, array('payload', 'action'));
|
||||
switch ($action) {
|
||||
|
@ -380,7 +376,6 @@ final class NuanceGitHubRawEvent extends Phobject {
|
|||
default:
|
||||
return pht('"%s"', $action);
|
||||
}
|
||||
break;
|
||||
case 'WatchEvent':
|
||||
return pht('Watched');
|
||||
}
|
||||
|
|
|
@ -222,7 +222,6 @@ final class PhamePost extends PhameDAO
|
|||
} else {
|
||||
return PhabricatorPolicies::POLICY_NOONE;
|
||||
}
|
||||
break;
|
||||
case PhabricatorPolicyCapability::CAN_EDIT:
|
||||
if ($this->getBlog()) {
|
||||
return $this->getBlog()->getEditPolicy();
|
||||
|
|
|
@ -318,7 +318,6 @@ final class PhrequentTimeBlock extends Phobject {
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ final class PhabricatorConpherenceSoundSetting
|
|||
ConpherenceRoomSettings::SOUND_MENTION =>
|
||||
ConpherenceRoomSettings::DEFAULT_MENTION_SOUND,
|
||||
);
|
||||
break;
|
||||
case self::VALUE_CONPHERENCE_MENTION:
|
||||
return array(
|
||||
ConpherenceRoomSettings::SOUND_RECEIVE =>
|
||||
|
@ -58,7 +57,6 @@ final class PhabricatorConpherenceSoundSetting
|
|||
ConpherenceRoomSettings::SOUND_MENTION =>
|
||||
ConpherenceRoomSettings::DEFAULT_MENTION_SOUND,
|
||||
);
|
||||
break;
|
||||
case self::VALUE_CONPHERENCE_SILENT:
|
||||
return array(
|
||||
ConpherenceRoomSettings::SOUND_RECEIVE =>
|
||||
|
@ -66,7 +64,6 @@ final class PhabricatorConpherenceSoundSetting
|
|||
ConpherenceRoomSettings::SOUND_MENTION =>
|
||||
ConpherenceRoomSettings::DEFAULT_NO_SOUND,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ final class PhabricatorApplicationTransactionValueController
|
|||
break;
|
||||
default:
|
||||
return new Aphront404Response();
|
||||
break;
|
||||
}
|
||||
|
||||
if ($type == 'old') {
|
||||
|
|
|
@ -678,7 +678,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||
$field = $this->getTransactionCustomField();
|
||||
if ($field) {
|
||||
|
@ -705,7 +704,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1061,7 +1059,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
'%s updated subscribers...',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
break;
|
||||
case PhabricatorTransactions::TYPE_FILE:
|
||||
$add = array_diff_key($new, $old);
|
||||
$add = array_keys($add);
|
||||
|
@ -1179,7 +1176,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
|
||||
break;
|
||||
case PhabricatorTransactions::TYPE_EDGE:
|
||||
$record = PhabricatorEdgeChangeRecord::newFromTransaction($this);
|
||||
$add = $record->getAddedPHIDs();
|
||||
|
@ -1275,7 +1271,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
$this->renderHandleLink($author_phid),
|
||||
new PhutilNumber($undone));
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorTransactions::TYPE_COLUMNS:
|
||||
$moves = $this->getInterestingMoves($new);
|
||||
|
@ -1315,8 +1310,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
phutil_count($moves),
|
||||
phutil_implode_html(', ', $fragments));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case PhabricatorTransactions::TYPE_MFA:
|
||||
return pht(
|
||||
|
@ -1490,7 +1483,6 @@ abstract class PhabricatorApplicationTransaction
|
|||
phutil_count($moves),
|
||||
phutil_implode_html(', ', $fragments));
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorTransactions::TYPE_MFA:
|
||||
return null;
|
||||
|
|
|
@ -376,7 +376,6 @@ final class PHUIHeaderView extends AphrontTagView {
|
|||
break;
|
||||
default:
|
||||
throw new Exception(pht('Incorrect Property Passed'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue