A linter that removes blank lines:
final class BlankLineLinter extends ArcanistLinter { public function getLinterName() { return 'Blank Lines'; } public function lintPath($path) { $data = $this->getData($path); $lines = explode("\n", $data); $lineno = 0; foreach ($lines as $line) { $lineno++; if ($line == "") { $message = new ArcanistLintMessage(); $message->setPath($path); $message->setLine($lineno); $message->setCode($this->getLinterName()); $message->setName("Blank line"); $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING); $message->setChar(0); $message->setOriginalText("\n"); $message->setReplacementText(""); $this->addLintMessage($message); } } } }
...applied to a file with a blank line in it:
first second third, blank after fifth, blank before sixth
...yields:
>>> Lint for foo.txt: Warning (Blank Lines) Blank line 1 first 2 second 3 third, blank after >>> - 4 - 5 fifth, blank before + 6 sixth
...which makes it appear that line 5 is being removed, when it is not. The + line is also irrelevant and misleading, as nothing is being added.
This can also be seen with the ArcanistTextLinter, when removing EOF_WHITESPACE:
$ echo -e "one\ntwo\nthree newlines now:\n\n\n" > foo.txt $ arc lint foo.txt >>> Lint for foo.txt: Warning (TXT9) Trailing Whitespace at EOF This file contains trailing whitespace at the end of the file. This is unnecessary and should be avoided when possible. 1 one 2 two 3 three newlines now: >>> - 4 - 5 - 6 - 7 +
Note that foo.txt only has 6 lines, as seen by most programs:
$ cat -n foo.txt 1 one 2 two 3 three newlines now: 4 5 6