1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-23 05:50:54 +01:00

Support for lint messages which are always shown

Summary: If one wishes to implement a linter which finds unused resources or variables the current scheme does not work as the lint engine filters all changes from lines which were not introduced in a diff. To solve that, I've added an "always show" configuration for a lint message allowing creation of such linters.

Test Plan:
1. Created a custom linter for finding unused Android resources in a project
2. Ran arc lint with linter added and received warnings as expected

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D6119
This commit is contained in:
Omer Strulovich 2013-06-09 08:37:40 -07:00 committed by epriestley
parent 3de4984256
commit 9a46ba7ea1
2 changed files with 17 additions and 1 deletions

View file

@ -21,6 +21,7 @@ final class ArcanistLintMessage {
protected $otherLocations = array();
protected $obsolete;
protected $granularity;
protected $bypassChangedLineFiltering;
public static function newFromDictionary(array $dict) {
$message = new ArcanistLintMessage();
@ -40,6 +41,9 @@ final class ArcanistLintMessage {
}
$message->setGranularity(idx($dict, 'granularity'));
$message->setOtherLocations(idx($dict, 'locations', array()));
if (isset($dict['bypassChangedLineFiltering'])) {
$message->bypassChangedLineFiltering($dict['bypassChangedLineFiltering']);
}
return $message;
}
@ -56,6 +60,7 @@ final class ArcanistLintMessage {
'replacement' => $this->getReplacementText(),
'granularity' => $this->getGranularity(),
'locations' => $this->getOtherLocations(),
'bypassChangedLineFiltering' => $this->shouldBypassChangedLineFiltering(),
);
}
@ -213,4 +218,13 @@ final class ArcanistLintMessage {
return $this;
}
public function setBypassChangedLineFiltering($bypass_changed_lines) {
$this->bypassChangedLineFiltering = $bypass_changed_lines;
return $this;
}
public function shouldBypassChangedLineFiltering() {
return $this->bypassChangedLineFiltering;
}
}

View file

@ -411,7 +411,9 @@ abstract class ArcanistLintEngine {
// path is a directory or a binary file so we should not exclude
// warnings.
if (!$this->changedLines || $message->isError()) {
if (!$this->changedLines ||
$message->isError() ||
$message->shouldBypassChangedLineFiltering()) {
return true;
}