1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-10 06:41:04 +01:00
phorge-arcanist/src/lint/linter/ArcanistJSONLinter.php
Joshua Spence fa37d3135f 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
2015-01-12 06:40:40 +11:00

50 lines
961 B
PHP

<?php
/**
* A linter for JSON files.
*/
final class ArcanistJSONLinter extends ArcanistLinter {
const LINT_PARSE_ERROR = 1;
public function getInfoName() {
return 'JSON Lint';
}
public function getInfoDescription() {
return pht('Detect syntax errors in JSON files.');
}
public function getLinterName() {
return 'JSON';
}
public function getLinterConfigurationName() {
return 'json';
}
public function getLintNameMap() {
return array(
self::LINT_PARSE_ERROR => pht('Parse Error'),
);
}
protected function canCustomizeLintSeverities() {
return false;
}
public function lintPath($path) {
$data = $this->getData($path);
try {
id(new PhutilJSONParser())->parse($data);
} catch (PhutilJSONParserException $ex) {
$this->raiseLintAtLine(
$ex->getSourceLine(),
$ex->getSourceChar(),
self::LINT_PARSE_ERROR,
$ex->getMessage());
}
}
}