Page MenuHomePhorge

Remove trivial cases of unreachable code
ClosedPublic

Authored by aklapper on Aug 24 2024, 08:53.
Tags
None
Referenced Files
F3290725: D25803.1742871498.diff
Mon, Mar 24, 02:58
F3285199: D25803.1742795301.diff
Sun, Mar 23, 05:48
F3254919: D25803.1742488094.diff
Wed, Mar 19, 16:28
F3224427: D25803.1742026760.diff
Fri, Mar 14, 08:19
F3094683: D25803.1741101027.diff
Mon, Mar 3, 15:10
F3018579: D25803.1740772917.diff
Thu, Feb 27, 20:01
F3012752: D25803.1740682241.diff
Wed, Feb 26, 18:50
F2995432: D25803.1740341528.diff
Feb 22 2025, 20:12

Details

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.

Diff Detail

Repository
rARC Arcanist
Branch
unreachableCode
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 1563
Build 1563: arc lint + arc unit

Unit TestsFailed

TimeTest
724 msArcanistBundleTestCase::testGitRepository
EXCEPTION (Exception): Expected patch and actual patch for 5dec8bf28557f078d1987c4e8cfb53d08310f522 differ. Wrote actual patch to '/var/www/html/phorge/arcanist/src/parser/__tests__/patches//5dec8bf28557f078d1987c4e8cfb53d08310f522.gitpatch.real'. #0 /var/www/html/phorge/arcanist/src/parser/__tests__/ArcanistBundleTestCase.php(85): ArcanistBundleTestCase->runGitRepositoryTests(Object(PhutilDirectoryFixture)) #1 /var/www/html/phorge/arcanist/src/unit/engine/phutil/PhutilTestCase.php(639): ArcanistBundleTestCase->testGitRepository()
75 msArcanistBaseCommitParserTestCase::testBasics
2 assertion(s) passed.
74 msArcanistBaseCommitParserTestCase::testHalt
1 assertion(s) passed.
88 msArcanistBaseCommitParserTestCase::testJump
1 assertion(s) passed.
75 msArcanistBaseCommitParserTestCase::testJumpReturn
1 assertion(s) passed.
View Full Test Results (1 Failed · 88 Passed)