]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Define interface for lint renderers
authorvrana <jakubv@fb.com>
Sat, 2 Jun 2012 00:32:35 +0000 (17:32 -0700)
committervrana <jakubv@fb.com>
Sat, 2 Jun 2012 00:35:38 +0000 (17:35 -0700)
Summary:
It makes me nervous.

Also move them to the dir.

Test Plan:
`arc lint`
`arc lint --output json`

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin
Differential Revision: https://secure.phabricator.com/D2644

src/__phutil_library_map__.php
src/lint/renderer/ArcanistLintConsoleRenderer.php [moved from src/lint/ArcanistLintRenderer.php with 98% similarity]
src/lint/renderer/ArcanistLintJSONRenderer.php [moved from src/lint/ArcanistLintJSONRenderer.php with 95% similarity]
src/lint/renderer/ArcanistLintLikeCompilerRenderer.php [moved from src/lint/ArcanistLintLikeCompilerRenderer.php with 94% similarity]
src/lint/renderer/ArcanistLintRenderer.php [new file with mode: 0644]
src/lint/renderer/ArcanistLintSummaryRenderer.php [moved from src/lint/ArcanistLintSummaryRenderer.php with 94% similarity]
src/workflow/ArcanistLiberateWorkflow.php
src/workflow/ArcanistLintWorkflow.php
src/workflow/ArcanistSvnHookPreCommitWorkflow.php

index b278c3a56591c80eccc4875fabab0ec450b630e5..1008913cd2d69442e28cad328fcf8693f108ea34 100644 (file)
@@ -59,15 +59,16 @@ phutil_register_library_map(array(
     'ArcanistLiberateLintEngine' => 'lint/engine/ArcanistLiberateLintEngine.php',
     'ArcanistLiberateWorkflow' => 'workflow/ArcanistLiberateWorkflow.php',
     'ArcanistLicenseLinter' => 'lint/linter/ArcanistLicenseLinter.php',
+    'ArcanistLintConsoleRenderer' => 'lint/renderer/ArcanistLintConsoleRenderer.php',
     'ArcanistLintEngine' => 'lint/engine/ArcanistLintEngine.php',
-    'ArcanistLintJSONRenderer' => 'lint/ArcanistLintJSONRenderer.php',
-    'ArcanistLintLikeCompilerRenderer' => 'lint/ArcanistLintLikeCompilerRenderer.php',
+    'ArcanistLintJSONRenderer' => 'lint/renderer/ArcanistLintJSONRenderer.php',
+    'ArcanistLintLikeCompilerRenderer' => 'lint/renderer/ArcanistLintLikeCompilerRenderer.php',
     'ArcanistLintMessage' => 'lint/ArcanistLintMessage.php',
     'ArcanistLintPatcher' => 'lint/ArcanistLintPatcher.php',
-    'ArcanistLintRenderer' => 'lint/ArcanistLintRenderer.php',
+    'ArcanistLintRenderer' => 'lint/renderer/ArcanistLintRenderer.php',
     'ArcanistLintResult' => 'lint/ArcanistLintResult.php',
     'ArcanistLintSeverity' => 'lint/ArcanistLintSeverity.php',
-    'ArcanistLintSummaryRenderer' => 'lint/ArcanistLintSummaryRenderer.php',
+    'ArcanistLintSummaryRenderer' => 'lint/renderer/ArcanistLintSummaryRenderer.php',
     'ArcanistLintWorkflow' => 'workflow/ArcanistLintWorkflow.php',
     'ArcanistLinter' => 'lint/linter/ArcanistLinter.php',
     'ArcanistLinterTestCase' => 'lint/linter/__tests__/ArcanistLinterTestCase.php',
@@ -169,6 +170,10 @@ phutil_register_library_map(array(
     'ArcanistLiberateLintEngine' => 'ArcanistLintEngine',
     'ArcanistLiberateWorkflow' => 'ArcanistBaseWorkflow',
     'ArcanistLicenseLinter' => 'ArcanistLinter',
+    'ArcanistLintConsoleRenderer' => 'ArcanistLintRenderer',
+    'ArcanistLintJSONRenderer' => 'ArcanistLintRenderer',
+    'ArcanistLintLikeCompilerRenderer' => 'ArcanistLintRenderer',
+    'ArcanistLintSummaryRenderer' => 'ArcanistLintRenderer',
     'ArcanistLintWorkflow' => 'ArcanistBaseWorkflow',
     'ArcanistLinterTestCase' => 'ArcanistPhutilTestCase',
     'ArcanistListWorkflow' => 'ArcanistBaseWorkflow',
similarity index 98%
rename from src/lint/ArcanistLintRenderer.php
rename to src/lint/renderer/ArcanistLintConsoleRenderer.php
index 3f9cb480a18e14f6170403077b4f8a9398f63271..944acfe7063c7d1b4261736bf079dc55d835c3e1 100644 (file)
@@ -21,7 +21,7 @@
  *
  * @group lint
  */
-final class ArcanistLintRenderer {
+final class ArcanistLintConsoleRenderer implements ArcanistLintRenderer {
   private $showAutofixPatches = false;
 
   public function setShowAutofixPatches($show_autofix_patches) {
similarity index 95%
rename from src/lint/ArcanistLintJSONRenderer.php
rename to src/lint/renderer/ArcanistLintJSONRenderer.php
index ddaa70c6bee7f37ab9534373766a21d46bf771d3..423845ec814c0ba8940eda5285dd5323aa9e3aa5 100644 (file)
@@ -21,7 +21,7 @@
  *
  * @group lint
  */
-final class ArcanistLintJSONRenderer {
+final class ArcanistLintJSONRenderer implements ArcanistLintRenderer {
   const LINES_OF_CONTEXT = 3;
 
   public function renderLintResult(ArcanistLintResult $result) {
similarity index 94%
rename from src/lint/ArcanistLintLikeCompilerRenderer.php
rename to src/lint/renderer/ArcanistLintLikeCompilerRenderer.php
index 53316aa9b2fa7e176808a0eb7b91664c3d46055a..bc75d5ba0960cfc5629ee711471e22f23684667d 100644 (file)
@@ -21,7 +21,7 @@
  *
  * @group lint
  */
-final class ArcanistLintLikeCompilerRenderer {
+final class ArcanistLintLikeCompilerRenderer implements ArcanistLintRenderer {
   public function renderLintResult(ArcanistLintResult $result) {
     $lines = array();
     $messages = $result->getMessages();
diff --git a/src/lint/renderer/ArcanistLintRenderer.php b/src/lint/renderer/ArcanistLintRenderer.php
new file mode 100644 (file)
index 0000000..aacd4ec
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * Copyright 2012 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Shows lint messages to the user.
+ *
+ * @group lint
+ */
+interface ArcanistLintRenderer {
+  public function renderLintResult(ArcanistLintResult $result);
+  public function renderOkayResult();
+}
similarity index 94%
rename from src/lint/ArcanistLintSummaryRenderer.php
rename to src/lint/renderer/ArcanistLintSummaryRenderer.php
index a9d053753fe6a7a51f85a9000ac74582a565b262..36147642999aee458dfbb89b6d6ebc082a20986e 100644 (file)
@@ -21,7 +21,7 @@
  *
  * @group lint
  */
-final class ArcanistLintSummaryRenderer {
+final class ArcanistLintSummaryRenderer implements ArcanistLintRenderer {
   public function renderLintResult(ArcanistLintResult $result) {
     $messages = $result->getMessages();
     $path = $result->getPath();
index a709aa53fc0c36780bc1b91d1a90b62af3863e06..fd189ea15f18f83398de8dd7019089daf1ef205d 100644 (file)
@@ -393,7 +393,7 @@ EOTEXT
     $paths = $this->liberateGetChangedPaths($path);
     $results = $this->liberateLintModules($path, $paths);
 
-    $renderer = new ArcanistLintRenderer();
+    $renderer = new ArcanistLintConsoleRenderer();
 
     $unresolved = false;
     foreach ($results as $result) {
index 43c35ddb326c5d46e63baa5a997a42a2841b966c..96ed2109cc799bfb9c3af74aad9057481038c0d2 100644 (file)
@@ -239,7 +239,7 @@ EOTEXT
         $apply_patches = $this->getArgument('apply-patches');
         break;
       default:
-        $renderer = new ArcanistLintRenderer();
+        $renderer = new ArcanistLintConsoleRenderer();
         $renderer->setShowAutofixPatches($prompt_autofix_patches);
         break;
     }
index d8e4fe49bb1c682ffc5a276e213add1cd05efab2..a4379fc5ce46d0a24e0eb9e5dbdf33f2a5c0b70c 100644 (file)
@@ -212,7 +212,6 @@ EOTEXT
       return 0;
     }
 
-    $renderer = new ArcanistLintRenderer();
     $failures = array();
     foreach ($results as $result) {
       if (!$result->getMessages()) {
@@ -231,6 +230,8 @@ EOTEXT
         "lint checks for this commit, or '{$at}nolint' to the file with ".
         "errors to disable lint for that file.\n\n");
       echo phutil_console_wrap($msg);
+
+      $renderer = new ArcanistLintConsoleRenderer();
       foreach ($failures as $result) {
         echo $renderer->renderLintResult($result);
       }