Skip to content

Commit

Permalink
Fix a bug with whitespace linter
Browse files Browse the repository at this point in the history
Summary: Fix a MySqlWhitespace linter bug where it matches two whitespace lines too aggressively. We should discard whitespace only lines in the comparison since it is too easy for them to accidentally match

Reviewed By: lth

Differential Revision: D13776064

fbshipit-source-id: 1311a69
  • Loading branch information
yizhang82 authored and facebook-github-bot committed Jan 23, 2019
1 parent 5f38e20 commit 27be297
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion arcanist/lint/linter/FacebookMySQLWhitespaceLinter.php
Expand Up @@ -121,6 +121,19 @@ private function stripWhitespace($str) {
}

private function differsByWhitespaceOnly($line1, $line2) {
return $this->stripWhitespace($line1) === $this->stripWhitespace($line2);
if ($line1 === $line2) {
// Definitely don't flag two identical lines
return false;
}

$stripped_line1 = $this->stripWhitespace($line1);
$stripped_line2 = $this->stripWhitespace($line2);
if ($stripped_line1 === "" and
$stripped_line2 === "") {
// Don't want to flag two whitespace only lines by accident
return false;
}

return $stripped_line1 === $stripped_line2;
}
}

0 comments on commit 27be297

Please sign in to comment.