mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-16 16:58:38 +01:00
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
This commit is contained in:
parent
91d273a7dd
commit
6b22184712
2 changed files with 18 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -954,6 +954,15 @@ class ArcanistXHPASTLinter extends ArcanistLinter {
|
|||
self::LINT_FORMATTING_CONVENTIONS,
|
||||
'Convention: put a space after control statements.',
|
||||
$token->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;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ if ($x) {}
|
|||
else if ($y) {}
|
||||
else if ($z) {}
|
||||
<strong>if</strong>;
|
||||
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
|
||||
~~~~~~~~~~
|
||||
<?php
|
||||
if ($x) {}
|
||||
|
@ -32,3 +38,5 @@ if ($x) {}
|
|||
else if ($y) {}
|
||||
else if ($z) {}
|
||||
<strong>if</strong>;
|
||||
if ($x) {}
|
||||
if ($x) {}
|
||||
|
|
Loading…
Add table
Reference in a new issue