Bug 1494069 - [mozlint] Properly exclude files in LineType linters, r=rwood
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 16 Oct 2018 21:04:14 +0000
changeset 500143 3cbd82a01bc27518e21aae6668292c0b6f25802b
parent 500142 fbd19192e4fc1e66c4eefaede7d356fdd8627285
child 500144 9c587734513ad0366938cb19b378aaa15b28d209
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1494069
milestone64.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 1494069 - [mozlint] Properly exclude files in LineType linters, r=rwood This fixes a latent bug that is currently not being hit (by sheer luck). Basically the 'ignore' argument of a FileFinder object needs all paths to be relative to the base. As luck would have it, most of the time it worked out that way if you were running |mach lint| from the root of the repo. However there are edge cases where this will cause an 'exclude' directive to get missed. Plus this bug is about to be exposed 100% of the time in the next commit :). Depends on D8842 Differential Revision: https://phabricator.services.mozilla.com/D8843
python/mozlint/mozlint/types.py
--- a/python/mozlint/mozlint/types.py
+++ b/python/mozlint/mozlint/types.py
@@ -66,18 +66,20 @@ class LineType(BaseType):
         pass
 
     def _lint_dir(self, path, config, **lintargs):
         if not config.get('extensions'):
             patterns = ['**']
         else:
             patterns = ['**/*.{}'.format(e) for e in config['extensions']]
 
+        exclude = [os.path.relpath(e, path) for e in lintargs.get('exclude', [])]
+        finder = FileFinder(path, ignore=exclude)
+
         errors = []
-        finder = FileFinder(path, ignore=lintargs.get('exclude', []))
         for pattern in patterns:
             for p, f in finder.find(pattern):
                 errors.extend(self._lint(os.path.join(path, p), config, **lintargs))
         return errors
 
     def _lint(self, path, config, **lintargs):
         if os.path.isdir(path):
             return self._lint_dir(path, config, **lintargs)