From: epriestley Date: Wed, 12 Jan 2011 04:21:17 +0000 (-0800) Subject: Ship lint warnings to Differential. X-Git-Tag: conduit-4~442 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=bb7e649fa51fca4209dde0da38173eaa6a7a57da;p=arcanist.git 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 --- diff --git a/src/lint/engine/base/ArcanistLintEngine.php b/src/lint/engine/base/ArcanistLintEngine.php index 5a199d4b..d3291ab7 100644 --- a/src/lint/engine/base/ArcanistLintEngine.php +++ b/src/lint/engine/base/ArcanistLintEngine.php @@ -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; diff --git a/src/workflow/base/ArcanistBaseWorkflow.php b/src/workflow/base/ArcanistBaseWorkflow.php index 54bd74f7..3ca14ff9 100644 --- a/src/workflow/base/ArcanistBaseWorkflow.php +++ b/src/workflow/base/ArcanistBaseWorkflow.php @@ -449,7 +449,6 @@ class ArcanistBaseWorkflow { $change = $this->getChange($path); $lines = $change->getChangedLines($mode); - return array_keys($lines); } diff --git a/src/workflow/diff/ArcanistDiffWorkflow.php b/src/workflow/diff/ArcanistDiffWorkflow.php index 15c4da93..cee3b70f 100644 --- a/src/workflow/diff/ArcanistDiffWorkflow.php +++ b/src/workflow/diff/ArcanistDiffWorkflow.php @@ -19,6 +19,8 @@ class ArcanistDiffWorkflow extends ArcanistBaseWorkflow { private $hasWarnedExternals = false; + private $unresolvedLint; + private $unresolvedUnit; public function getCommandHelp() { return phutil_console_format(<<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( diff --git a/src/workflow/lint/ArcanistLintWorkflow.php b/src/workflow/lint/ArcanistLintWorkflow.php index 9b2d276e..573cede7 100644 --- a/src/workflow/lint/ArcanistLintWorkflow.php +++ b/src/workflow/lint/ArcanistLintWorkflow.php @@ -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(<<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; + } + }