1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-28 08:20:56 +01:00

Improve LINT_DOS_NEWLINE behavior

Summary: Improve the behavior of `ArcanistTextLinter` in dealing with `LINT_DOS_NEWLINE`. In particular, provide replacement text so that these linter issues can be autofixed.

Test Plan: Added a unit test.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D10472
This commit is contained in:
Joshua Spence 2014-09-25 07:13:10 +10:00
parent 5951ec26b4
commit 888ada2f38
2 changed files with 14 additions and 3 deletions

View file

@ -123,13 +123,17 @@ final class ArcanistTextLinter extends ArcanistLinter {
}
protected function lintNewlines($path) {
$pos = strpos($this->getData($path), "\r");
$data = $this->getData($path);
$pos = strpos($this->getData($path), "\r");
if ($pos !== false) {
$this->raiseLintAtOffset(
$pos,
0,
self::LINT_DOS_NEWLINE,
pht('You must use ONLY Unix linebreaks ("%s") in source code.', '\n'),
"\r");
$data,
str_replace("\r\n", "\n", $data));
if ($this->isMessageEnabled(self::LINT_DOS_NEWLINE)) {
$this->stopAllLinters();
}

View file

@ -0,0 +1,7 @@
The quick brown fox
jumps over the lazy dog.
~~~~~~~~~~
error:1:1
~~~~~~~~~~
The quick brown fox
jumps over the lazy dog.