]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Provide `arc linters --verbose` to list all available options
authorepriestley <git@epriestley.com>
Mon, 12 May 2014 03:23:07 +0000 (20:23 -0700)
committerepriestley <git@epriestley.com>
Mon, 12 May 2014 03:23:07 +0000 (20:23 -0700)
Summary:
Ref T2039. I'll update the corresponding documentation.

It feels a little awkward that this is disconnected from `getLinterConfigurationOptions()`, but I dislike returning weird ad-hoc structures more than I dislike having two methods. Most linters don't implement either of these anyway.

Test Plan: Ran `arc linters` and `arc linters --verbose`.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T2039

Differential Revision: https://secure.phabricator.com/D9062

src/lint/engine/ArcanistConfigurationDrivenLintEngine.php
src/lint/linter/ArcanistCSharpLinter.php
src/lint/linter/ArcanistExternalLinter.php
src/lint/linter/ArcanistLesscLinter.php
src/lint/linter/ArcanistLinter.php
src/lint/linter/ArcanistTextLinter.php
src/workflow/ArcanistLintersWorkflow.php

index b3cb0db31f63bcea350c39a717fb7d263ad4da58..330e73976d1396778506176486cef3c03b423cd6 100644 (file)
@@ -47,6 +47,16 @@ final class ArcanistConfigurationDrivenLintEngine extends ArcanistLintEngine {
         $linter = clone $linters[$type];
         $linter->setEngine($this);
         $more = $linter->getLinterConfigurationOptions();
+
+        foreach ($more as $key => $option_spec) {
+          PhutilTypeSpec::checkMap(
+            $option_spec,
+            array(
+              'type' => 'string',
+              'help' => 'string',
+            ));
+          $more[$key] = $option_spec['type'];
+        }
       } else {
         // We'll raise an error below about the invalid "type" key.
         $linter = null;
index 0d6f3c22f7b9149b38e40f6d962f96d4dd687be7..b0b7b2447e0cc09dd2cc715152726fc5a989b111 100644 (file)
@@ -2,8 +2,6 @@
 
 /**
  * C# linter for Arcanist.
- *
- * @group linter
  */
 final class ArcanistCSharpLinter extends ArcanistLinter {
 
@@ -27,8 +25,19 @@ final class ArcanistCSharpLinter extends ArcanistLinter {
   public function getLinterConfigurationOptions() {
     $options = parent::getLinterConfigurationOptions();
 
-    $options["discovery"] = 'map<string, list<string>>';
-    $options["binary"] = 'string';
+    $options['discovery'] = array(
+      'type' => 'map<string, list<string>>',
+      'help' => pht('Provide a discovery map.'),
+    );
+
+
+    // TODO: This should probably be replaced with "bin" when this moves
+    // to extend ExternalLinter.
+
+    $options['binary'] = array(
+      'type' => 'string',
+      'help' => pht('Override default binary.'),
+    );
 
     return $options;
   }
index d05fa219d3504a1a99afe7cd88261379e6aa383d..a1ea0b723155ff39e0ce39aa86c6182dfa345d05 100644 (file)
@@ -442,15 +442,33 @@ abstract class ArcanistExternalLinter extends ArcanistFutureLinter {
     }
   }
 
-
   public function getLinterConfigurationOptions() {
     $options = array(
-      'bin' => 'optional string | list<string>',
-      'flags' => 'optional list<string>',
+      'bin' => array(
+        'type' => 'optional string | list<string>',
+        'help' => pht(
+          'Specify a string (or list of strings) identifying the binary '.
+          'which should be invoked to execute this linter. This overrides '.
+          'the default binary. If you provide a list of possible binaries, '.
+          'the first one which exists will be used.')
+      ),
+      'flags' => array(
+        'type' => 'optional list<string>',
+        'help' => pht(
+          'Provide a list of additional flags to pass to the linter on the '.
+          'command line.'),
+      ),
     );
 
     if ($this->shouldUseInterpreter()) {
-      $options['interpreter'] = 'optional string | list<string>';
+      $options['interpreter'] = array(
+        'type' => 'optional string | list<string>',
+        'help' => pht(
+          'Specify a string (or list of strings) identifying the interpreter '.
+          'which should be used to invoke the linter binary. If you provide '.
+          'a list of possible interpreters, the first one that exists '.
+          'will be used.'),
+      );
     }
 
     return $options + parent::getLinterConfigurationOptions();
index 1315e3715f47133338b06bbc5cfdd48029b9665a..c267389eee9cb1f29328a4855c6b2e8aaab44502 100644 (file)
@@ -40,8 +40,17 @@ final class ArcanistLesscLinter extends ArcanistExternalLinter {
 
   public function getLinterConfigurationOptions() {
     return parent::getLinterConfigurationOptions() + array(
-      'lessc.strict-math' => 'optional bool',
-      'lessc.strict-units' => 'optional bool',
+      'lessc.strict-math' => array(
+        'type' => 'optional bool',
+        'help' => pht(
+          'Enable strict math, which only processes mathematical expressions '.
+          'inside extraneous parentheses.'),
+      ),
+      'lessc.strict-units' => array(
+        'type' => 'optional bool',
+        'help' => pht(
+          'Enable strict handling of units in expressions.'),
+      ),
     );
   }
 
index ae40eb9036bab4f7feb883cad2c812e7088786da..90d3b46b7a31738f2700bee62abfe48287249f12 100644 (file)
@@ -74,6 +74,7 @@ abstract class ArcanistLinter {
       get_class($this));
   }
 
+
   public function getLinterPriority() {
     return 1.0;
   }
@@ -360,8 +361,18 @@ abstract class ArcanistLinter {
     }
 
     return array(
-      'severity' => 'optional map<string|int, string>',
-      'severity.rules' => 'optional map<string, string>',
+      'severity' => array(
+        'type' => 'optional map<string|int, string>',
+        'help' => pht(
+          'Provide a map from lint codes to adjusted severity levels: error, '.
+          'warning, advice, autofix or disabled.')
+      ),
+      'severity.rules' => array(
+        'type' => 'optional map<string, string>',
+        'help' => pht(
+          'Provide a map of regular expressions to severity levels. All '.
+          'matching codes have their severity adjusted.'),
+      ),
     );
   }
 
index 1599a750d3bb08bf5d45962a5b4eedfabc4761d8..115f5bd5f53f0988eefb56ca6730693f9105db68 100644 (file)
@@ -33,7 +33,12 @@ final class ArcanistTextLinter extends ArcanistLinter {
 
   public function getLinterConfigurationOptions() {
     $options = array(
-      'text.max-line-length' => 'optional int',
+      'text.max-line-length' => array(
+        'type' => 'optional int',
+        'help' => pht(
+          'Adjust the maximum line length before a warning is raised. By '.
+          'default, a warning is raised on lines exceeding 80 characters.'),
+      ),
     );
 
     return $options + parent::getLinterConfigurationOptions();
index d96488c31e4f7285e249d51c1db7dbacf38b61ef..a2dc604c1b730f02ae45cedeb105c6365d2e7ebc 100644 (file)
@@ -26,7 +26,11 @@ EOTEXT
   }
 
   public function getArguments() {
-    return array();
+    return array(
+      'verbose' => array(
+        'help' => pht('Show detailed information, including options.'),
+      ),
+    );
   }
 
   public function run() {
@@ -77,6 +81,7 @@ EOTEXT
         'uri' => $linter->getInfoURI(),
         'description' => $linter->getInfoDescription(),
         'exception' => $exception,
+        'options' => $linter->getLinterConfigurationOptions(),
       );
     }
 
@@ -137,10 +142,44 @@ EOTEXT
         $print_tail = true;
       }
 
+      $options = $linter['options'];
+      if ($options && $this->getArgument('verbose')) {
+        $console->writeOut(
+          "\n%s**%s**\n\n",
+          $pad,
+          pht('Configuration Options'));
+
+        $last_option = last_key($options);
+        foreach ($options as $option => $option_spec) {
+          $console->writeOut(
+            "%s__%s__ (%s)\n",
+            $pad,
+            $option,
+            $option_spec['type']);
+
+          $console->writeOut(
+            "%s\n",
+            phutil_console_wrap(
+              $option_spec['help'],
+              strlen($pad) + 2));
+
+          if ($option != $last_option) {
+            $console->writeOut("\n");
+          }
+        }
+        $print_tail = true;
+      }
+
       if ($print_tail) {
         $console->writeOut("\n");
       }
     }
+
+    if (!$this->getArgument('verbose')) {
+      $console->writeOut(
+        "%s\n",
+        pht('(Run `arc linters --verbose` for more details.)'));
+    }
   }