1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 22:32:41 +01:00

Ship lint warnings to Differential.

Summary: Send skipped lint warnings to Differential. This also fixes a nasty
bug with lint excluding too many warnings based on line changes.

Test Plan: meta

Reviewers:

CC:

Differential Revision: 200387
This commit is contained in:
epriestley 2011-01-11 20:21:17 -08:00
parent 964630facc
commit bb7e649fa5
4 changed files with 40 additions and 4 deletions

View file

@ -135,7 +135,7 @@ abstract class ArcanistLintEngine {
// When a user runs "arc diff", we default to raising only warnings on
// lines they have changed (errors are still raised anywhere in the
// file).
$changed = $this->getPathChangedLines($path);
$changed = $this->getPathChangedLines($message->getPath());
if ($changed !== null && !$message->isError()) {
if (empty($changed[$message->getLine()])) {
continue;

View file

@ -449,7 +449,6 @@ class ArcanistBaseWorkflow {
$change = $this->getChange($path);
$lines = $change->getChangedLines($mode);
return array_keys($lines);
}

View file

@ -19,6 +19,8 @@
class ArcanistDiffWorkflow extends ArcanistBaseWorkflow {
private $hasWarnedExternals = false;
private $unresolvedLint;
private $unresolvedUnit;
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
@ -247,6 +249,28 @@ EOTEXT
'differential.creatediff',
$diff);
if ($this->unresolvedLint) {
$data = array();
foreach ($this->unresolvedLint as $message) {
$data[] = array(
'path' => $message->getPath(),
'line' => $message->getLine(),
'char' => $message->getChar(),
'code' => $message->getCode(),
'severity' => $message->getSeverity(),
'name' => $message->getName(),
'description' => $message->getDescription(),
);
}
$conduit->callMethodSynchronous(
'differential.setdiffproperty',
array(
'diff_id' => $diff_info['diffid'],
'name' => 'arc:lint',
'data' => json_encode($data),
));
}
if ($this->shouldOnlyCreateDiff()) {
echo phutil_console_format(
"Created a new Differential diff:\n".
@ -535,7 +559,7 @@ EOTEXT
// TODO: This is kind of silly, but 'file -ib' goes crazy on executables.
$mime_type = reset(explode(',', $mime_type));
}
$result['mime'] = $mime_type;
@ -816,6 +840,7 @@ EOTEXT
if (!$continue) {
throw new ArcanistUserAbortException();
}
$this->unresolvedLint = $lint_workflow->getUnresolvedMessages();
break;
case ArcanistLintWorkflow::RESULT_ERRORS:
echo phutil_console_format(

View file

@ -23,6 +23,8 @@ class ArcanistLintWorkflow extends ArcanistBaseWorkflow {
const RESULT_ERRORS = 2;
const RESULT_SKIP = 3;
private $unresolvedMessages;
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
**lint** [__options__] [__paths__] (svn)
@ -230,6 +232,7 @@ EOTEXT
}
}
$unresolved = array();
$result_code = self::RESULT_OKAY;
foreach ($results as $result) {
foreach ($result->getMessages() as $message) {
@ -238,11 +241,15 @@ EOTEXT
$result_code = self::RESULT_ERRORS;
break;
} else if ($message->isWarning()) {
$result_code = self::RESULT_WARNINGS;
if ($result_code != self::RESULT_ERRORS) {
$result_code = self::RESULT_WARNINGS;
}
$unresolved[] = $message;
}
}
}
}
$this->unresolvedMessages = $unresolved;
if (!$this->getParentWorkflow()) {
if ($result_code == self::RESULT_OKAY) {
@ -253,4 +260,9 @@ EOTEXT
return $result_code;
}
public function getUnresolvedMessages() {
return $this->unresolvedMessages;
}
}