]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Allow spaces after the `.` operator if followed by a comment.
authorJoshua Spence <josh@joshuaspence.com>
Mon, 9 Jun 2014 19:25:14 +0000 (12:25 -0700)
committerepriestley <git@epriestley.com>
Mon, 9 Jun 2014 19:25:14 +0000 (12:25 -0700)
Summary: Currently, `'foo'.    // Some comment` is not allowed by the `ArcanistXHPASTLinter::LINT_BINARY_EXPRESSION_SPACING` rule. I believe that in the case of a trailing comment, we //should// allow whitespace after the `.` operator.

Test Plan: Wrote and executed a unit test for this case.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9438

src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/space-around-more-operators.lint-test

index 4337c6e2a86459fc00c78c3a234fe19660ea8448..0776a346e82ac8f770927aec8650cde9785c75d1 100644 (file)
@@ -1975,6 +1975,11 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
           continue;
         }
 
+        $next = $wtoken->getNextToken();
+        if ($next && $next->getTypeName() == 'T_COMMENT') {
+          continue;
+        }
+
         $this->raiseLintAtToken(
           $wtoken,
           self::LINT_BINARY_EXPRESSION_SPACING,
index 553979d779c6191d88f91d50c80a1b9b22f32a47..7fe6108b3ea5b0302f8901eebb4a6d0f6a846e7f 100644 (file)
@@ -5,6 +5,8 @@ $a. $b;
 $a .$b;
 $a.
 $b;
+$a.   // This should be okay.
+$b;
 
 array($x => $y);
 array($x=>$y);
@@ -26,10 +28,10 @@ warning:3:3
 warning:3:5
 warning:4:4
 warning:5:3
-warning:10:9
-warning:11:10
 warning:12:9
-warning:22:5
+warning:13:10
+warning:14:9
+warning:24:5
 ~~~~~~~~~~
 <?php
 $a.$b;
@@ -38,6 +40,8 @@ $a.$b;
 $a.$b;
 $a.
 $b;
+$a.   // This should be okay.
+$b;
 
 array($x => $y);
 array($x => $y);