Page MenuHomePhabricator

D10472.id25184.diff
No OneTemporary

D10472.id25184.diff

diff --git a/src/lint/linter/ArcanistTextLinter.php b/src/lint/linter/ArcanistTextLinter.php
--- a/src/lint/linter/ArcanistTextLinter.php
+++ b/src/lint/linter/ArcanistTextLinter.php
@@ -123,17 +123,26 @@
}
protected function lintNewlines($path) {
- $pos = strpos($this->getData($path), "\r");
- if ($pos !== false) {
- $this->raiseLintAtOffset(
- $pos,
- self::LINT_DOS_NEWLINE,
- 'You must use ONLY Unix linebreaks ("\n") in source code.',
- "\r");
- if ($this->isMessageEnabled(self::LINT_DOS_NEWLINE)) {
- $this->stopAllLinters();
+ $pos = 0;
+ $failed = false;
+
+ while ($pos !== false) {
+ $pos = strpos($this->getData($path), "\r", $pos ? ($pos + 1) : 0);
+
+ if ($pos !== false) {
+ $failed = true;
+ $this->raiseLintAtOffset(
+ $pos,
+ self::LINT_DOS_NEWLINE,
+ 'You must use ONLY Unix linebreaks ("\n") in source code.',
+ "\r",
+ '');
}
}
+
+ if ($failed && $this->isMessageEnabled(self::LINT_DOS_NEWLINE)) {
+ $this->stopAllLinters();
+ }
}
protected function lintTabs($path) {
diff --git a/src/lint/linter/__tests__/text/dos-newline.lint-test b/src/lint/linter/__tests__/text/dos-newline.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/__tests__/text/dos-newline.lint-test
@@ -0,0 +1,8 @@
+The quick brown fox
+jumps over the lazy dog.
+~~~~~~~~~~
+error:1:20
+error:2:25
+~~~~~~~~~~
+The quick brown fox
+jumps over the lazy dog.

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 24, 3:52 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6746866
Default Alt Text
D10472.id25184.diff (1 KB)

Event Timeline