Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15282607
D7957.id18001.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D7957.id18001.diff
View Options
Index: .divinerconfig
===================================================================
--- .divinerconfig
+++ .divinerconfig
@@ -20,4 +20,3 @@
["DivinerXHPEngine", {}]
]
}
-
Index: bin/arc.bat
===================================================================
--- bin/arc.bat
+++ bin/arc.bat
@@ -1,3 +1,2 @@
@echo off
php -f "%~dp0..\scripts\arcanist.php" -- %*
-
Index: scripts/arcanist.php
===================================================================
--- scripts/arcanist.php
+++ scripts/arcanist.php
@@ -624,4 +624,3 @@
exit($err);
}
-
Index: src/lint/linter/ArcanistLicenseLinter.php
===================================================================
--- src/lint/linter/ArcanistLicenseLinter.php
+++ src/lint/linter/ArcanistLicenseLinter.php
@@ -57,5 +57,3 @@
}
}
}
-
-
Index: src/lint/linter/ArcanistTextLinter.php
===================================================================
--- src/lint/linter/ArcanistTextLinter.php
+++ src/lint/linter/ArcanistTextLinter.php
@@ -14,6 +14,8 @@
const LINT_BAD_CHARSET = 5;
const LINT_TRAILING_WHITESPACE = 6;
const LINT_NO_COMMIT = 7;
+ const LINT_BOF_WHITESPACE = 8;
+ const LINT_EOF_WHITESPACE = 9;
private $maxLineLength = 80;
@@ -38,6 +40,8 @@
return array(
self::LINT_LINE_WRAP => ArcanistLintSeverity::SEVERITY_WARNING,
self::LINT_TRAILING_WHITESPACE => ArcanistLintSeverity::SEVERITY_AUTOFIX,
+ self::LINT_BOF_WHITESPACE => ArcanistLintSeverity::SEVERITY_AUTOFIX,
+ self::LINT_EOF_WHITESPACE => ArcanistLintSeverity::SEVERITY_AUTOFIX,
);
}
@@ -50,6 +54,8 @@
self::LINT_BAD_CHARSET => pht('Bad Charset'),
self::LINT_TRAILING_WHITESPACE => pht('Trailing Whitespace'),
self::LINT_NO_COMMIT => pht('Explicit %s', '@no'.'commit'),
+ self::LINT_BOF_WHITESPACE => pht('Leading Whitespace at BOF'),
+ self::LINT_EOF_WHITESPACE => pht('Trailing Whitespace at EOF'),
);
}
@@ -77,6 +83,9 @@
$this->lintEOFNewline($path);
$this->lintTrailingWhitespace($path);
+ $this->lintBOFWhitespace($path);
+ $this->lintEOFWhitespace($path);
+
if ($this->getEngine()->getCommitHookMode()) {
$this->lintNoCommit($path);
}
@@ -194,6 +203,54 @@
}
}
+ protected function lintBOFWhitespace($path) {
+ $data = $this->getData($path);
+
+ $matches = null;
+ $preg = preg_match(
+ '/^\s*\n/',
+ $data,
+ $matches,
+ PREG_OFFSET_CAPTURE);
+
+ if (!$preg) {
+ return;
+ }
+
+ list($string, $offset) = $matches[0];
+ $this->raiseLintAtOffset(
+ $offset,
+ self::LINT_BOF_WHITESPACE,
+ 'This file contains leading whitespace at the beginning of the file. ' .
+ 'This is unnecessary and should be avoided when possible.',
+ $string,
+ '');
+ }
+
+ protected function lintEOFWhitespace($path) {
+ $data = $this->getData($path);
+
+ $matches = null;
+ $preg = preg_match(
+ '/(?<=\n)\s+$/',
+ $data,
+ $matches,
+ PREG_OFFSET_CAPTURE);
+
+ if (!$preg) {
+ return;
+ }
+
+ list($string, $offset) = $matches[0];
+ $this->raiseLintAtOffset(
+ $offset,
+ self::LINT_EOF_WHITESPACE,
+ 'This file contains trailing whitespace at the end of the file. This ' .
+ 'is unnecessary and should be avoided when possible.',
+ $string,
+ '');
+ }
+
private function lintNoCommit($path) {
$data = $this->getData($path);
@@ -210,5 +267,4 @@
}
}
-
}
Index: src/lint/linter/__tests__/text/bof-whitespace-1.lint-test
===================================================================
--- /dev/null
+++ src/lint/linter/__tests__/text/bof-whitespace-1.lint-test
@@ -0,0 +1,9 @@
+
+
+
+
+The quick brown fox jumps over the lazy dog.
+~~~~~~~~~~
+autofix:1:1
+~~~~~~~~~~
+The quick brown fox jumps over the lazy dog.
Index: src/lint/linter/__tests__/text/bof-whitespace-2.lint-test
===================================================================
--- /dev/null
+++ src/lint/linter/__tests__/text/bof-whitespace-2.lint-test
@@ -0,0 +1,2 @@
+ The quick brown fox jumps over the lazy dog.
+~~~~~~~~~~
Index: src/lint/linter/__tests__/text/eof-whitespace.lint-test
===================================================================
--- /dev/null
+++ src/lint/linter/__tests__/text/eof-whitespace.lint-test
@@ -0,0 +1,9 @@
+The quick brown fox jumps over the lazy dog.
+
+
+
+
+~~~~~~~~~~
+autofix:2:1
+~~~~~~~~~~
+The quick brown fox jumps over the lazy dog.
Index: src/unit/engine/CSharpToolsTestEngine.php
===================================================================
--- src/unit/engine/CSharpToolsTestEngine.php
+++ src/unit/engine/CSharpToolsTestEngine.php
@@ -284,5 +284,3 @@
return $reports;
}
}
-
-
Index: src/workflow/ArcanistBackoutWorkflow.php
===================================================================
--- src/workflow/ArcanistBackoutWorkflow.php
+++ src/workflow/ArcanistBackoutWorkflow.php
@@ -181,4 +181,3 @@
}
}
-
Index: src/workflow/ArcanistRevertWorkflow.php
===================================================================
--- src/workflow/ArcanistRevertWorkflow.php
+++ src/workflow/ArcanistRevertWorkflow.php
@@ -35,4 +35,3 @@
$console->writeOut("Please use arc backout instead.\n");
}
}
-
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 12:35 AM (5 d, 5 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223213
Default Alt Text
D7957.id18001.diff (5 KB)
Attached To
Mode
D7957: Added `ArcanistTextLinter::LINT_BOF_WHITESPACE` and `ArcanistTextLinter::LINT_EOF_WHITESPACE`
Attached
Detach File
Event Timeline
Log In to Comment