]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Made some additional methods of `ArcanistLinter` and `ArcanistExternalLinter` final
authorJoshua Spence <josh@joshuaspence.com>
Mon, 12 May 2014 16:48:52 +0000 (09:48 -0700)
committerepriestley <git@epriestley.com>
Mon, 12 May 2014 16:49:45 +0000 (09:49 -0700)
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

src/lint/linter/ArcanistBaseXHPASTLinter.php
src/lint/linter/ArcanistExternalLinter.php
src/lint/linter/ArcanistFutureLinter.php
src/lint/linter/ArcanistLinter.php
src/lint/linter/ArcanistXMLLinter.php

index 1fe7d7780204d75b848bdb3227fab081eacd5a0e..86b0072e21522a66b6192b4c6fa28aabe6ab9cc4 100644 (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,
index a1ea0b723155ff39e0ce39aa86c6182dfa345d05..e7a21a9e9d9ccd27a12bbae77cb5a0931b6ef23b 100644 (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();
index 7b5fb775de960fe0b67553864a09cb6f0d77894a..30105c709cde267d2d15a5dfe53e3a5cd6478d90 100644 (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);
index f599505a7cd160ddb530cbcafab84662ec5acebe..b6b566e28944567b5c3aa76e11df83d918600f76 100644 (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);
   }
index 59e05febf825148ebdb80493f3855ef021dc22d3..f67ef0b75d3a6eebeb2b13189fe5fe551cce8f8c 100644 (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) {