From: Joshua Spence Date: Wed, 14 May 2014 00:32:49 +0000 (-0700) Subject: Minor improvements to the `ArcanistLintCheckstyleXMLRenderer` class. X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=d484b60295050c1f6637c1450ef78cc1f583dda0;p=arcanist.git Minor improvements to the `ArcanistLintCheckstyleXMLRenderer` class. 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 --- diff --git a/src/lint/renderer/ArcanistLintCheckstyleXMLRenderer.php b/src/lint/renderer/ArcanistLintCheckstyleXMLRenderer.php index 081ead90..29afda46 100644 --- a/src/lint/renderer/ArcanistLintCheckstyleXMLRenderer.php +++ b/src/lint/renderer/ArcanistLintCheckstyleXMLRenderer.php @@ -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) { diff --git a/src/lint/renderer/ArcanistLintRenderer.php b/src/lint/renderer/ArcanistLintRenderer.php index bc82a32f..808f3128 100644 --- a/src/lint/renderer/ArcanistLintRenderer.php +++ b/src/lint/renderer/ArcanistLintRenderer.php @@ -7,6 +7,10 @@ */ abstract class ArcanistLintRenderer { + public function renderPreamble() { + return ''; + } + abstract public function renderLintResult(ArcanistLintResult $result); abstract public function renderOkayResult(); diff --git a/src/workflow/ArcanistLintWorkflow.php b/src/workflow/ArcanistLintWorkflow.php index 61f20a34..05c13a65 100644 --- a/src/workflow/ArcanistLintWorkflow.php +++ b/src/workflow/ArcanistLintWorkflow.php @@ -469,6 +469,7 @@ EOTEXT } $all_autofix = true; + $console->writeOut('%s', $renderer->renderPreamble()); foreach ($results as $result) { $result_all_autofix = $result->isAllAutofix();