mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42:40 +01:00
Minor tidying of ArcanistCSSLintLinter
Summary: Minor tidying. Test Plan: Eyeball it. Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11307
This commit is contained in:
parent
1b3d600098
commit
7b383632dd
1 changed files with 18 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses "CSS Lint" to detect checkstyle errors in css code.
|
* Uses "CSS Lint" to detect checkstyle errors in CSS code.
|
||||||
*/
|
*/
|
||||||
final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInfoDescription() {
|
public function getInfoDescription() {
|
||||||
return pht('Use `csslint` to detect issues with CSS source files.');
|
return pht(
|
||||||
|
'Use `%s` to detect issues with CSS source files.',
|
||||||
|
'csslint');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLinterName() {
|
public function getLinterName() {
|
||||||
|
@ -51,7 +53,9 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInstallInstructions() {
|
public function getInstallInstructions() {
|
||||||
return pht('Install CSSLint using `npm install -g csslint`.');
|
return pht(
|
||||||
|
'Install %s using `%s`.', 'CSSLint',
|
||||||
|
'npm install -g csslint');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldExpectCommandErrors() {
|
public function shouldExpectCommandErrors() {
|
||||||
|
@ -68,12 +72,9 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
||||||
|
|
||||||
$files = $report_dom->getElementsByTagName('file');
|
$files = $report_dom->getElementsByTagName('file');
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
foreach ($file->childNodes as $child) {
|
foreach ($file->childNodes as $child) {
|
||||||
if (!($child instanceof DOMElement)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $this->getData($path);
|
$data = $this->getData($path);
|
||||||
$lines = explode("\n", $data);
|
$lines = explode("\n", $data);
|
||||||
$name = $child->getAttribute('reason');
|
$name = $child->getAttribute('reason');
|
||||||
|
@ -81,13 +82,13 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
||||||
? ArcanistLintSeverity::SEVERITY_WARNING
|
? ArcanistLintSeverity::SEVERITY_WARNING
|
||||||
: ArcanistLintSeverity::SEVERITY_ERROR;
|
: ArcanistLintSeverity::SEVERITY_ERROR;
|
||||||
|
|
||||||
$message = new ArcanistLintMessage();
|
$message = id(new ArcanistLintMessage())
|
||||||
$message->setPath($path);
|
->setPath($path)
|
||||||
$message->setLine($child->getAttribute('line'));
|
->setLine($child->getAttribute('line'))
|
||||||
$message->setChar($child->getAttribute('char'));
|
->setChar($child->getAttribute('char'))
|
||||||
$message->setCode('CSSLint');
|
->setCode('CSSLint')
|
||||||
$message->setDescription($child->getAttribute('reason'));
|
->setSeverity($severity)
|
||||||
$message->setSeverity($severity);
|
->setDescription($child->getAttribute('reason'));
|
||||||
|
|
||||||
if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
|
if ($child->hasAttribute('line') && $child->getAttribute('line') > 0) {
|
||||||
$line = $lines[$child->getAttribute('line') - 1];
|
$line = $lines[$child->getAttribute('line') - 1];
|
||||||
|
@ -103,18 +104,16 @@ final class ArcanistCSSLintLinter extends ArcanistExternalLinter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getLintCodeFromLinterConfigurationKey($code) {
|
protected function getLintCodeFromLinterConfigurationKey($code) {
|
||||||
|
|
||||||
// NOTE: We can't figure out which rule generated each message, so we
|
// 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
|
// can not customize severities. I opened a pull request to add this
|
||||||
// ability; see:
|
// ability; see:
|
||||||
//
|
//
|
||||||
// https://github.com/stubbornella/csslint/pull/409
|
// https://github.com/stubbornella/csslint/pull/409
|
||||||
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
pht(
|
pht(
|
||||||
"CSSLint does not currently support custom severity levels, because ".
|
"%s does not currently support custom severity levels, because ".
|
||||||
"rules can't be identified from messages in output. ".
|
"rules can't be identified from messages in output.",
|
||||||
"See Pull Request #409."));
|
'CSSLint'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue