]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Ship lint warnings to Differential.
authorepriestley <epriestley@javelinjs.com>
Wed, 12 Jan 2011 04:21:17 +0000 (20:21 -0800)
committerepriestley <epriestley@javelinjs.com>
Wed, 12 Jan 2011 04:45:36 +0000 (20:45 -0800)
Summary: Send skipped lint warnings to Differential. This also fixes a nasty
bug with lint excluding too many warnings based on line changes.

Test Plan: meta

Reviewers:

CC:

Differential Revision: 200387

src/lint/engine/base/ArcanistLintEngine.php
src/workflow/base/ArcanistBaseWorkflow.php
src/workflow/diff/ArcanistDiffWorkflow.php
src/workflow/lint/ArcanistLintWorkflow.php

index 5a199d4b00ab9f3a61b459c8751811034cc4bd20..d3291ab704001b0c98ce43323214f1385e135ed4 100644 (file)
@@ -135,7 +135,7 @@ abstract class ArcanistLintEngine {
         // When a user runs "arc diff", we default to raising only warnings on
         // lines they have changed (errors are still raised anywhere in the
         // file).
-        $changed = $this->getPathChangedLines($path);
+        $changed = $this->getPathChangedLines($message->getPath());
         if ($changed !== null && !$message->isError()) {
           if (empty($changed[$message->getLine()])) {
             continue;
index 54bd74f7561d6af563c0e1b9a1740c9c7dd1ff47..3ca14ff9bf918ae2930ef9301bcaeef81bf35bbb 100644 (file)
@@ -449,7 +449,6 @@ class ArcanistBaseWorkflow {
 
     $change = $this->getChange($path);
     $lines = $change->getChangedLines($mode);
-
     return array_keys($lines);
   }
 
index 15c4da931a2bad528b6fd8950f7474bfc49a948e..cee3b70fdb1faf0725d3ac1e572badb22952238e 100644 (file)
@@ -19,6 +19,8 @@
 class ArcanistDiffWorkflow extends ArcanistBaseWorkflow {
 
   private $hasWarnedExternals = false;
+  private $unresolvedLint;
+  private $unresolvedUnit;
 
   public function getCommandHelp() {
     return phutil_console_format(<<<EOTEXT
@@ -247,6 +249,28 @@ EOTEXT
       'differential.creatediff',
       $diff);
 
+    if ($this->unresolvedLint) {
+      $data = array();
+      foreach ($this->unresolvedLint as $message) {
+        $data[] = array(
+          'path'        => $message->getPath(),
+          'line'        => $message->getLine(),
+          'char'        => $message->getChar(),
+          'code'        => $message->getCode(),
+          'severity'    => $message->getSeverity(),
+          'name'        => $message->getName(),
+          'description' => $message->getDescription(),
+        );
+      }
+      $conduit->callMethodSynchronous(
+        'differential.setdiffproperty',
+        array(
+          'diff_id' => $diff_info['diffid'],
+          'name'    => 'arc:lint',
+          'data'    => json_encode($data),
+        ));
+    }
+
     if ($this->shouldOnlyCreateDiff()) {
       echo phutil_console_format(
         "Created a new Differential diff:\n".
@@ -535,7 +559,7 @@ EOTEXT
       // TODO: This is kind of silly, but 'file -ib' goes crazy on executables.
       $mime_type = reset(explode(',', $mime_type));
     }
-      
+
 
     $result['mime'] = $mime_type;
 
@@ -816,6 +840,7 @@ EOTEXT
           if (!$continue) {
             throw new ArcanistUserAbortException();
           }
+          $this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
           break;
         case ArcanistLintWorkflow::RESULT_ERRORS:
           echo phutil_console_format(
index 9b2d276e44a9da6a869eed77191273da1d1386e1..573cede74fffc8599bb9401e3f1cae49364eb70c 100644 (file)
@@ -23,6 +23,8 @@ class ArcanistLintWorkflow extends ArcanistBaseWorkflow {
   const RESULT_ERRORS     = 2;
   const RESULT_SKIP       = 3;
 
+  private $unresolvedMessages;
+
   public function getCommandHelp() {
     return phutil_console_format(<<<EOTEXT
       **lint** [__options__] [__paths__] (svn)
@@ -230,6 +232,7 @@ EOTEXT
       }
     }
 
+    $unresolved = array();
     $result_code = self::RESULT_OKAY;
     foreach ($results as $result) {
       foreach ($result->getMessages() as $message) {
@@ -238,11 +241,15 @@ EOTEXT
             $result_code = self::RESULT_ERRORS;
             break;
           } else if ($message->isWarning()) {
-            $result_code = self::RESULT_WARNINGS;
+            if ($result_code != self::RESULT_ERRORS) {
+              $result_code = self::RESULT_WARNINGS;
+            }
+            $unresolved[] = $message;
           }
         }
       }
     }
+    $this->unresolvedMessages = $unresolved;
 
     if (!$this->getParentWorkflow()) {
       if ($result_code == self::RESULT_OKAY) {
@@ -253,4 +260,9 @@ EOTEXT
 
     return $result_code;
   }
+
+  public function getUnresolvedMessages() {
+    return $this->unresolvedMessages;
+  }
+
 }