1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 08:42:40 +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 $trees = array();
private $exceptions = array(); private $exceptions = array();
protected final function raiseLintAtToken( final protected function raiseLintAtToken(
XHPASTToken $token, XHPASTToken $token,
$code, $code,
$desc, $desc,
@ -22,7 +22,7 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter {
$replace); $replace);
} }
protected final function raiseLintAtNode( final protected function raiseLintAtNode(
XHPASTNode $node, XHPASTNode $node,
$code, $code,
$desc, $desc,

View file

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

View file

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

View file

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

View file

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