mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +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 ($files as $file) {
|
||||||
foreach ($file->childNodes as $child) {
|
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())
|
$message = id(new ArcanistLintMessage())
|
||||||
->setPath($path)
|
->setPath($path)
|
||||||
->setLine($child->getAttribute('line'))
|
->setLine($child->getAttribute('line'))
|
||||||
->setChar($child->getAttribute('char'))
|
->setChar($child->getAttribute('char'))
|
||||||
->setCode('CSSLint')
|
->setCode($this->getLinterName())
|
||||||
->setSeverity($severity)
|
->setDescription($child->getAttribute('reason'))
|
||||||
->setDescription($child->getAttribute('reason'));
|
->setOriginalText(
|
||||||
|
substr(
|
||||||
|
$child->getAttribute('evidence'),
|
||||||
|
$child->getAttribute('char') - 1));
|
||||||
|
|
||||||
if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
|
switch ($child->getAttribute('severity')) {
|
||||||
$line = $lines[$child->getAttribute('line') - 1];
|
case 'error':
|
||||||
$text = substr($line, $child->getAttribute('char') - 1);
|
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
|
||||||
$message->setOriginalText($text);
|
break;
|
||||||
|
|
||||||
|
case 'warning':
|
||||||
|
$message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages[] = $message;
|
$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