Page MenuHomePhabricator

D10980.diff
No OneTemporary

D10980.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
@@ -15,6 +15,8 @@
const LINT_BOF_WHITESPACE = 8;
const LINT_EOF_WHITESPACE = 9;
+ private $checkNewlines = true;
+
private $maxLineLength = 80;
public function getInfoName() {
@@ -39,11 +41,22 @@
'Adjust the maximum line length before a warning is raised. By '.
'default, a warning is raised on lines exceeding 80 characters.'),
),
+ 'text.check-newlines' => array(
+ 'type' => 'optional bool',
+ 'help' => pht(
+ 'Whether to check line endings for UNIX conformance (LF). By '.
+ 'default true.'),
+ ),
);
return $options + parent::getLinterConfigurationOptions();
}
+ public function setCheckNewlines($active) {
+ $this->checkNewlines = $active;
+ return $this;
+ }
+
public function setMaxLineLength($new_length) {
$this->maxLineLength = $new_length;
return $this;
@@ -54,6 +67,9 @@
case 'text.max-line-length':
$this->setMaxLineLength($value);
return;
+ case 'text.check-newlines':
+ $this->setCheckNewlines($value);
+ return;
}
return parent::setLinterConfigurationValue($key, $value);
@@ -123,6 +139,10 @@
}
protected function lintNewlines($path) {
+ if (!$this->checkNewlines) {
+ return;
+ }
+
$data = $this->getData($path);
$pos = strpos($this->getData($path), "\r");
@@ -187,7 +207,7 @@
$data = $this->getData($path);
$matches = null;
- $bad = '[^\x09\x0A\x20-\x7E]';
+ $bad = '[^\x09\x0A\x0D\x20-\x7E]';
$preg = preg_match_all(
"/{$bad}(.*{$bad})?/",
$data,
@@ -205,8 +225,8 @@
self::LINT_BAD_CHARSET,
pht(
'Source code should contain only ASCII bytes with ordinal '.
- 'decimal values between 32 and 126 inclusive, plus linefeed. '.
- 'Do not use UTF-8 or other multibyte charsets.'),
+ 'decimal values between 32 and 126 inclusive, plus carriage return '.
+ 'and linefeed. Do not use UTF-8 or other multibyte charsets.'),
$string);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 7, 6:07 AM (1 d, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722024
Default Alt Text
D10980.diff (2 KB)

Event Timeline