Page MenuHomePhabricator

Add an XHPAST lint rule for empty block statements
ClosedPublic

Authored by joshuaspence on Sep 6 2014, 6:58 AM.
Tags
None
Referenced Files
F14033544: D10434.diff
Sat, Nov 9, 6:03 PM
F14021798: D10434.diff
Wed, Nov 6, 12:08 PM
F13965477: D10434.id.diff
Wed, Oct 16, 2:20 AM
F13961946: D10434.id25095.diff
Tue, Oct 15, 7:12 AM
Unknown Object (File)
Oct 1 2024, 7:31 PM
Unknown Object (File)
Sep 17 2024, 10:21 PM
Unknown Object (File)
Sep 14 2024, 9:43 PM
Unknown Object (File)
Sep 12 2024, 3:20 PM
Subscribers

Details

Summary

Adds an XHPAST linter rule for empty block statements. Basically, if a block statement is empty then it is much neater if the opening ({) and closing (}) braces are adjacent. Maybe this is just my own personal preference, in which case we could reduce the default severity to ArcanistLintSeverity::SEVERITY_DISABLED.

Test Plan

Wrote unit tests. I had to modify a bunch of existing unit tests accordingly.

Diff Detail

Repository
rARC Arcanist
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 2452
Build 2456: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

joshuaspence retitled this revision from to Add an XHPAST lint rule for empty block statements.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.

In normal code I think empty bodies should usually have an explanatory comment (e.g., why the exception is OK to drop on the ground in an empty catch block, or what a loop-acting-through-side-effects is doing) although I wouldn't want to force that. This rule seems OK for blocks without a comment.

src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test
125

Maybe add a comment here instead, this seems less readable than the old version was.

This revision is now accepted and ready to land.Sep 8 2014, 1:58 PM