]> khamidou — GitHub mirrors - arcanist.git/commitdiff
add 'lint.pylint.rcfile' option for ArcanistPyLintLinter
authorChris Piro <cpiro@airtime.com>
Tue, 25 Oct 2011 20:47:03 +0000 (13:47 -0700)
committerepriestley <git@epriestley.com>
Tue, 25 Oct 2011 20:47:03 +0000 (13:47 -0700)
Summary: add the ability to specify an rcfile path either absolute or relative
to the project root.

Test Plan: added one for a project, ran ##arc lint --trace## to see the expected
result

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley
Differential Revision: 1046

src/lint/linter/pylint/ArcanistPyLintLinter.php
src/lint/linter/pylint/__init__.php

index fdc312ee79714ab326bebd7af8480c0a59e9e2c9..abce9aa60a7f666bdfab293b3ac044b4237d9323 100644 (file)
  * You can specify additional command-line options to pass to PyLint by
  * setting ##lint.pylint.options##.
 
+ * If you have a PyLint rcfile, specify its path with
+ * ##lint.pylint.rcfile##. It can be absolute or relative to the project
+ * root. Be sure not to define ##output-format##, or if you do, set it to
+ * ##text##.
  *
  * Specify which PyLint messages map to which Arcanist messages by defining
  * the following regular expressions:
@@ -156,8 +160,20 @@ class ArcanistPyLintLinter extends ArcanistLinter {
     // '-iy': show message codes for lint warnings/errors
     $options = array('-rn',  '-iy');
 
-    // Add any options defined in the config file for PyLint
     $working_copy = $this->getEngine()->getWorkingCopy();
+
+    // Specify an --rcfile, either absolute or relative to the project root.
+    // Stupidly, the command line args above are overridden by rcfile, so be
+    // careful.
+    $rcfile = $working_copy->getConfig('lint.pylint.rcfile');
+    if ($rcfile !== null) {
+      $rcfile = Filesystem::resolvePath(
+                   $rcfile,
+                   $working_copy->getProjectRoot());
+      $options[] = csprintf('--rcfile=%s', $rcfile);
+    }
+
+    // Add any options defined in the config file for PyLint
     $config_options = $working_copy->getConfig('lint.pylint.options');
     if ($config_options !== null) {
       $options = array_merge($options, $config_options);
index a4df923f461e818e20187550fcdf2799a7735fc1..ad12effe47a9fac9d44ae3c5ebb29dde757af624 100644 (file)
@@ -13,6 +13,7 @@ phutil_require_module('arcanist', 'lint/severity');
 
 phutil_require_module('phutil', 'filesystem');
 phutil_require_module('phutil', 'future/exec');
+phutil_require_module('phutil', 'xsprintf/csprintf');
 
 
 phutil_require_source('ArcanistPyLintLinter.php');