1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00

Make lint output look like a compiler

Summary:
Make lint output look like gcc errors / grep output; a format used by
editors to jump from a compiler error to a file+line of code which
triggered the error.

Test Plan:
In vim, I ran:

  :set makeprg=~/checkouts/devtools/arcanist/bin/arc\ lint\ --output\ compiler

Then:

  :make

And was able to jump directly to problematic lines of code.

Reviewers: jungejason

Reviewed By: jungejason

CC: aran, edwardspeyer, jungejason, codeblock, tuomaspelkonen, epriestley

Differential Revision: https://secure.phabricator.com/D550
This commit is contained in:
Edward Speyer 2011-06-28 18:14:07 -07:00
parent e462f2e84e
commit 8f76800efc
3 changed files with 61 additions and 2 deletions

View file

@ -0,0 +1,52 @@
<?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
*/
final class ArcanistLintLikeCompilerRenderer {
public function renderLintResult(ArcanistLintResult $result) {
$lines = array();
$messages = $result->getMessages();
$path = $result->getPath();
foreach ($messages as $message) {
$severity = ArcanistLintSeverity::getStringForSeverity(
$message->getSeverity());
$line = $message->getLine();
$code = $message->getCode();
$description = $message->getDescription();
$lines[] = sprintf(
"%s:%d:%s (%s) %s\n",
$path,
$line,
$severity,
$code,
$description
);
}
return implode('', $lines);
}
public function renderOkayResult() {
return "";
}
}

View file

@ -12,6 +12,7 @@ phutil_require_module('phutil', 'console');
phutil_require_module('phutil', 'utils');
phutil_require_source('ArcanistLintJSONRenderer.php');
phutil_require_source('ArcanistLintLikeCompilerRenderer.php');
phutil_require_source('ArcanistLintRenderer.php');
phutil_require_source('ArcanistLintSummaryRenderer.php');
phutil_require_source('ArcanistLintJSONRenderer.php');

View file

@ -74,7 +74,8 @@ EOTEXT
'param' => 'format',
'help' =>
"With 'summary', show lint warnings in a more compact format. ".
"With 'json', show lint warnings in machine-readable JSON format."
"With 'json', show lint warnings in machine-readable JSON format. ".
"With 'compiler', show lint warnings in suitable for your editor."
),
'advice' => array(
'help' =>
@ -196,6 +197,11 @@ EOTEXT
case 'summary':
$renderer = new ArcanistLintSummaryRenderer();
break;
case 'compiler':
$renderer = new ArcanistLintLikeCompilerRenderer();
$prompt_patches = false;
$apply_patches = $this->getArgument('apply-patches');
break;
default:
$renderer = new ArcanistLintRenderer();
break;