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)
Tue, Sep 17, 10:21 PM
Unknown Object (File)
Sat, Sep 14, 9:43 PM
Unknown Object (File)
Thu, Sep 12, 3:20 PM
Unknown Object (File)
Thu, Sep 5, 5:35 PM
Unknown Object (File)
Thu, Sep 5, 10:31 AM
Unknown Object (File)
Mon, Sep 2, 6:35 AM
Unknown Object (File)
Wed, Aug 28, 3:05 AM
Unknown Object (File)
Sat, Aug 24, 4:50 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
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