]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Move conversion to dictionary inside lint message
authorvrana <jakubv@fb.com>
Tue, 6 Nov 2012 04:23:38 +0000 (20:23 -0800)
committervrana <jakubv@fb.com>
Tue, 6 Nov 2012 06:39:35 +0000 (22:39 -0800)
Summary: Maybe I will need it on other places.

Test Plan:
  $ arc lint --output json # on file with lint error

Reviewers: epriestley

Reviewed By: epriestley

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

src/lint/ArcanistLintMessage.php
src/lint/renderer/ArcanistLintJSONRenderer.php
src/workflow/ArcanistDiffWorkflow.php

index 6da5a0d82ef29760f4f7804dc23309b853e5f1d1..89a8fd1ed99b1020ce7c0d53d5167b8034d0959d 100644 (file)
@@ -39,6 +39,18 @@ final class ArcanistLintMessage {
     return $message;
   }
 
+  public function toDictionary() {
+    return array(
+      'path'        => $this->getPath(),
+      'line'        => $this->getLine(),
+      'char'        => $this->getChar(),
+      'code'        => $this->getCode(),
+      'severity'    => $this->getSeverity(),
+      'name'        => $this->getName(),
+      'description' => $this->getDescription(),
+    );
+  }
+
   public function setPath($path) {
     $this->path = $path;
     return $this;
index 1c038841aa533844ac9f21fec7b04eca252a715e..ce824224e73d9cb911c64c8c01943f3d687f6c0d 100644 (file)
@@ -17,19 +17,13 @@ final class ArcanistLintJSONRenderer implements ArcanistLintRenderer {
     $output = array($path => array());
 
     foreach ($messages as $message) {
-      $output[$path][] = array(
-        'code' => $message->getCode(),
-        'name' => $message->getName(),
-        'severity' => $message->getSeverity(),
-        'line' => $message->getLine(),
-        'char' => $message->getChar(),
-        'context' => implode("\n", array_slice(
-          $data,
-          max(1, $message->getLine() - self::LINES_OF_CONTEXT),
-          self::LINES_OF_CONTEXT * 2 + 1
-        )),
-        'description' => $message->getDescription(),
-      );
+      $dictionary = $message->toDictionary();
+      $dictionary['context'] = implode("\n", array_slice(
+        $data,
+        max(1, $message->getLine() - self::LINES_OF_CONTEXT),
+        self::LINES_OF_CONTEXT * 2 + 1));
+      unset($dictionary['path']);
+      $output[$path][] = $dictionary;
     }
 
     return json_encode($output)."\n";
index 08163d3f634b43591c8433e916d01f3cc0fe7b5e..43c049e557360f3fe2003981632ec18ed48e993c 100644 (file)
@@ -1264,15 +1264,7 @@ EOTEXT
 
       $this->unresolvedLint = array();
       foreach ($lint_workflow->getUnresolvedMessages() as $message) {
-        $this->unresolvedLint[] = array(
-          'path'        => $message->getPath(),
-          'line'        => $message->getLine(),
-          'char'        => $message->getChar(),
-          'code'        => $message->getCode(),
-          'severity'    => $message->getSeverity(),
-          'name'        => $message->getName(),
-          'description' => $message->getDescription(),
-        );
+        $this->unresolvedLint[] = $message->toDictionary();
       }
 
       $this->postponedLinters = $lint_workflow->getPostponedLinters();