Bug 1530352, add lintargs to lint setup, r=ahal
authorAxel Hecht <axel@pike.org>
Tue, 05 Mar 2019 16:15:03 +0000
changeset 520259 d7643c689d07380b594ae798cd575e4e3caa9bd8
parent 520258 af0ecb4e1e695590b0dcd96cae7afa631912c046
child 520260 2ff1c636903d3f14e1c0aaf1fda56791033a27ea
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1530352
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530352, add lintargs to lint setup, r=ahal Differential Revision: https://phabricator.services.mozilla.com/D21010
python/mozlint/mozlint/roller.py
python/mozlint/test/linters/external.py
tools/lint/docs/create.rst
tools/lint/eslint/__init__.py
tools/lint/python/compat.py
tools/lint/python/flake8.py
--- a/python/mozlint/mozlint/roller.py
+++ b/python/mozlint/mozlint/roller.py
@@ -129,17 +129,17 @@ class LintRoller(object):
         if not self.linters:
             raise LintersNotConfigured
 
         for linter in self.linters:
             if 'setup' not in linter:
                 continue
 
             try:
-                res = findobject(linter['setup'])(self.root)
+                res = findobject(linter['setup'])(**self.lintargs)
             except Exception:
                 traceback.print_exc()
                 res = 1
 
             if res:
                 self.result.failed_setup.add(linter['name'])
 
         if self.result.failed_setup:
--- a/python/mozlint/test/linters/external.py
+++ b/python/mozlint/test/linters/external.py
@@ -55,20 +55,20 @@ def structured(files, config, logger, **
                                       column=1,
                                       rule="no-foobar")
 
 
 def passes(files, config, **lintargs):
     return []
 
 
-def setup(root):
+def setup(**lintargs):
     print('setup passed')
 
 
-def setupfailed(root):
+def setupfailed(**lintargs):
     print('setup failed')
     return 1
 
 
-def setupraised(root):
+def setupraised(**lintargs):
     print('setup raised')
     raise LintException('oh no setup failed')
--- a/tools/lint/docs/create.rst
+++ b/tools/lint/docs/create.rst
@@ -208,17 +208,17 @@ path object format as an external payloa
 The setup function takes a single argument, the root of the repository being
 linted. In the case of ``flake8``, it might look like:
 
 .. code-block:: python
 
     import subprocess
     from distutils.spawn import find_executable
 
-    def setup(root):
+    def setup(root, **lintargs):
         if not find_executable('flake8'):
             subprocess.call(['pip', 'install', 'flake8'])
 
 The setup function will be called implicitly before running the linter. This
 means it should return fast and not produce any output if there is no setup to
 be performed.
 
 The setup functions can also be called explicitly by running ``mach lint
--- a/tools/lint/eslint/__init__.py
+++ b/tools/lint/eslint/__init__.py
@@ -28,17 +28,17 @@ environment variable, and then at your l
 eslint and needed plugins with:
 
 mach eslint --setup
 
 and try again.
 """.strip()
 
 
-def setup(root):
+def setup(root, **lintargs):
     setup_helper.set_project_root(root)
 
     if not setup_helper.check_node_executables_valid():
         return 1
 
     return setup_helper.eslint_maybe_setup()
 
 
--- a/tools/lint/python/compat.py
+++ b/tools/lint/python/compat.py
@@ -68,22 +68,22 @@ def run_linter(python, paths, config, **
         try:
             proc.wait()
         except KeyboardInterrupt:
             proc.kill()
 
     return results
 
 
-def setuppy2(root):
+def setuppy2(**lintargs):
     return setup('python2')
 
 
 def lintpy2(*args, **kwargs):
     return run_linter('python2', *args, **kwargs)
 
 
-def setuppy3(root):
+def setuppy3(**lintargs):
     return setup('python3')
 
 
 def lintpy3(*args, **kwargs):
     return run_linter('python3', *args, **kwargs)
--- a/tools/lint/python/flake8.py
+++ b/tools/lint/python/flake8.py
@@ -65,17 +65,17 @@ else:
 
 
 class NothingToLint(Exception):
     """Exception used to bail out of flake8's internals if all the specified
     files were excluded.
     """
 
 
-def setup(root):
+def setup(root, **lintargs):
     if not pip.reinstall_program(FLAKE8_REQUIREMENTS_PATH):
         print(FLAKE8_INSTALL_ERROR)
         return 1
 
 
 def lint(paths, config, **lintargs):
     from flake8.main.application import Application