mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Made some additional methods of ArcanistLintEngine
final
Summary: To me, it seems that these methods should not be overridden by subclasses Test Plan: `arc lint` and `arc unit` Reviewers: epriestley Reviewed By: epriestley Subscribers: LegNeato, aran, epriestley, Korvin Differential Revision: https://secure.phabricator.com/D7960
This commit is contained in:
parent
a67b848f44
commit
606380f4bd
1 changed files with 34 additions and 32 deletions
|
@ -71,26 +71,27 @@ abstract class ArcanistLintEngine {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setConfigurationManager(
|
final public function setConfigurationManager(
|
||||||
ArcanistConfigurationManager $configuration_manager) {
|
ArcanistConfigurationManager $configuration_manager) {
|
||||||
$this->configurationManager = $configuration_manager;
|
$this->configurationManager = $configuration_manager;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfigurationManager() {
|
final public function getConfigurationManager() {
|
||||||
return $this->configurationManager;
|
return $this->configurationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWorkingCopy(ArcanistWorkingCopyIdentity $working_copy) {
|
final public function setWorkingCopy(
|
||||||
|
ArcanistWorkingCopyIdentity $working_copy) {
|
||||||
$this->workingCopy = $working_copy;
|
$this->workingCopy = $working_copy;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWorkingCopy() {
|
final public function getWorkingCopy() {
|
||||||
return $this->workingCopy;
|
return $this->workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPaths($paths) {
|
final public function setPaths($paths) {
|
||||||
$this->paths = $paths;
|
$this->paths = $paths;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +100,7 @@ abstract class ArcanistLintEngine {
|
||||||
return $this->paths;
|
return $this->paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPathChangedLines($path, $changed) {
|
final public function setPathChangedLines($path, $changed) {
|
||||||
if ($changed === null) {
|
if ($changed === null) {
|
||||||
$this->changedLines[$path] = null;
|
$this->changedLines[$path] = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,39 +109,39 @@ abstract class ArcanistLintEngine {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPathChangedLines($path) {
|
final public function getPathChangedLines($path) {
|
||||||
return idx($this->changedLines, $path);
|
return idx($this->changedLines, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFileData($data) {
|
final public function setFileData($data) {
|
||||||
$this->fileData = $data + $this->fileData;
|
$this->fileData = $data + $this->fileData;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCommitHookMode($mode) {
|
final public function setCommitHookMode($mode) {
|
||||||
$this->commitHookMode = $mode;
|
$this->commitHookMode = $mode;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHookAPI(ArcanistHookAPI $hook_api) {
|
final public function setHookAPI(ArcanistHookAPI $hook_api) {
|
||||||
$this->hookAPI = $hook_api;
|
$this->hookAPI = $hook_api;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHookAPI() {
|
final public function getHookAPI() {
|
||||||
return $this->hookAPI;
|
return $this->hookAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEnableAsyncLint($enable_async_lint) {
|
final public function setEnableAsyncLint($enable_async_lint) {
|
||||||
$this->enableAsyncLint = $enable_async_lint;
|
$this->enableAsyncLint = $enable_async_lint;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEnableAsyncLint() {
|
final public function getEnableAsyncLint() {
|
||||||
return $this->enableAsyncLint;
|
return $this->enableAsyncLint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadData($path) {
|
final public function loadData($path) {
|
||||||
if (!isset($this->fileData[$path])) {
|
if (!isset($this->fileData[$path])) {
|
||||||
if ($this->getCommitHookMode()) {
|
if ($this->getCommitHookMode()) {
|
||||||
$this->fileData[$path] = $this->getHookAPI()
|
$this->fileData[$path] = $this->getHookAPI()
|
||||||
|
@ -163,7 +164,7 @@ abstract class ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDirectory($path) {
|
final public function isDirectory($path) {
|
||||||
if ($this->getCommitHookMode()) {
|
if ($this->getCommitHookMode()) {
|
||||||
// TODO: This won't get the right result in every case (we need more
|
// TODO: This won't get the right result in every case (we need more
|
||||||
// metadata) but should almost always be correct.
|
// metadata) but should almost always be correct.
|
||||||
|
@ -179,7 +180,7 @@ abstract class ArcanistLintEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBinaryFile($path) {
|
final public function isBinaryFile($path) {
|
||||||
try {
|
try {
|
||||||
$data = $this->loadData($path);
|
$data = $this->loadData($path);
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
@ -189,22 +190,22 @@ abstract class ArcanistLintEngine {
|
||||||
return ArcanistDiffUtils::isHeuristicBinaryFile($data);
|
return ArcanistDiffUtils::isHeuristicBinaryFile($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilePathOnDisk($path) {
|
final public function getFilePathOnDisk($path) {
|
||||||
return Filesystem::resolvePath(
|
return Filesystem::resolvePath(
|
||||||
$path,
|
$path,
|
||||||
$this->getWorkingCopy()->getProjectRoot());
|
$this->getWorkingCopy()->getProjectRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMinimumSeverity($severity) {
|
final public function setMinimumSeverity($severity) {
|
||||||
$this->minimumSeverity = $severity;
|
$this->minimumSeverity = $severity;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommitHookMode() {
|
final public function getCommitHookMode() {
|
||||||
return $this->commitHookMode;
|
return $this->commitHookMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
final public function run() {
|
||||||
$linters = $this->buildLinters();
|
$linters = $this->buildLinters();
|
||||||
if (!$linters) {
|
if (!$linters) {
|
||||||
throw new ArcanistNoEffectException("No linters to run.");
|
throw new ArcanistNoEffectException("No linters to run.");
|
||||||
|
@ -375,12 +376,13 @@ abstract class ArcanistLintEngine {
|
||||||
return $this->results;
|
return $this->results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeverityEnabled($severity) {
|
final public function isSeverityEnabled($severity) {
|
||||||
$minimum = $this->minimumSeverity;
|
$minimum = $this->minimumSeverity;
|
||||||
return ArcanistLintSeverity::isAtLeastAsSevere($severity, $minimum);
|
return ArcanistLintSeverity::isAtLeastAsSevere($severity, $minimum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shouldUseCache($cache_granularity, $repository_version) {
|
final private function shouldUseCache($cache_granularity,
|
||||||
|
$repository_version) {
|
||||||
if ($this->commitHookMode) {
|
if ($this->commitHookMode) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -399,22 +401,22 @@ abstract class ArcanistLintEngine {
|
||||||
* @param dict<string path, dict<string version, list<dict message>>>
|
* @param dict<string path, dict<string version, list<dict message>>>
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public function setCachedResults(array $results) {
|
final public function setCachedResults(array $results) {
|
||||||
$this->cachedResults = $results;
|
$this->cachedResults = $results;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResults() {
|
final public function getResults() {
|
||||||
return $this->results;
|
return $this->results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStoppedPaths() {
|
final public function getStoppedPaths() {
|
||||||
return $this->stopped;
|
return $this->stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function buildLinters();
|
abstract protected function buildLinters();
|
||||||
|
|
||||||
protected function didRunLinters(array $linters) {
|
final protected function didRunLinters(array $linters) {
|
||||||
assert_instances_of($linters, 'ArcanistLinter');
|
assert_instances_of($linters, 'ArcanistLinter');
|
||||||
|
|
||||||
$exceptions = array();
|
$exceptions = array();
|
||||||
|
@ -441,12 +443,12 @@ abstract class ArcanistLintEngine {
|
||||||
return $exceptions;
|
return $exceptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRepositoryVersion($version) {
|
final public function setRepositoryVersion($version) {
|
||||||
$this->repositoryVersion = $version;
|
$this->repositoryVersion = $version;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isRelevantMessage(ArcanistLintMessage $message) {
|
final private function isRelevantMessage(ArcanistLintMessage $message) {
|
||||||
// When a user runs "arc lint", we default to raising only warnings on
|
// When a user runs "arc lint", we default to raising only warnings on
|
||||||
// lines they have changed (errors are still raised anywhere in the
|
// lines they have changed (errors are still raised anywhere in the
|
||||||
// file). The list of $changed lines may be null, to indicate that the
|
// file). The list of $changed lines may be null, to indicate that the
|
||||||
|
@ -490,7 +492,7 @@ abstract class ArcanistLintEngine {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getResultForPath($path) {
|
final protected function getResultForPath($path) {
|
||||||
if (empty($this->results[$path])) {
|
if (empty($this->results[$path])) {
|
||||||
$result = new ArcanistLintResult();
|
$result = new ArcanistLintResult();
|
||||||
$result->setPath($path);
|
$result->setPath($path);
|
||||||
|
@ -500,7 +502,7 @@ abstract class ArcanistLintEngine {
|
||||||
return $this->results[$path];
|
return $this->results[$path];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLineAndCharFromOffset($path, $offset) {
|
final public function getLineAndCharFromOffset($path, $offset) {
|
||||||
if (!isset($this->charToLine[$path])) {
|
if (!isset($this->charToLine[$path])) {
|
||||||
$char_to_line = array();
|
$char_to_line = array();
|
||||||
$line_to_first_char = array();
|
$line_to_first_char = array();
|
||||||
|
@ -527,11 +529,11 @@ abstract class ArcanistLintEngine {
|
||||||
return array($line, $char);
|
return array($line, $char);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostponedLinters() {
|
final public function getPostponedLinters() {
|
||||||
return $this->postponedLinters;
|
return $this->postponedLinters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPostponedLinters(array $linters) {
|
final public function setPostponedLinters(array $linters) {
|
||||||
$this->postponedLinters = $linters;
|
$this->postponedLinters = $linters;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue