~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to src/lint/linter/ArcanistJSONLinter.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-11-01 23:20:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141101232006-mvlnp0cil67tsboe
Tags: upstream-0~git20141101/arcanist
Import upstream version 0~git20141101, component arcanist

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * A linter for JSON files.
 
5
 */
 
6
final class ArcanistJSONLinter extends ArcanistLinter {
 
7
 
 
8
  public function getInfoName() {
 
9
    return 'JSON Lint';
 
10
  }
 
11
 
 
12
  public function getInfoDescription() {
 
13
    return pht('Detect syntax errors in JSON files.');
 
14
  }
 
15
 
 
16
  public function getLinterName() {
 
17
    return 'JSON';
 
18
  }
 
19
 
 
20
  public function getLinterConfigurationName() {
 
21
    return 'json';
 
22
  }
 
23
 
 
24
  public function lintPath($path) {
 
25
    $data = $this->getData($path);
 
26
 
 
27
    try {
 
28
      $parser = new PhutilJSONParser();
 
29
      $parser->parse($data);
 
30
    } catch (PhutilJSONParserException $ex) {
 
31
      $this->raiseLintAtLine(
 
32
        $ex->getSourceLine(),
 
33
        $ex->getSourceChar(),
 
34
        $this->getLinterName(),
 
35
        $ex->getMessage());
 
36
    }
 
37
  }
 
38
 
 
39
}