mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 23:02:41 +01:00
Define interface for lint renderers
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
This commit is contained in:
parent
21acd2180e
commit
1d9ffce1ec
9 changed files with 44 additions and 11 deletions
|
@ -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',
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
* @group lint
|
||||
*/
|
||||
final class ArcanistLintRenderer {
|
||||
final class ArcanistLintConsoleRenderer implements ArcanistLintRenderer {
|
||||
private $showAutofixPatches = false;
|
||||
|
||||
public function setShowAutofixPatches($show_autofix_patches) {
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
* @group lint
|
||||
*/
|
||||
final class ArcanistLintJSONRenderer {
|
||||
final class ArcanistLintJSONRenderer implements ArcanistLintRenderer {
|
||||
const LINES_OF_CONTEXT = 3;
|
||||
|
||||
public function renderLintResult(ArcanistLintResult $result) {
|
|
@ -21,7 +21,7 @@
|
|||
*
|
||||
* @group lint
|
||||
*/
|
||||
final class ArcanistLintLikeCompilerRenderer {
|
||||
final class ArcanistLintLikeCompilerRenderer implements ArcanistLintRenderer {
|
||||
public function renderLintResult(ArcanistLintResult $result) {
|
||||
$lines = array();
|
||||
$messages = $result->getMessages();
|
27
src/lint/renderer/ArcanistLintRenderer.php
Normal file
27
src/lint/renderer/ArcanistLintRenderer.php
Normal file
|
@ -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();
|
||||
}
|
|
@ -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();
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue