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
Unknown Object (File)
Wed, Nov 27, 1:15 PM
Unknown Object (File)
Tue, Nov 26, 2:37 AM
Unknown Object (File)
Tue, Nov 26, 2:33 AM
Unknown Object (File)
Tue, Nov 26, 2:30 AM
Unknown Object (File)
Tue, Nov 26, 2:25 AM
Unknown Object (File)
Thu, Nov 21, 8:03 PM
Unknown Object (File)
Mon, Nov 18, 5:46 AM
Unknown Object (File)
Fri, Nov 15, 7:10 AM
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
Lint
Lint Skipped
Unit
Tests Skipped

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
128–129

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