From 9bd740b1f85c6a040452c7830e967d3e5c2bc286 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Sun, 11 May 2014 19:28:26 -0700 Subject: [PATCH] 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 --- src/lint/linter/ArcanistConduitLinter.php | 4 ++++ src/lint/linter/ArcanistGeneratedLinter.php | 4 ++++ src/lint/linter/ArcanistLinter.php | 17 +++++++++++++++++ src/lint/linter/ArcanistNoLintLinter.php | 4 ++++ 4 files changed, 29 insertions(+) diff --git a/src/lint/linter/ArcanistConduitLinter.php b/src/lint/linter/ArcanistConduitLinter.php index 2618ea99..5a7a67a2 100644 --- a/src/lint/linter/ArcanistConduitLinter.php +++ b/src/lint/linter/ArcanistConduitLinter.php @@ -95,4 +95,8 @@ final class ArcanistConduitLinter extends ArcanistLinter { 'ArcanistConduitLinter does not support a name map.' ); } + + protected function canCustomizeLintSeverities() { + return false; + } } diff --git a/src/lint/linter/ArcanistGeneratedLinter.php b/src/lint/linter/ArcanistGeneratedLinter.php index 7cf90450..29c1e809 100644 --- a/src/lint/linter/ArcanistGeneratedLinter.php +++ b/src/lint/linter/ArcanistGeneratedLinter.php @@ -28,6 +28,10 @@ final class ArcanistGeneratedLinter extends ArcanistLinter { return 'generated'; } + protected function canCustomizeLintSeverities() { + return false; + } + public function lintPath($path) { $data = $this->getData($path); if (preg_match('/@'.'generated/', $data)) { diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php index e8847512..ae40eb90 100644 --- a/src/lint/linter/ArcanistLinter.php +++ b/src/lint/linter/ArcanistLinter.php @@ -355,6 +355,10 @@ abstract class ArcanistLinter { } public function getLinterConfigurationOptions() { + if (!$this->canCustomizeLintSeverities()) { + return array(); + } + return array( 'severity' => 'optional map', 'severity.rules' => 'optional map', @@ -372,6 +376,10 @@ abstract class ArcanistLinter { switch ($key) { case 'severity': + if (!$this->canCustomizeLintSeverities()) { + break; + } + $custom = array(); foreach ($value as $code => $severity) { if (empty($sev_map[$severity])) { @@ -388,7 +396,12 @@ abstract class ArcanistLinter { $this->setCustomSeverityMap($custom); return; + case 'severity.rules': + if (!$this->canCustomizeLintSeverities()) { + break; + } + foreach ($value as $rule => $severity) { if (@preg_match($rule, '') === false) { throw new Exception( @@ -412,6 +425,10 @@ abstract class ArcanistLinter { throw new Exception("Incomplete implementation: {$key}!"); } + protected function canCustomizeLintSeverities() { + return true; + } + protected function shouldLintBinaryFiles() { return false; } diff --git a/src/lint/linter/ArcanistNoLintLinter.php b/src/lint/linter/ArcanistNoLintLinter.php index 67ef6922..e219103f 100644 --- a/src/lint/linter/ArcanistNoLintLinter.php +++ b/src/lint/linter/ArcanistNoLintLinter.php @@ -28,6 +28,10 @@ final class ArcanistNoLintLinter extends ArcanistLinter { return 'nolint'; } + protected function canCustomizeLintSeverities() { + return false; + } + public function lintPath($path) { $data = $this->getData($path); if (preg_match('/@'.'nolint/', $data)) {