From: epriestley Date: Wed, 4 Jan 2012 18:59:00 +0000 (-0800) Subject: Make XHPAST linter correct too much space after control keywords like "if" X-Git-Tag: conduit-4~202 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6b22184712917169e5fd7d500f3e500d07420504;p=arcanist.git Make XHPAST linter correct too much space after control keywords like "if" Summary: Previously, we would not correct excessive space after "if", etc. Test Plan: Ran test case. Reviewers: btrahan, jungejason, kiyoto Reviewed By: jungejason CC: aran, jungejason, epriestley Differential Revision: https://secure.phabricator.com/D1311 --- diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLinter.php b/src/lint/linter/xhpast/ArcanistXHPASTLinter.php index 28b26811..c552a32c 100644 --- a/src/lint/linter/xhpast/ArcanistXHPASTLinter.php +++ b/src/lint/linter/xhpast/ArcanistXHPASTLinter.php @@ -1,7 +1,7 @@ getValue().' '); + } else if (count($after) == 1) { + $space = head($after); + if ($space->isAnyWhitespace() && $space->getValue() != ' ') { + $this->raiseLintAtToken( + $space, + self::LINT_FORMATTING_CONVENTIONS, + 'Convention: put a single space after control statements.', + ' '); + } } break; } diff --git a/src/lint/linter/xhpast/__tests__/data/space-after-control-keywords.lint-test b/src/lint/linter/xhpast/__tests__/data/space-after-control-keywords.lint-test index 2d0a21a0..0febb585 100644 --- a/src/lint/linter/xhpast/__tests__/data/space-after-control-keywords.lint-test +++ b/src/lint/linter/xhpast/__tests__/data/space-after-control-keywords.lint-test @@ -10,6 +10,10 @@ if ($x) {} else if ($y) {} else if ($z) {} if; +if ($x) {} +if + +($x) {} ~~~~~~~~~~ warning:2:1 warning:3:1 @@ -19,6 +23,8 @@ warning:6:1 warning:7:1 warning:7:6 warning:8:1 +warning:13:3 +warning:14:3 ~~~~~~~~~~ if; +if ($x) {} +if ($x) {}