mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Improve parsing of csslint
output
Summary: `csslint` returns an `evidence` field which contains the line of the "original text" which produced the linter message (see 5dd84b259b/src/core/Reporter.js (L64)
). We can use this data instead of trying to achieve the same result using `$this->getData($path)`.
Test Plan: {F265449}
Reviewers: chad, #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D11311
This commit is contained in:
parent
7b383632dd
commit
e4149e43cd
2 changed files with 24 additions and 14 deletions
|
@ -75,25 +75,29 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
|||
|
||||
foreach ($files as $file) {
|
||||
foreach ($file->childNodes as $child) {
|
||||
$data = $this->getData($path);
|
||||
$lines = explode("\n", $data);
|
||||
$name = $child->getAttribute('reason');
|
||||
$severity = ($child->getAttribute('severity') == 'warning')
|
||||
? ArcanistLintSeverity::SEVERITY_WARNING
|
||||
: ArcanistLintSeverity::SEVERITY_ERROR;
|
||||
|
||||
$message = id(new ArcanistLintMessage())
|
||||
->setPath($path)
|
||||
->setLine($child->getAttribute('line'))
|
||||
->setChar($child->getAttribute('char'))
|
||||
->setCode('CSSLint')
|
||||
->setSeverity($severity)
|
||||
->setDescription($child->getAttribute('reason'));
|
||||
->setCode($this->getLinterName())
|
||||
->setDescription($child->getAttribute('reason'))
|
||||
->setOriginalText(
|
||||
substr(
|
||||
$child->getAttribute('evidence'),
|
||||
$child->getAttribute('char') - 1));
|
||||
|
||||
if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
|
||||
$line = $lines[$child->getAttribute('line') - 1];
|
||||
$text = substr($line, $child->getAttribute('char') - 1);
|
||||
$message->setOriginalText($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;
|
||||
|
|
6
src/lint/linter/__tests__/csslint/parse-error.lint-test
Normal file
6
src/lint/linter/__tests__/csslint/parse-error.lint-test
Normal file
|
@ -0,0 +1,6 @@
|
|||
li {
|
||||
float: left;
|
||||
float left;
|
||||
}
|
||||
~~~~~~~~~~
|
||||
error:3:9
|
Loading…
Reference in a new issue