Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9582574
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/lint/linter/ArcanistCSSLintLinter.php b/src/lint/linter/ArcanistCSSLintLinter.php
index a7583959..e8fd3546 100644
--- a/src/lint/linter/ArcanistCSSLintLinter.php
+++ b/src/lint/linter/ArcanistCSSLintLinter.php
@@ -1,116 +1,127 @@
<?php
/**
* Uses "CSS Lint" to detect checkstyle errors in CSS code.
*/
final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
public function getInfoName() {
return 'CSSLint';
}
public function getInfoURI() {
return 'http://csslint.net';
}
public function getInfoDescription() {
return pht(
'Use `%s` to detect issues with CSS source files.',
'csslint');
}
public function getLinterName() {
return 'CSSLint';
}
public function getLinterConfigurationName() {
return 'csslint';
}
protected function getMandatoryFlags() {
return array(
'--format=lint-xml',
);
}
public function getDefaultBinary() {
return 'csslint';
}
public function getVersion() {
list($stdout) = execx('%C --version', $this->getExecutableCommand());
$matches = array();
if (preg_match('/^v(?P<version>\d+\.\d+\.\d+)$/', $stdout, $matches)) {
return $matches['version'];
} else {
return false;
}
}
public function getInstallInstructions() {
return pht(
'Install %s using `%s`.', 'CSSLint',
'npm install -g csslint');
}
protected function parseLinterOutput($path, $err, $stdout, $stderr) {
$report_dom = new DOMDocument();
$ok = @$report_dom->loadXML($stdout);
if (!$ok) {
return false;
}
$files = $report_dom->getElementsByTagName('file');
$messages = array();
foreach ($files as $file) {
foreach ($file->childNodes as $child) {
+ $line = $child->getAttribute('line');
+ $char = $child->getAttribute('char');
+ $original_text = $child->getAttribute('evidence');
+
+ if ($line === '') {
+ $line = null;
+ }
+
+ if ($char === '') {
+ $char = null;
+ } else {
+ $original_text = substr($original_text, $char - 1);
+ }
+
$message = id(new ArcanistLintMessage())
->setPath($path)
- ->setLine($child->getAttribute('line'))
- ->setChar($child->getAttribute('char'))
+ ->setLine($line)
+ ->setChar($char)
->setCode($this->getLinterName())
->setName($this->getLinterName())
->setDescription($child->getAttribute('reason'))
- ->setOriginalText(
- substr(
- $child->getAttribute('evidence'),
- $child->getAttribute('char') - 1));
+ ->setOriginalText($original_text);
switch ($child->getAttribute('severity')) {
case 'error':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
case 'warning':
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
break;
default:
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
break;
}
$messages[] = $message;
}
}
return $messages;
}
protected function getLintCodeFromLinterConfigurationKey($code) {
// NOTE: We can't figure out which rule generated each message, so we
// can not customize severities. I opened a pull request to add this
// ability; see:
//
// https://github.com/stubbornella/csslint/pull/409
throw new Exception(
pht(
"%s does not currently support custom severity levels, because ".
"rules can't be identified from messages in output.",
'CSSLint'));
}
}
diff --git a/src/lint/linter/__tests__/csslint/no-line-related-issue.lint-test b/src/lint/linter/__tests__/csslint/no-line-related-issue.lint-test
new file mode 100644
index 00000000..409e2a05
--- /dev/null
+++ b/src/lint/linter/__tests__/csslint/no-line-related-issue.lint-test
@@ -0,0 +1,9 @@
+h1 {
+ font-weight: bold;
+}
+h1 {
+ font-weight: bold;
+}
+~~~~~~~~~~
+warning::
+warning:4:1
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Oct 11, 07:11 (12 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
983946
Default Alt Text
(4 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline
Log In to Comment