Closed Bug 1448417 Opened 7 years ago Closed 6 years ago

[mozlint] Simplify include/exclude path filtering by removing glob support

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement, P3)

3 Branch
enhancement

Tracking

(firefox64 fixed)

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: ahal, Assigned: ahal)

References

Details

Attachments

(3 files)

I was overly ambitious when implementing the path filtering logic. Currently, this logic is affected by the 'include', 'exclude' and 'extensions' config options. In the former two, you can specify paths with either strings or globs: - path/to/dir - path/to/file - path/to/dir/* - path/to/dir/**/*.js Needless to say, the logic to support all of this is quite complicated: https://searchfox.org/mozilla-central/source/python/mozlint/mozlint/pathutils.py#73 It's gotten to the point where the complexity of how paths are handled is giving me pause when implementing new features for fear of breaking some obscure case. After some thought, I think we can get rid of the 'glob' patterns. Looking through our linters, the only time they are used is to limit files to extensions that are also specified in the 'extensions' key. So far no linters run on "test_*" for example. The only exception to this rule is that we exclude 'obj*' directly in the mach_commands.py. We'd need to figure out another way of excluding that. It's possible this feature *might* be useful in the future, but since it is causing unnecessary complexity, I'd like to remove it. We can always revisit adding it back in (or implementing something different) to solve our future needs.
Thinking about this it might be good to keep globs for exclude rules. They are useful for things like excluding all "node_modules" directories in the tree. But I can't think of any good reason to allow them in an include (and none of our existing linters use that feature anyway). So let's at least simplify logic around include directives.
Assignee: nobody → ahal
Status: NEW → ASSIGNED
This makes this test match all the other tests (which are named after the module they are testing). Also rename the test function to 'test_filterpaths'.
This makes things more explicit. Previously we were relying on those magic global "linters" variables, and it turned out that one of the tests was actually linting a completely different set of linters than I was expecting. This changes things so each test needs to explicitly define which linters it wants to use. Depends on D6410
Whiteboard: [leave-open]
Comment on attachment 9010682 [details] Bug 1448417 - [mozlint] Rename test_filterpaths.py to test_pathutils.py, r?rwood Robert Wood [:rwood] has approved the revision.
Attachment #9010682 - Flags: review+
Comment on attachment 9010684 [details] Bug 1448417 - [mozlint] Be explicit about which linters are used for functions in test_roller.py, r?rwood Robert Wood [:rwood] has approved the revision.
Attachment #9010684 - Flags: review+
Pushed by ahalberstadt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/545de0d5b961 [mozlint] Rename test_filterpaths.py to test_pathutils.py, r=rwood https://hg.mozilla.org/integration/autoland/rev/35c033207fa3 [mozlint] Be explicit about which linters are used for functions in test_roller.py, r=rwood
There is only a single linter (test-disable.yml) that uses a glob in any include path, and that usage is easily replaced by using the 'extensions' key instead. Since globs in include directives aren't very useful, let's disallow them. This will allow us to simplify the 'filterpaths' logic quite substantially and make future refactorings in this area easier.
Comment on attachment 9011850 [details] Bug 1448417 - [mozlint] Remove ability to specify globs in an 'include' directive, r?egao Edwin Gao ( :egao ) has approved the revision.
Attachment #9011850 - Flags: review+
Pushed by ahalberstadt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a80cb43e8d5e [mozlint] Remove ability to specify globs in an 'include' directive, r=egao
Whiteboard: [leave-open]
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Version: Version 3 → 3 Branch
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: