1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Made some additional methods of ArcanistLinter and ArcanistExternalLinter final

Summary: To me, it seems that these methods should never be overwritten in subclasses.

Test Plan: `arc unit`

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: aran, epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D7958
This commit is contained in:
Joshua Spence 2014-05-12 09:48:52 -07:00 committed by epriestley
parent 0583b39bb0
commit 9b05a025b7
5 changed files with 32 additions and 37 deletions

View file

@ -9,7 +9,7 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter {
private $trees = array();
private $exceptions = array();
protected final function raiseLintAtToken(
final protected function raiseLintAtToken(
XHPASTToken $token,
$code,
$desc,
@ -22,7 +22,7 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter {
$replace);
}
protected final function raiseLintAtNode(
final protected function raiseLintAtNode(
XHPASTNode $node,
$code,
$desc,

View file

@ -324,7 +324,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
* @return string Command to execute the raw linter.
* @task exec
*/
protected function getExecutableCommand() {
final protected function getExecutableCommand() {
$this->checkBinaryConfiguration();
$interpreter = null;
@ -351,7 +351,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
* @return list<string> Composed flags.
* @task exec
*/
protected function getCommandFlags() {
final protected function getCommandFlags() {
$mandatory_flags = $this->getMandatoryFlags();
if (!is_array($mandatory_flags)) {
phutil_deprecated(
@ -394,7 +394,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
return csprintf('%s', $path);
}
protected function buildFutures(array $paths) {
final protected function buildFutures(array $paths) {
$executable = $this->getExecutableCommand();
$bin = csprintf('%C %Ls', $executable, $this->getCommandFlags());
@ -420,7 +420,7 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
return $futures;
}
protected function resolveFuture($path, Future $future) {
final protected function resolveFuture($path, Future $future) {
list($err, $stdout, $stderr) = $future->resolve();
if ($err && !$this->shouldExpectCommandErrors()) {
$future->resolvex();

View file

@ -7,11 +7,11 @@ abstract class ArcanistFutureLinter extends ArcanistLinter {
abstract protected function buildFutures(array $paths);
abstract protected function resolveFuture($path, Future $future);
protected function getFuturesLimit() {
final protected function getFuturesLimit() {
return 8;
}
public function willLintPaths(array $paths) {
final public function willLintPaths(array $paths) {
$limit = $this->getFuturesLimit();
$this->futures = Futures(array())->limit($limit);
foreach ($this->buildFutures($paths) as $path => $future) {
@ -19,10 +19,9 @@ abstract class ArcanistFutureLinter extends ArcanistLinter {
}
}
public function lintPath($path) {
}
final public function lintPath($path) {}
public function didRunLinters() {
final public function didRunLinters() {
if ($this->futures) {
foreach ($this->futures as $path => $future) {
$this->willLintPath($path);

View file

@ -88,11 +88,11 @@ abstract class ArcanistLinter {
return $this;
}
public function getActivePath() {
final public function getActivePath() {
return $this->activePath;
}
public function getOtherLocation($offset, $path = null) {
final public function getOtherLocation($offset, $path = null) {
if ($path === null) {
$path = $this->getActivePath();
}
@ -108,21 +108,21 @@ abstract class ArcanistLinter {
);
}
public function stopAllLinters() {
final public function stopAllLinters() {
$this->stopAllLinters = true;
return $this;
}
public function didStopAllLinters() {
final public function didStopAllLinters() {
return $this->stopAllLinters;
}
public function addPath($path) {
final public function addPath($path) {
$this->paths[$path] = $path;
return $this;
}
public function setPaths(array $paths) {
final public function setPaths(array $paths) {
$this->paths = $paths;
return $this;
}
@ -131,7 +131,7 @@ abstract class ArcanistLinter {
* Filter out paths which this linter doesn't act on (for example, because
* they are binaries and the linter doesn't apply to binaries).
*/
private function filterPaths($paths) {
final private function filterPaths($paths) {
$engine = $this->getEngine();
$keep = array();
@ -154,16 +154,16 @@ abstract class ArcanistLinter {
return $keep;
}
public function getPaths() {
final public function getPaths() {
return $this->filterPaths(array_values($this->paths));
}
public function addData($path, $data) {
final public function addData($path, $data) {
$this->data[$path] = $data;
return $this;
}
protected function getData($path) {
final protected function getData($path) {
if (!array_key_exists($path, $this->data)) {
$this->data[$path] = $this->getEngine()->loadData($path);
}
@ -175,7 +175,7 @@ abstract class ArcanistLinter {
return $this;
}
protected function getEngine() {
final protected function getEngine() {
return $this->engine;
}
@ -183,11 +183,11 @@ abstract class ArcanistLinter {
return 0;
}
public function getLintMessageFullCode($short_code) {
final public function getLintMessageFullCode($short_code) {
return $this->getLinterName().$short_code;
}
public function getLintMessageSeverity($code) {
final public function getLintMessageSeverity($code) {
$map = $this->customSeverityMap;
if (isset($map[$code])) {
return $map[$code];
@ -211,12 +211,12 @@ abstract class ArcanistLinter {
return ArcanistLintSeverity::SEVERITY_ERROR;
}
public function isMessageEnabled($code) {
final public function isMessageEnabled($code) {
return ($this->getLintMessageSeverity($code) !==
ArcanistLintSeverity::SEVERITY_DISABLED);
}
public function getLintMessageName($code) {
final public function getLintMessageName($code) {
$map = $this->getLintNameMap();
if (isset($map[$code])) {
return $map[$code];
@ -224,7 +224,7 @@ abstract class ArcanistLinter {
return "Unknown lint message!";
}
protected function addLintMessage(ArcanistLintMessage $message) {
final protected function addLintMessage(ArcanistLintMessage $message) {
if (!$this->getEngine()->getCommitHookMode()) {
$root = $this->getEngine()->getWorkingCopy()->getProjectRoot();
$path = Filesystem::resolvePath($message->getPath(), $root);
@ -234,11 +234,11 @@ abstract class ArcanistLinter {
return $message;
}
public function getLintMessages() {
final public function getLintMessages() {
return $this->messages;
}
protected function raiseLintAtLine(
final protected function raiseLintAtLine(
$line,
$char,
$code,
@ -260,14 +260,14 @@ abstract class ArcanistLinter {
return $this->addLintMessage($message);
}
protected function raiseLintAtPath(
final protected function raiseLintAtPath(
$code,
$desc) {
return $this->raiseLintAtLine(null, null, $code, $desc, null, null);
}
protected function raiseLintAtOffset(
final protected function raiseLintAtOffset(
$offset,
$code,
$desc,
@ -316,7 +316,7 @@ abstract class ArcanistLinter {
// This is a hook.
}
protected function isCodeEnabled($code) {
final protected function isCodeEnabled($code) {
$severity = $this->getLintMessageSeverity($code);
return $this->getEngine()->isSeverityEnabled($severity);
}

View file

@ -30,10 +30,6 @@ final class ArcanistXMLLinter extends ArcanistLinter {
return LIBXML_VERSION;
}
public function getLintMessageName($code) {
return 'LibXML Error';
}
public function lintPath($path) {
libxml_use_internal_errors(true);
libxml_clear_errors();
@ -49,7 +45,7 @@ final class ArcanistXMLLinter extends ArcanistLinter {
$message->setLine($error->line);
$message->setChar($error->column ? $error->column : null);
$message->setCode($this->getLintMessageFullCode($error->code));
$message->setName($this->getLintMessageName($error->code));
$message->setName('LibXML Error');
$message->setDescription(trim($error->message));
switch ($error->level) {