mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +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:
parent
5951ec26b4
commit
888ada2f38
2 changed files with 14 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
|
|
7
src/lint/linter/__tests__/text/dos-newline.lint-test
Normal file
7
src/lint/linter/__tests__/text/dos-newline.lint-test
Normal 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.
|
Loading…
Reference in a new issue