From 8f76800efc0e4eba65e47e8f17adc728408f717a Mon Sep 17 00:00:00 2001 From: Edward Speyer Date: Tue, 28 Jun 2011 18:14:07 -0700 Subject: [PATCH] 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 --- .../ArcanistLintLikeCompilerRenderer.php | 52 +++++++++++++++++++ src/lint/renderer/__init__.php | 3 +- src/workflow/lint/ArcanistLintWorkflow.php | 8 ++- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/lint/renderer/ArcanistLintLikeCompilerRenderer.php diff --git a/src/lint/renderer/ArcanistLintLikeCompilerRenderer.php b/src/lint/renderer/ArcanistLintLikeCompilerRenderer.php new file mode 100644 index 00000000..53316aa9 --- /dev/null +++ b/src/lint/renderer/ArcanistLintLikeCompilerRenderer.php @@ -0,0 +1,52 @@ +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 ""; + } +} diff --git a/src/lint/renderer/__init__.php b/src/lint/renderer/__init__.php index 23f3b960..8837258e 100644 --- a/src/lint/renderer/__init__.php +++ b/src/lint/renderer/__init__.php @@ -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'); diff --git a/src/workflow/lint/ArcanistLintWorkflow.php b/src/workflow/lint/ArcanistLintWorkflow.php index 93c82433..b53c87ba 100644 --- a/src/workflow/lint/ArcanistLintWorkflow.php +++ b/src/workflow/lint/ArcanistLintWorkflow.php @@ -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;