2012-01-17 12:17:51 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic lint engine which just applies several linters based on the file types
|
|
|
|
*
|
|
|
|
* @group linter
|
|
|
|
*/
|
2012-01-31 12:07:05 -08:00
|
|
|
final class ComprehensiveLintEngine extends ArcanistLintEngine {
|
2012-01-17 12:17:51 -08:00
|
|
|
|
|
|
|
public function buildLinters() {
|
|
|
|
$linters = array();
|
|
|
|
|
|
|
|
$paths = $this->getPaths();
|
|
|
|
|
|
|
|
foreach ($paths as $key => $path) {
|
|
|
|
if (!$this->pathExists($path)) {
|
|
|
|
unset($paths[$key]);
|
|
|
|
}
|
|
|
|
if (preg_match('@^externals/@', $path)) {
|
|
|
|
// Third-party stuff lives in /externals/; don't run lint engines
|
|
|
|
// against it.
|
|
|
|
unset($paths[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-09 15:06:55 -07:00
|
|
|
$text_paths = preg_grep('/\.(php|css|hpp|cpp|l|y|py|pl)$/', $paths);
|
2012-10-20 05:45:22 -07:00
|
|
|
$linters[] = id(new ArcanistGeneratedLinter())->setPaths($text_paths);
|
|
|
|
$linters[] = id(new ArcanistNoLintLinter())->setPaths($text_paths);
|
|
|
|
$linters[] = id(new ArcanistTextLinter())->setPaths($text_paths);
|
2012-01-17 12:17:51 -08:00
|
|
|
|
2012-10-20 05:45:22 -07:00
|
|
|
$linters[] = id(new ArcanistFilenameLinter())->setPaths($paths);
|
2012-01-17 12:17:51 -08:00
|
|
|
|
2012-10-20 05:45:22 -07:00
|
|
|
$linters[] = id(new ArcanistXHPASTLinter())
|
|
|
|
->setPaths(preg_grep('/\.php$/', $paths));
|
2012-01-17 12:17:51 -08:00
|
|
|
|
2012-10-20 05:45:22 -07:00
|
|
|
$py_paths = preg_grep('/\.py$/', $paths);
|
|
|
|
$linters[] = id(new ArcanistPyFlakesLinter())->setPaths($py_paths);
|
2012-11-03 14:47:38 -07:00
|
|
|
$linters[] = id(new ArcanistPEP8Linter())
|
|
|
|
->setConfig(array('options' => $this->getPEP8WithTextOptions()))
|
|
|
|
->setPaths($py_paths);
|
2012-01-17 12:17:51 -08:00
|
|
|
|
2012-10-20 05:45:22 -07:00
|
|
|
$linters[] = id(new ArcanistRubyLinter())
|
|
|
|
->setPaths(preg_grep('/\.rb$/', $paths));
|
2012-01-17 12:17:51 -08:00
|
|
|
|
2012-12-03 08:13:45 -08:00
|
|
|
$linters[] = id(new ArcanistScalaSBTLinter())
|
|
|
|
->setPaths(preg_grep('/\.scala$/', $paths));
|
|
|
|
|
2012-10-20 05:45:22 -07:00
|
|
|
$linters[] = id(new ArcanistJSHintLinter())
|
|
|
|
->setPaths(preg_grep('/\.js$/', $paths));
|
2012-01-17 12:17:51 -08:00
|
|
|
|
|
|
|
return $linters;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|