From a6e81daad1bbd470c1907a7ea705b2e084fc07dd Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Mon, 7 Dec 2015 20:20:57 +0000 Subject: [PATCH] Improve brace formatting linter rule Summary: Allow the brace formatting linter rule to complain about `class X{}`. Test Plan: Updated unit tests. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14690 --- ...rcanistBraceFormattingXHPASTLinterRule.php | 8 -- .../brace-formatting.lint-test | 87 ------------------- .../brace-formatting/class.lint-test | 14 +++ .../control-statement.lint-test | 53 +++++++++++ .../brace-formatting/declare.lint-test | 4 + .../brace-formatting/function.lint-test | 27 ++++++ .../brace-formatting/try-catch.lint-test | 14 +++ 7 files changed, 112 insertions(+), 95 deletions(-) delete mode 100644 src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test create mode 100644 src/lint/linter/xhpast/rules/__tests__/brace-formatting/class.lint-test create mode 100644 src/lint/linter/xhpast/rules/__tests__/brace-formatting/control-statement.lint-test create mode 100644 src/lint/linter/xhpast/rules/__tests__/brace-formatting/declare.lint-test create mode 100644 src/lint/linter/xhpast/rules/__tests__/brace-formatting/function.lint-test create mode 100644 src/lint/linter/xhpast/rules/__tests__/brace-formatting/try-catch.lint-test diff --git a/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php index 0a8c33b7..775c6f18 100644 --- a/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php +++ b/src/lint/linter/xhpast/rules/ArcanistBraceFormattingXHPASTLinterRule.php @@ -24,14 +24,6 @@ final class ArcanistBraceFormattingXHPASTLinterRule if (!$before) { $first = head($tokens); - // Only insert the space if we're after a closing parenthesis. If - // we're in a construct like "else{}", other rules will insert space - // after the 'else' correctly. - $prev = $first->getPrevToken(); - if (!$prev || $prev->getValue() !== ')') { - continue; - } - $this->raiseLintAtToken( $first, pht( diff --git a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test b/src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test deleted file mode 100644 index 725773f3..00000000 --- a/src/lint/linter/xhpast/rules/__tests__/brace-formatting/brace-formatting.lint-test +++ /dev/null @@ -1,87 +0,0 @@ -