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

« back to all changes in this revision

Viewing changes to src/lint/engine/ComprehensiveLintEngine.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
 * Basic lint engine which just applies several linters based on the file types.
 
5
 */
 
6
final class ComprehensiveLintEngine extends ArcanistLintEngine {
 
7
 
 
8
  public function buildLinters() {
 
9
    $linters = array();
 
10
 
 
11
    $paths = $this->getPaths();
 
12
 
 
13
    foreach ($paths as $key => $path) {
 
14
      if (preg_match('@^externals/@', $path)) {
 
15
        // Third-party stuff lives in /externals/; don't run lint engines
 
16
        // against it.
 
17
        unset($paths[$key]);
 
18
      }
 
19
    }
 
20
 
 
21
    $text_paths = preg_grep('/\.(php|css|hpp|cpp|l|y|py|pl)$/', $paths);
 
22
    $linters[] = id(new ArcanistGeneratedLinter())->setPaths($text_paths);
 
23
    $linters[] = id(new ArcanistNoLintLinter())->setPaths($text_paths);
 
24
    $linters[] = id(new ArcanistTextLinter())->setPaths($text_paths);
 
25
 
 
26
    $linters[] = id(new ArcanistFilenameLinter())->setPaths($paths);
 
27
 
 
28
    $linters[] = id(new ArcanistXHPASTLinter())
 
29
      ->setPaths(preg_grep('/\.php$/', $paths));
 
30
 
 
31
    $py_paths = preg_grep('/\.py$/', $paths);
 
32
    $linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths);
 
33
    $linters[] = id(new ArcanistPEP8Linter())
 
34
      ->setFlags($this->getPEP8WithTextOptions())
 
35
      ->setPaths($py_paths);
 
36
 
 
37
    $linters[] = id(new ArcanistRubyLinter())
 
38
      ->setPaths(preg_grep('/\.rb$/', $paths));
 
39
 
 
40
    $linters[] = id(new ArcanistJSHintLinter())
 
41
      ->setPaths(preg_grep('/\.js$/', $paths));
 
42
 
 
43
    return $linters;
 
44
  }
 
45
 
 
46
  protected function getPEP8WithTextOptions() {
 
47
    // E101 is subset of TXT2 (Tab Literal).
 
48
    // E501 is same as TXT3 (Line Too Long).
 
49
    // W291 is same as TXT6 (Trailing Whitespace).
 
50
    // W292 is same as TXT4 (File Does Not End in Newline).
 
51
    // W293 is same as TXT6 (Trailing Whitespace).
 
52
    return array('--ignore=E101,E501,W291,W292,W293');
 
53
  }
 
54
 
 
55
}