1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 08:52:39 +01:00

Remove severity options from some linters.

Summary: The `ArcanistGeneratedLinter` and `ArcanistNoLintLinter` don't actually ever raise any linter messages, so it doesn't make sense to set custom severities for these linters. Instead, don't expose this configuration.

Test Plan: N/A

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9038
This commit is contained in:
Joshua Spence 2014-05-11 19:28:26 -07:00 committed by epriestley
parent 7870e7f2e4
commit 9bd740b1f8
4 changed files with 29 additions and 0 deletions

View file

@ -95,4 +95,8 @@ final class ArcanistConduitLinter extends ArcanistLinter {
'ArcanistConduitLinter does not support a name map.' 'ArcanistConduitLinter does not support a name map.'
); );
} }
protected function canCustomizeLintSeverities() {
return false;
}
} }

View file

@ -28,6 +28,10 @@ final class ArcanistGeneratedLinter extends ArcanistLinter {
return 'generated'; return 'generated';
} }
protected function canCustomizeLintSeverities() {
return false;
}
public function lintPath($path) { public function lintPath($path) {
$data = $this->getData($path); $data = $this->getData($path);
if (preg_match('/@'.'generated/', $data)) { if (preg_match('/@'.'generated/', $data)) {

View file

@ -355,6 +355,10 @@ abstract class ArcanistLinter {
} }
public function getLinterConfigurationOptions() { public function getLinterConfigurationOptions() {
if (!$this->canCustomizeLintSeverities()) {
return array();
}
return array( return array(
'severity' => 'optional map<string|int, string>', 'severity' => 'optional map<string|int, string>',
'severity.rules' => 'optional map<string, string>', 'severity.rules' => 'optional map<string, string>',
@ -372,6 +376,10 @@ abstract class ArcanistLinter {
switch ($key) { switch ($key) {
case 'severity': case 'severity':
if (!$this->canCustomizeLintSeverities()) {
break;
}
$custom = array(); $custom = array();
foreach ($value as $code => $severity) { foreach ($value as $code => $severity) {
if (empty($sev_map[$severity])) { if (empty($sev_map[$severity])) {
@ -388,7 +396,12 @@ abstract class ArcanistLinter {
$this->setCustomSeverityMap($custom); $this->setCustomSeverityMap($custom);
return; return;
case 'severity.rules': case 'severity.rules':
if (!$this->canCustomizeLintSeverities()) {
break;
}
foreach ($value as $rule => $severity) { foreach ($value as $rule => $severity) {
if (@preg_match($rule, '') === false) { if (@preg_match($rule, '') === false) {
throw new Exception( throw new Exception(
@ -412,6 +425,10 @@ abstract class ArcanistLinter {
throw new Exception("Incomplete implementation: {$key}!"); throw new Exception("Incomplete implementation: {$key}!");
} }
protected function canCustomizeLintSeverities() {
return true;
}
protected function shouldLintBinaryFiles() { protected function shouldLintBinaryFiles() {
return false; return false;
} }

View file

@ -28,6 +28,10 @@ final class ArcanistNoLintLinter extends ArcanistLinter {
return 'nolint'; return 'nolint';
} }
protected function canCustomizeLintSeverities() {
return false;
}
public function lintPath($path) { public function lintPath($path) {
$data = $this->getData($path); $data = $this->getData($path);
if (preg_match('/@'.'nolint/', $data)) { if (preg_match('/@'.'nolint/', $data)) {