Page MenuHomePhabricator

Add a ternary expression spacing linter rule
AcceptedPublic

Authored by joshuaspence on Aug 19 2015, 9:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 5, 5:47 AM
Unknown Object (File)
Mar 28 2024, 4:19 PM
Unknown Object (File)
Mar 4 2024, 2:11 PM
Unknown Object (File)
Feb 17 2024, 1:26 AM
Unknown Object (File)
Feb 9 2024, 12:14 PM
Unknown Object (File)
Feb 9 2024, 9:59 AM
Unknown Object (File)
Jan 28 2024, 8:16 AM
Unknown Object (File)
Jan 28 2024, 8:15 AM
Subscribers

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Summary

Adds a linter rule to warn against incorrect ternary expression spacing.

Test Plan

Added test cases... this still needs some work.

Diff Detail

Repository
rARC Arcanist
Branch
master
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 8941
Build 10490: Run Core Tests
Build 10489: arc lint + arc unit

Event Timeline

joshuaspence retitled this revision from to Adda ternary expression spacing linter rule.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.

@epriestley, this linter rule would be much easier if we change the way ternary expressions are parsed (specifically, if we add n_OPERATOR nodes for ? and :)... I'm not sure if this is desirable though.

joshuaspence retitled this revision from Adda ternary expression spacing linter rule to Add a ternary expression spacing linter rule.Aug 19 2015, 10:17 PM
joshuaspence edited edge metadata.
epriestley edited edge metadata.
This revision is now accepted and ready to land.Aug 27 2015, 11:26 AM

The parser change elsewhere seems correct/desirable to me.

Maybe included nested ternary operators in the test case, too, since this will also not get that quite right (the operators will be selected by both the parent and child and we'll raise extra warnings, I think)?

src/lint/linter/__tests__/xhpast/ternary-expression-spacing.lint-test
14 ↗(On Diff #33642)

(We should fix this, of course, but presumably that's straightforward with the operator fix.)