Page MenuHomePhabricator

Brace placement linter rule
Closed, ResolvedPublic

Description

I think that the brace placement linter rule needs some tweaking. For example:

<?php

if ($x) {
  echo 'foo';
}else {
  echo 'bar';
}

Running arc lint on the above example produces the following fix, which seems wrong:

@@ -4,4 +4,4 @@
   echo 'foo';
 }else {
   echo 'bar';
-}
+ }

I would expect the fix to look like this:

@@ -2,6 +2,6 @@
 
 if ($x) {
   echo 'foo';
-}else {
+} else {
   echo 'bar';
 }

Revisions and Commits

Event Timeline

joshuaspence raised the priority of this task from to Needs Triage.
joshuaspence updated the task description. (Show Details)
joshuaspence added a project: Lint.
joshuaspence added a subscriber: joshuaspence.

Another issue, if I lint this file twice, I get extra indentation unintentionally:

original
<?php

if ($foo) {
    echo "a";
}elseif($bar){
    echo "b";
}else{
    echo "c";
}
first pass
<?php

if ($foo) {
    echo 'a';
}else if($bar) {
    echo 'b';
 }else {
    echo 'c';
 }
second pass
<?php

if ($foo) {
    echo 'a';
}else if ($bar) {
    echo 'b';
  }else {
    echo 'c';
  }