@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

-55
-1
src/applications/auth/factor/PhabricatorDuoAuthFactor.php
··· 650 650 'You denied this request. Wait %s second(s) to try again.', 651 651 new PhutilNumber($wait_duration))); 652 652 } 653 - break; 654 653 } 655 654 656 655 return null;
-8
src/applications/auth/storage/PhabricatorAuthProviderConfigTransaction.php
··· 79 79 '%s disabled this provider.', 80 80 $this->renderHandleLink($author_phid)); 81 81 } 82 - break; 83 82 case self::TYPE_LOGIN: 84 83 if ($new) { 85 84 return pht( ··· 90 89 '%s disabled login.', 91 90 $this->renderHandleLink($author_phid)); 92 91 } 93 - break; 94 92 case self::TYPE_REGISTRATION: 95 93 if ($new) { 96 94 return pht( ··· 101 99 '%s disabled registration.', 102 100 $this->renderHandleLink($author_phid)); 103 101 } 104 - break; 105 102 case self::TYPE_LINK: 106 103 if ($new) { 107 104 return pht( ··· 112 109 '%s disabled account linking.', 113 110 $this->renderHandleLink($author_phid)); 114 111 } 115 - break; 116 112 case self::TYPE_UNLINK: 117 113 if ($new) { 118 114 return pht( ··· 123 119 '%s disabled account unlinking.', 124 120 $this->renderHandleLink($author_phid)); 125 121 } 126 - break; 127 122 case self::TYPE_TRUST_EMAILS: 128 123 if ($new) { 129 124 return pht( ··· 134 129 '%s disabled email trust.', 135 130 $this->renderHandleLink($author_phid)); 136 131 } 137 - break; 138 132 case self::TYPE_AUTO_LOGIN: 139 133 if ($new) { 140 134 return pht( ··· 145 139 '%s disabled auto login.', 146 140 $this->renderHandleLink($author_phid)); 147 141 } 148 - break; 149 142 case self::TYPE_PROPERTY: 150 143 $provider = $this->getProvider(); 151 144 if ($provider) { ··· 158 151 return pht( 159 152 '%s edited a property of this provider.', 160 153 $this->renderHandleLink($author_phid)); 161 - break; 162 154 } 163 155 164 156 return parent::getTitle();
-1
src/applications/calendar/parser/data/PhutilCalendarRecurrenceRule.php
··· 575 575 pht( 576 576 'RRULE specifies BYMONTHDAY with FREQ set to WEEKLY, which '. 577 577 'violates RFC5545.')); 578 - break; 579 578 default: 580 579 break; 581 580 }
-3
src/applications/config/storage/PhabricatorConfigTransaction.php
··· 45 45 '%s edited this configuration entry.', 46 46 $this->renderHandleLink($author_phid)); 47 47 } 48 - break; 49 48 } 50 49 51 50 return parent::getTitle(); ··· 83 82 $this->renderHandleLink($author_phid), 84 83 $this->getObject()->getConfigKey()); 85 84 } 86 - break; 87 85 } 88 86 89 87 return parent::getTitle(); ··· 145 143 } else { 146 144 return PhabricatorTransactions::COLOR_BLUE; 147 145 } 148 - break; 149 146 } 150 147 } 151 148
-1
src/applications/conpherence/conduit/ConpherenceCreateThreadConduitAPIMethod.php
··· 62 62 switch ($error_code) { 63 63 case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS: 64 64 throw new ConduitException('ERR_EMPTY_PARTICIPANT_PHIDS'); 65 - break; 66 65 } 67 66 } 68 67 }
-4
src/applications/conpherence/controller/ConpherenceUpdateController.php
··· 139 139 break; 140 140 default: 141 141 throw new Exception(pht('Unknown action: %s', $action)); 142 - break; 143 142 } 144 143 145 144 if ($xactions) { ··· 173 172 $latest_transaction_id); 174 173 return id(new AphrontAjaxResponse()) 175 174 ->setContent($content); 176 - break; 177 175 case 'go-home': 178 176 $content = array( 179 177 'href' => $this->getApplicationURI(), 180 178 ); 181 179 return id(new AphrontAjaxResponse()) 182 180 ->setContent($content); 183 - break; 184 181 case 'redirect': 185 182 default: 186 183 return id(new AphrontRedirectResponse()) 187 184 ->setURI('/'.$conpherence->getMonogram()); 188 - break; 189 185 } 190 186 } 191 187 }
-1
src/applications/conpherence/storage/ConpherenceThread.php
··· 271 271 switch ($capability) { 272 272 case PhabricatorPolicyCapability::CAN_VIEW: 273 273 return pht('Participants in a room can always view it.'); 274 - break; 275 274 } 276 275 } 277 276
-1
src/applications/conpherence/view/ConpherenceTransactionView.php
··· 88 88 $viewer, 89 89 'M jS, Y')), 90 90 )); 91 - break; 92 91 } 93 92 94 93 $info = $this->renderTransactionInfo();
-1
src/applications/differential/conduit/DifferentialCreateCommentConduitAPIMethod.php
··· 81 81 pht( 82 82 'Unsupported action "%s".', 83 83 $action)); 84 - break; 85 84 } 86 85 } 87 86
-3
src/applications/differential/storage/DifferentialTransaction.php
··· 252 252 $commit_name, 253 253 $author_name); 254 254 } 255 - break; 256 255 default: 257 256 return DifferentialAction::getBasicStoryText($new, $author_handle); 258 257 } 259 - break; 260 258 } 261 259 262 260 return parent::getTitle(); ··· 366 364 $commit_name); 367 365 } 368 366 } 369 - break; 370 367 371 368 case DifferentialAction::ACTION_REQUEST: 372 369 return pht(
-1
src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php
··· 162 162 break; 163 163 default: 164 164 throw new ConduitException('ERR-UNKNOWN-VCS-TYPE'); 165 - break; 166 165 } 167 166 return $result; 168 167 }
-1
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 1371 1371 1372 1372 return id(new DiffusionCommitRef()) 1373 1373 ->setMessage($message); 1374 - break; 1375 1374 default: 1376 1375 throw new Exception(pht("Unknown VCS '%s!'", $vcs)); 1377 1376 }
-1
src/applications/feed/story/PhabricatorFeedStory.php
··· 223 223 break; 224 224 default: 225 225 throw new Exception(pht('Unknown rendering target: %s', $target)); 226 - break; 227 226 } 228 227 } 229 228
-1
src/applications/files/management/PhabricatorFilesManagementRebuildWorkflow.php
··· 139 139 return 0; 140 140 } 141 141 142 - return 0; 143 142 } 144 143 }
-3
src/applications/files/storage/PhabricatorFile.php
··· 1038 1038 case 'jpg'; 1039 1039 case 'jpeg': 1040 1040 return function_exists('imagejpeg'); 1041 - break; 1042 1041 case 'png': 1043 1042 return function_exists('imagepng'); 1044 - break; 1045 1043 case 'gif': 1046 1044 return function_exists('imagegif'); 1047 - break; 1048 1045 default: 1049 1046 throw new Exception(pht('Unknown type matched as image MIME type.')); 1050 1047 }
-1
src/applications/flag/query/PhabricatorFlagQuery.php
··· 123 123 default: 124 124 throw new Exception( 125 125 pht('Unknown groupBy parameter: %s', $this->groupBy)); 126 - break; 127 126 } 128 127 129 128 return $flags;
-1
src/applications/herald/field/HeraldField.php
··· 144 144 145 145 return $tokenizer; 146 146 } 147 - break; 148 147 149 148 } 150 149
-1
src/applications/legalpad/storage/LegalpadDocumentBody.php
··· 54 54 break; 55 55 default: 56 56 throw new Exception(pht('Unknown field: %s', $field)); 57 - break; 58 57 } 59 58 60 59 return $text;
-1
src/applications/maniphest/storage/ManiphestTransaction.php
··· 130 130 $this->renderHandleLink($author_phid), 131 131 $this->renderSubtypeName($old), 132 132 $this->renderSubtypeName($new)); 133 - break; 134 133 } 135 134 136 135 return parent::getTitle();
-5
src/applications/nuance/github/NuanceGitHubRawEvent.php
··· 266 266 default: 267 267 return pht('Ref %s', $ref); 268 268 } 269 - break; 270 269 case 'PushEvent': 271 270 $ref = idxv($raw, array('payload', 'ref')); 272 271 if (preg_match('(^refs/heads/)', $ref)) { ··· 274 273 } else { 275 274 return pht('Ref %s', $ref); 276 275 } 277 - break; 278 276 case 'WatchEvent': 279 277 $actor = idxv($raw, array('actor', 'login')); 280 278 return pht('User %s', $actor); ··· 362 360 default: 363 361 return pht('"%s"', $action); 364 362 } 365 - break; 366 363 case 'IssueCommentEvent': 367 364 $action = idxv($raw, array('payload', 'action')); 368 365 switch ($action) { ··· 371 368 default: 372 369 return pht('"%s"', $action); 373 370 } 374 - break; 375 371 case 'PullRequestEvent': 376 372 $action = idxv($raw, array('payload', 'action')); 377 373 switch ($action) { ··· 380 376 default: 381 377 return pht('"%s"', $action); 382 378 } 383 - break; 384 379 case 'WatchEvent': 385 380 return pht('Watched'); 386 381 }
-1
src/applications/phame/storage/PhamePost.php
··· 222 222 } else { 223 223 return PhabricatorPolicies::POLICY_NOONE; 224 224 } 225 - break; 226 225 case PhabricatorPolicyCapability::CAN_EDIT: 227 226 if ($this->getBlog()) { 228 227 return $this->getBlog()->getEditPolicy();
-1
src/applications/phrequent/storage/PhrequentTimeBlock.php
··· 318 318 } 319 319 } 320 320 321 - return 0; 322 321 } 323 322 324 323 }
-3
src/applications/settings/setting/PhabricatorConpherenceSoundSetting.php
··· 50 50 ConpherenceRoomSettings::SOUND_MENTION => 51 51 ConpherenceRoomSettings::DEFAULT_MENTION_SOUND, 52 52 ); 53 - break; 54 53 case self::VALUE_CONPHERENCE_MENTION: 55 54 return array( 56 55 ConpherenceRoomSettings::SOUND_RECEIVE => ··· 58 57 ConpherenceRoomSettings::SOUND_MENTION => 59 58 ConpherenceRoomSettings::DEFAULT_MENTION_SOUND, 60 59 ); 61 - break; 62 60 case self::VALUE_CONPHERENCE_SILENT: 63 61 return array( 64 62 ConpherenceRoomSettings::SOUND_RECEIVE => ··· 66 64 ConpherenceRoomSettings::SOUND_MENTION => 67 65 ConpherenceRoomSettings::DEFAULT_NO_SOUND, 68 66 ); 69 - break; 70 67 } 71 68 } 72 69
-1
src/applications/transactions/controller/PhabricatorApplicationTransactionValueController.php
··· 37 37 break; 38 38 default: 39 39 return new Aphront404Response(); 40 - break; 41 40 } 42 41 43 42 if ($type == 'old') {
-8
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 678 678 } else { 679 679 return false; 680 680 } 681 - break; 682 681 case PhabricatorTransactions::TYPE_CUSTOMFIELD: 683 682 $field = $this->getTransactionCustomField(); 684 683 if ($field) { ··· 705 704 return true; 706 705 } 707 706 return false; 708 - break; 709 707 default: 710 708 break; 711 709 } ··· 1061 1059 '%s updated subscribers...', 1062 1060 $this->renderHandleLink($author_phid)); 1063 1061 } 1064 - break; 1065 1062 case PhabricatorTransactions::TYPE_FILE: 1066 1063 $add = array_diff_key($new, $old); 1067 1064 $add = array_keys($add); ··· 1179 1176 $this->renderHandleLink($author_phid)); 1180 1177 } 1181 1178 1182 - break; 1183 1179 case PhabricatorTransactions::TYPE_EDGE: 1184 1180 $record = PhabricatorEdgeChangeRecord::newFromTransaction($this); 1185 1181 $add = $record->getAddedPHIDs(); ··· 1275 1271 $this->renderHandleLink($author_phid), 1276 1272 new PhutilNumber($undone)); 1277 1273 } 1278 - break; 1279 1274 1280 1275 case PhabricatorTransactions::TYPE_COLUMNS: 1281 1276 $moves = $this->getInterestingMoves($new); ··· 1315 1310 phutil_count($moves), 1316 1311 phutil_implode_html(', ', $fragments)); 1317 1312 } 1318 - break; 1319 - 1320 1313 1321 1314 case PhabricatorTransactions::TYPE_MFA: 1322 1315 return pht( ··· 1490 1483 phutil_count($moves), 1491 1484 phutil_implode_html(', ', $fragments)); 1492 1485 } 1493 - break; 1494 1486 1495 1487 case PhabricatorTransactions::TYPE_MFA: 1496 1488 return null;
-1
src/view/phui/PHUIHeaderView.php
··· 376 376 break; 377 377 default: 378 378 throw new Exception(pht('Incorrect Property Passed')); 379 - break; 380 379 } 381 380 } 382 381