This way linters that require it can be directly configured to be also run on
otherwise excluded thiry-party directories. Previously this was only possible
through the --include-third-party command line option.
Differential Revision: https://phabricator.services.mozilla.com/D290893
This check could cause false-positives, for example when using `jj fix` on a
patch in the stack that adds a new file but that's not currently applied to
the working directory.
Differential Revision: https://phabricator.services.mozilla.com/D278612
```
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `python/lldbutils/.ruff.toml`:
ruff-format (91) | - 'isort' -> 'lint.isort'
```
Differential Revision: https://phabricator.services.mozilla.com/D278037
This also adds some simple logging of exceptions raised from the sub-process. Whilst it doesn't cause the process to fail
it does at least mean the error is logged rather than thrown away.
Differential Revision: https://phabricator.services.mozilla.com/D263078
Some linters include source code as context, often with little ascii
arrows that point at the problem. This can be invaluable for figuring
out where the problem is.
We have an attribute to store this information in the `Issue` class, but
unfortunately none of the mozlint formatters display it!
This gets the default formatter to attempt displaying the source, with
some basic colorization. The colorization is dependent on the format of
each linter, so it may need to be adjusted as we add different linters.
Differential Revision: https://phabricator.services.mozilla.com/D257531
Make clippy a global linter. This means it only runs once per
workspace, which is good because `cargo` handles parallelization
internally. There's no reason to split things out into multiple commands.
Updated the global linter config handling to pass a list of files. This
is needed for clippy and we can just ignore them for the android lints.
Updated the clippy linter to work with crates outside of `gkrust`. For
these crates, we call `cargo clippy` directly and does not filter by
path name. These crates need to be listed in `tools/lint/clippy.yml`,
currently this is only `uniffi-bindgen-gecko-js`, but it's easy to add
more.
Fixed some lint warnings in the `mozlint` package itself.
Differential Revision: https://phabricator.services.mozilla.com/D246488
The pipelint tool was not working correctly on Windows for three reasons:
1. The module was being imported into every child process spawned by the
lint roller's multiprocessing executor. Because the import of
pipelint has side-effects (the actual running of mach lint on the
input), each child process would end up recursively triggering these
side-effects and causing exponential process growth until they all
eventually crashed.
To address this we now have the logic of the pipelint script behind a
`if __name__ == "__main__" guard.
2. We were keeping the file handle open before we called into mach,
which resulted in a permissions error trying to read from the file
handle after mach had finished.
To address this we now immediately close the file before invoking
`mach lint` and re-open it for reading after.
3. We were using default newline handling inside `pipelint` and
`mozlint`, which resulted in LFs being translated to CRLFs
automatically in all the intermediate temporary files.
To address this, we open files for reading and writing in binary mode
so that we deal directly with the underlying bytes instead of
particular interpretations of bytes (e.g., newlines, CP252 vs UTF-8),
including `stdin` (when reading file input from `jj`) and `stdout`
(when outputting the final formatted files).
Differential Revision: https://phabricator.services.mozilla.com/D244513
The pipelint tool was not working correctly on Windows for three reasons:
1. The module was being imported into every child process spawned by the
lint roller's multiprocessing executor. Because the import of
pipelint has side-effects (the actual running of mach lint on the
input), each child process would end up recursively triggering these
side-effects and causing exponential process growth until they all
eventually crashed.
To address this we now have the logic of the pipelint script behind a
`if __name__ == "__main__" guard.
2. We were keeping the file handle open before we called into mach,
which resulted in a permissions error trying to read from the file
handle after mach had finished.
To address this we now immediately close the file before invoking
`mach lint` and re-open it for reading after.
3. We were using default newline handling inside `pipelint` and
`mozlint`, which resulted in LFs being translated to CRLFs
automatically in all the intermediate temporary files.
To address this, we open files for reading and writing in binary mode
so that we deal directly with the underlying bytes instead of
particular interpretations of bytes (e.g., newlines, CP252 vs UTF-8),
including `stdin` (when reading file input from `jj`) and `stdout`
(when outputting the final formatted files).
Differential Revision: https://phabricator.services.mozilla.com/D244513
This allows `./mach lint` to be used with integrations that expect to
pass in file contents on stdin and get a fixed version of the file on
stdout.
Differential Revision: https://phabricator.services.mozilla.com/D236224
This ensures consistency in output between the parent and subprocess. It
also adjusts the formatting by log level, so we only get the more
detailed format when `--verbose` is enabled.
Differential Revision: https://phabricator.services.mozilla.com/D236252
Under the old logic, if a linter has a file directly in its include config, e.g:
```
include: [path/to/some/file.py]
```
Then it would always get linted, even if the user never specified it on
the cli. This is a bug.
Differential Revision: https://phabricator.services.mozilla.com/D236251
On Windows, paths provided to FileFinder may contain backslashes, which
will cause uses of `mozpath.match` later on to fail when they try to
compare mixed-path values. To avoid this, normalize those paths on
receipt.
(Also, silence a lint by pulling the global `args` variable into a
function, so that it is no longer occluded by the various function
parameters named `args`.)
Differential Revision: https://phabricator.services.mozilla.com/D194448
On Windows, paths provided to FileFinder may contain backslashes, which
will cause uses of `mozpath.match` later on to fail when they try to
compare mixed-path values. To avoid this, normalize those paths on
receipt.
(Also, silence a lint by pulling the global `args` variable into a
function, so that it is no longer occluded by the various function
parameters named `args`.)
Differential Revision: https://phabricator.services.mozilla.com/D194448