]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add a version number to `ArcanistXHPASTLinter`.
authorJoshua Spence <josh@joshuaspence.com>
Wed, 28 May 2014 13:33:58 +0000 (06:33 -0700)
committerepriestley <git@epriestley.com>
Wed, 28 May 2014 13:33:58 +0000 (06:33 -0700)
Summary: Fixes T5209. It makes sense for the `ArcanistXHPASTLinter` to implement the `getVersion` method in order to be able to enforce version requirements (as in T4954).

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T5209

Differential Revision: https://secure.phabricator.com/D9317

src/lint/linter/ArcanistBaseXHPASTLinter.php
src/lint/linter/ArcanistPhutilXHPASTLinter.php
src/lint/linter/ArcanistXHPASTLinter.php

index 86b0072e21522a66b6192b4c6fa28aabe6ab9cc4..7951c62e74c6b226730ea84beafed870b9e677bc 100644 (file)
@@ -9,6 +9,19 @@ abstract class ArcanistBaseXHPASTLinter extends ArcanistFutureLinter {
   private $trees = array();
   private $exceptions = array();
 
+  final public function getCacheVersion() {
+    $parts = array();
+
+    $parts[] = $this->getVersion();
+
+    $path = xhpast_get_binary_path();
+    if (Filesystem::pathExists($path)) {
+      $parts[] = md5_file($path);
+    }
+
+    return implode('-', $parts);
+  }
+
   final protected function raiseLintAtToken(
     XHPASTToken $token,
     $code,
index c14ec7e800151704e8c041f76b9ee3026a185ccb..fac289370885a08c78fc5f54f2c88e28d72607d7 100644 (file)
@@ -60,13 +60,9 @@ final class ArcanistPhutilXHPASTLinter extends ArcanistBaseXHPASTLinter {
     return 'phutil-xhpast';
   }
 
-  public function getCacheVersion() {
-    $version = '2';
-    $path = xhpast_get_binary_path();
-    if (Filesystem::pathExists($path)) {
-      $version .= '-'.md5_file($path);
-    }
-    return $version;
+  public function getVersion() {
+    // The version number should be incremented whenever a new rule is added.
+    return '2';
   }
 
   public function getLinterConfigurationOptions() {
index 8ac3bb12df32254cfa8efaf32817de06a9edd818..ff3da80f87933c72239c93352378dcb36a6ec827 100644 (file)
@@ -186,13 +186,9 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
     return parent::setLinterConfigurationValue($key, $value);
   }
 
-  public function getCacheVersion() {
-    $version = '5';
-    $path = xhpast_get_binary_path();
-    if (Filesystem::pathExists($path)) {
-      $version .= '-'.md5_file($path);
-    }
-    return $version;
+  public function getVersion() {
+    // The version number should be incremented whenever a new rule is added.
+    return '5';
   }
 
   protected function resolveFuture($path, Future $future) {