]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Support for lint messages which are always shown
authorOmer Strulovich <ostrulovich@fb.com>
Sun, 9 Jun 2013 15:37:40 +0000 (08:37 -0700)
committerepriestley <git@epriestley.com>
Sun, 9 Jun 2013 15:38:30 +0000 (08:38 -0700)
Summary: If one wishes to implement a linter which finds unused resources or variables the current scheme does not work as the lint engine filters all changes from lines which were not introduced in a diff. To solve that, I've added an "always show" configuration for a lint message allowing creation of such linters.

Test Plan:
1. Created a custom linter for finding unused Android resources in a project
2. Ran arc lint with linter added and received warnings as expected

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D6119

src/lint/ArcanistLintMessage.php
src/lint/engine/ArcanistLintEngine.php

index cce2ca21cc97e924550700f2f2c60fa5e3fe15ed..80816fbbbe47358cdc2a1939eb7f16ebdd2c8f25 100644 (file)
@@ -21,6 +21,7 @@ final class ArcanistLintMessage {
   protected $otherLocations = array();
   protected $obsolete;
   protected $granularity;
+  protected $bypassChangedLineFiltering;
 
   public static function newFromDictionary(array $dict) {
     $message = new ArcanistLintMessage();
@@ -40,6 +41,9 @@ final class ArcanistLintMessage {
     }
     $message->setGranularity(idx($dict, 'granularity'));
     $message->setOtherLocations(idx($dict, 'locations', array()));
+    if (isset($dict['bypassChangedLineFiltering'])) {
+      $message->bypassChangedLineFiltering($dict['bypassChangedLineFiltering']);
+    }
     return $message;
   }
 
@@ -56,6 +60,7 @@ final class ArcanistLintMessage {
       'replacement' => $this->getReplacementText(),
       'granularity' => $this->getGranularity(),
       'locations'   => $this->getOtherLocations(),
+      'bypassChangedLineFiltering' => $this->shouldBypassChangedLineFiltering(),
     );
   }
 
@@ -213,4 +218,13 @@ final class ArcanistLintMessage {
     return $this;
   }
 
+  public function setBypassChangedLineFiltering($bypass_changed_lines) {
+    $this->bypassChangedLineFiltering = $bypass_changed_lines;
+    return $this;
+  }
+
+  public function shouldBypassChangedLineFiltering() {
+    return $this->bypassChangedLineFiltering;
+  }
+
 }
index b08f5e19a752138e2bedaa315cfcb7c747156043..3cb5dbc510aa0acc04c77d6e42c111a099f34472 100644 (file)
@@ -411,7 +411,9 @@ abstract class ArcanistLintEngine {
     // path is a directory or a binary file so we should not exclude
     // warnings.
 
-    if (!$this->changedLines || $message->isError()) {
+    if (!$this->changedLines ||
+        $message->isError() ||
+        $message->shouldBypassChangedLineFiltering()) {
       return true;
     }