]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Minor improvements to the `ArcanistLintCheckstyleXMLRenderer` class.
authorJoshua Spence <josh@joshuaspence.com>
Wed, 14 May 2014 00:32:49 +0000 (17:32 -0700)
committerepriestley <git@epriestley.com>
Wed, 14 May 2014 00:32:49 +0000 (17:32 -0700)
Summary: Ref T4948. Move the `startDocument` code to a `renderPreamble` function so that, at least theoretically, the renderer can be reused. Otherwise, the only way to reuse the renderer would be to construct a new instance.

Test Plan: Ran `arc lint --output xml` and verified that the output looked reasonable.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4948

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

src/lint/renderer/ArcanistLintCheckstyleXMLRenderer.php
src/lint/renderer/ArcanistLintRenderer.php
src/workflow/ArcanistLintWorkflow.php

index 081ead900751c628629dc0cf655d89eae01c1097..29afda46aa2491b01271af702ef4bd6df30fa828 100644 (file)
@@ -14,10 +14,13 @@ final class ArcanistLintCheckstyleXMLRenderer extends ArcanistLintRenderer {
     $this->writer->openMemory();
     $this->writer->setIndent(true);
     $this->writer->setIndentString('  ');
+  }
 
+  public function renderPreamble() {
     $this->writer->startDocument('1.0', 'UTF-8');
     $this->writer->startElement('checkstyle');
     $this->writer->writeAttribute('version', '4.3');
+    return $this->writer->flush();
   }
 
   public function renderLintResult(ArcanistLintResult $result) {
index bc82a32fc7663bc779c8c3d4ee54bb0943d61812..808f31288dd59aa61c687c817303e1e8020037c8 100644 (file)
@@ -7,6 +7,10 @@
  */
 abstract class ArcanistLintRenderer {
 
+  public function renderPreamble() {
+    return '';
+  }
+
   abstract public function renderLintResult(ArcanistLintResult $result);
   abstract public function renderOkayResult();
 
index 61f20a34d312cd2b5db208c54304b22c29e14bab..05c13a65032d5cf42a404195cd4dd3a173ef63a8 100644 (file)
@@ -469,6 +469,7 @@ EOTEXT
     }
 
     $all_autofix = true;
+    $console->writeOut('%s', $renderer->renderPreamble());
 
     foreach ($results as $result) {
       $result_all_autofix = $result->isAllAutofix();