Page MenuHomePhabricator

abstract class ArcanistLintEngine
Arcanist Technical Documentation (Lint)

Manages lint execution. When you run 'arc lint' or 'arc diff', Arcanist attempts to run lint rules using a lint engine.

Lint engines are high-level strategic classes which do not contain any actual linting rules. Linting rules live in Linter classes. The lint engine builds and configures linters.

Most modern linters can be configured with an .arclint file, which is managed by the builtin ArcanistConfigurationDrivenLintEngine. Consult the documentation for more information on these files.

In the majority of cases, you do not need to write a custom lint engine. For example, to add new rules for a new language, write a linter instead. However, if you have a very advanced or specialized use case, you can write a custom lint engine by extending this class; custom lint engines are more powerful but much more complex than the builtin engines.

The lint engine is given a list of paths (generally, the paths that you modified in your change) and determines which linters to run on them. The linters themselves are responsible for actually analyzing file text and finding warnings and errors. For example, if the modified paths include some JS files and some Python files, you might want to run JSLint on the JS files and PyLint on the Python files.

You can also run multiple linters on a single file. For instance, you might run one linter on all text files to make sure they don't have trailing whitespace, or enforce tab vs space rules, or make sure there are enough curse words in them.

You can test an engine like this:

arc lint --engine YourLintEngineClassName --lintall some_file.py

...which will show you all the lint issues raised in the file.

See Arcanist User Guide: Customizing Lint, Unit Tests and Workflows for more information about configuring lint engines.

Methods

public function __construct()

This method is not documented.
Return
this//Implicit.//

final public function setConfigurationManager($configuration_manager)

This method is not documented.
Parameters
ArcanistConfigurationManager$configuration_manager
Return
wild

final public function getConfigurationManager()

This method is not documented.
Return
wild

final public function setWorkingCopy($working_copy)

This method is not documented.
Parameters
ArcanistWorkingCopyIdentity$working_copy
Return
wild

final public function getWorkingCopy()

This method is not documented.
Return
wild

final public function setPaths($paths)

This method is not documented.
Parameters
$paths
Return
wild

public function getPaths()

This method is not documented.
Return
wild

final public function setPathChangedLines($path, $changed)

This method is not documented.
Parameters
$path
$changed
Return
wild

final public function getPathChangedLines($path)

This method is not documented.
Parameters
$path
Return
wild

final public function setFileData($data)

This method is not documented.
Parameters
$data
Return
wild

final public function loadData($path)

This method is not documented.
Parameters
$path
Return
wild

public function pathExists($path)

This method is not documented.
Parameters
$path
Return
wild

final public function isDirectory($path)

This method is not documented.
Parameters
$path
Return
wild

final public function isBinaryFile($path)

This method is not documented.
Parameters
$path
Return
wild

final public function isSymbolicLink($path)

This method is not documented.
Parameters
$path
Return
wild

final public function getFilePathOnDisk($path)

This method is not documented.
Parameters
$path
Return
wild

final public function setMinimumSeverity($severity)

This method is not documented.
Parameters
$severity
Return
wild

final public function run()

This method is not documented.
Return
wild

final public function isSeverityEnabled($severity)

This method is not documented.
Parameters
$severity
Return
wild

private function shouldUseCache($cache_granularity, $repository_version)

This method is not documented.
Parameters
$cache_granularity
$repository_version
Return
wild

final public function setCachedResults($results)

This method is not documented.
Parameters
dict<string$resultspath, dict<string version, list<dict message>>>
Return
this

final public function getResults()

This method is not documented.
Return
wild

final public function getStoppedPaths()

This method is not documented.
Return
wild

abstract public function buildLinters()

This method is not documented.
Return
wild

final public function setRepositoryVersion($version)

This method is not documented.
Parameters
$version
Return
wild

private function isRelevantMessage($message)

This method is not documented.
Parameters
ArcanistLintMessage$message
Return
wild

final protected function getResultForPath($path)

This method is not documented.
Parameters
$path
Return
wild

final public function getLineAndCharFromOffset($path, $offset)

This method is not documented.
Parameters
$path
$offset
Return
wild

protected function getCacheVersion()

This method is not documented.
Return
wild

public function getLinterResource($key, $default)

Get a named linter resource shared by another linter.

This mechanism allows linters to share arbitrary resources, like the results of computation. If several linters need to perform the same expensive computation step, they can use a named resource to synchronize construction of the result so it doesn't need to be built multiple times.

Parameters
string$keyResource identifier.
wild$defaultOptionally, default value to return if resource does not exist.
Return
wildResource, or default value if not present.

public function setLinterResource($key, $value)

Set a linter resource that other linters can access.

See getLinterResource() for a description of this mechanism.

Parameters
string$keyResource identifier.
wild$valueResource.
Return
this

private function getRunnableLinters($linters)

This method is not documented.
Parameters
array$linters
Return
wild

private function executeLinters($runnable)

This method is not documented.
Parameters
array$runnable
Return
wild

private function executeLintersOnChunk($runnable, $path_list)

This method is not documented.
Parameters
array$runnable
array$path_list
Return
wild

private function beginLintServiceCall($linter, $paths)

This method is not documented.
Parameters
ArcanistLinter$linter
array$paths
Return
wild

private function endLintServiceCall($call_id)

This method is not documented.
Parameters
$call_id
Return
wild

private function executeLinterOnPaths($linter, $paths)

This method is not documented.
Parameters
ArcanistLinter$linter
array$paths
Return
wild

private function executeDidLintOnPaths($linter, $paths)

This method is not documented.
Parameters
ArcanistLinter$linter
array$paths
Return
wild

private function validateLintMessage($linter, $message)

This method is not documented.
Parameters
ArcanistLinter$linter
ArcanistLintMessage$message
Return
wild