mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 14:52:40 +01:00
Minor improvements to ArcanistJSONLinter
Summary: Self-explanatory. Test Plan: `arc unit` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11324
This commit is contained in:
parent
4e38fac47d
commit
fa37d3135f
1 changed files with 14 additions and 3 deletions
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
final class ArcanistJSONLinter extends ArcanistLinter {
|
final class ArcanistJSONLinter extends ArcanistLinter {
|
||||||
|
|
||||||
|
const LINT_PARSE_ERROR = 1;
|
||||||
|
|
||||||
public function getInfoName() {
|
public function getInfoName() {
|
||||||
return 'JSON Lint';
|
return 'JSON Lint';
|
||||||
}
|
}
|
||||||
|
@ -21,17 +23,26 @@ final class ArcanistJSONLinter extends ArcanistLinter {
|
||||||
return 'json';
|
return 'json';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLintNameMap() {
|
||||||
|
return array(
|
||||||
|
self::LINT_PARSE_ERROR => pht('Parse Error'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function canCustomizeLintSeverities() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function lintPath($path) {
|
public function lintPath($path) {
|
||||||
$data = $this->getData($path);
|
$data = $this->getData($path);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$parser = new PhutilJSONParser();
|
id(new PhutilJSONParser())->parse($data);
|
||||||
$parser->parse($data);
|
|
||||||
} catch (PhutilJSONParserException $ex) {
|
} catch (PhutilJSONParserException $ex) {
|
||||||
$this->raiseLintAtLine(
|
$this->raiseLintAtLine(
|
||||||
$ex->getSourceLine(),
|
$ex->getSourceLine(),
|
||||||
$ex->getSourceChar(),
|
$ex->getSourceChar(),
|
||||||
$this->getLinterName(),
|
self::LINT_PARSE_ERROR,
|
||||||
$ex->getMessage());
|
$ex->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue