From 930b32a6b4d9b2bef445fd80b5b6f76bb238f735 Mon Sep 17 00:00:00 2001 From: Chris Piro Date: Tue, 25 Oct 2011 13:47:03 -0700 Subject: [PATCH] add 'lint.pylint.rcfile' option for ArcanistPyLintLinter 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 --- .../linter/pylint/ArcanistPyLintLinter.php | 18 +++++++++++++++++- src/lint/linter/pylint/__init__.php | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lint/linter/pylint/ArcanistPyLintLinter.php b/src/lint/linter/pylint/ArcanistPyLintLinter.php index fdc312ee..abce9aa6 100644 --- a/src/lint/linter/pylint/ArcanistPyLintLinter.php +++ b/src/lint/linter/pylint/ArcanistPyLintLinter.php @@ -32,6 +32,10 @@ * 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); diff --git a/src/lint/linter/pylint/__init__.php b/src/lint/linter/pylint/__init__.php index a4df923f..ad12effe 100644 --- a/src/lint/linter/pylint/__init__.php +++ b/src/lint/linter/pylint/__init__.php @@ -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');