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

« back to all changes in this revision

Viewing changes to src/lint/linter/ArcanistGoLintLinter.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
final class ArcanistGoLintLinter extends ArcanistExternalLinter {
 
4
 
 
5
  public function getInfoName() {
 
6
    return 'Golint';
 
7
  }
 
8
 
 
9
  public function getInfoURI() {
 
10
    return 'https://github.com/golang/lint';
 
11
  }
 
12
 
 
13
  public function getInfoDescription() {
 
14
    return pht('Golint is a linter for Go source code.');
 
15
  }
 
16
 
 
17
  public function getLinterName() {
 
18
    return 'GOLINT';
 
19
  }
 
20
 
 
21
  public function getLinterConfigurationName() {
 
22
    return 'golint';
 
23
  }
 
24
 
 
25
  public function getDefaultBinary() {
 
26
    return 'golint';
 
27
  }
 
28
 
 
29
  public function getInstallInstructions() {
 
30
    return pht('Install Golint using `go get github.com/golang/lint/golint`.');
 
31
  }
 
32
 
 
33
  protected function canCustomizeLintSeverities() {
 
34
    return true;
 
35
  }
 
36
 
 
37
  protected function parseLinterOutput($path, $err, $stdout, $stderr) {
 
38
    $lines = phutil_split_lines($stdout, false);
 
39
 
 
40
    $messages = array();
 
41
    foreach ($lines as $line) {
 
42
      $matches = explode(':', $line, 4);
 
43
 
 
44
      if (count($matches) === 4) {
 
45
        $message = new ArcanistLintMessage();
 
46
        $message->setPath($path);
 
47
        $message->setLine($matches[1]);
 
48
        $message->setChar($matches[2]);
 
49
        $message->setCode($this->getLinterName());
 
50
        $message->setDescription(ucfirst(trim($matches[3])));
 
51
        $message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE);
 
52
 
 
53
        $messages[] = $message;
 
54
      }
 
55
    }
 
56
 
 
57
    return $messages;
 
58
  }
 
59
 
 
60
}