Closed Bug 2023410 Opened 2 months ago Closed 1 month ago

mozlint: allow some linters to be written in Rust

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement)

enhancement

Tracking

(firefox152 fixed)

RESOLVED FIXED
152 Branch
Tracking Status
firefox152 --- fixed

People

(Reporter: Sylvestre, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

Attachments

(5 files, 3 obsolete files)

python isn't great when we have linters that needs to run on the full code base. Rust would be much better here.

Blocks: 2023411

A new in-tree Rust binary (tools/lint/moz-linter/) that provides fast,
parallelized implementations of simple mozlint linters. This commit adds
the project setup and shared JSONL output infrastructure.

Add RustType to supported_types. It locates the moz-linter binary,
serializes linter config as JSON, and invokes the batch subcommand.
This eliminates the need for per-linter Python wrappers.

Adds a linux64 toolchain task that builds moz-linter as a static musl
binary. Updates the rejected-words, file-perm, file-whitespace, and
trojan-source mozlint CI tasks to fetch the pre-built binary.

Attachment #9553494 - Attachment description: WIP: Bug 2023410 - Add moz-linter Rust crate skeleton with batch mode → Bug 2023410 - Add moz-linter Rust crate skeleton with batch mode r?#linter-reviewers
Attachment #9553496 - Attachment description: WIP: Bug 2023410 - Add type:rust linter support to mozlint → Bug 2023410 - Add type:rust linter support to mozlint r?#linter-reviewers
Attachment #9553503 - Attachment description: WIP: Bug 2023410 - Add moz-linter CI toolchain task and fetch it in lint jobs → Bug 2023410 - Add moz-linter CI toolchain task and fetch it in lint jobs r?#linter-reviewers
Attachment #9554827 - Attachment description: WIP: Bug 2023410 - mozlint/clippy: add moz-linter to the list → Bug 2023410 - mozlint/clippy: add moz-linter to the list r?#linter-reviewers

The module-level results list was never cleared between test runs,
causing results from test_lint_codespell_fix to leak into
test_lint_codespell.

Comment on attachment 9556069 [details]
Bug 2023410 - Fix codespell test leak: clear module-level state at start of lint() r?#linter-reviewers

Revision D289076 was moved to bug 2023756. Setting attachment 9556069 [details] to obsolete.

Attachment #9556069 - Attachment is obsolete: true
Attachment #9554827 - Attachment is obsolete: true
Attachment #9556068 - Attachment is obsolete: true
Attachment #9553494 - Attachment description: Bug 2023410 - Add moz-linter Rust crate skeleton with batch mode r?#linter-reviewers → Bug 2023410 - Add mozcheck Rust crate skeleton with batch mode r?#linter-reviewers
Attachment #9553496 - Attachment is obsolete: true
Attachment #9553496 - Attachment is obsolete: false
Attachment #9553496 - Attachment description: Bug 2023410 - Add type:rust linter support to mozlint r?#linter-reviewers → Bug 2023410 - Add rust linter support to mozlint r?#linter-reviewers

Python 3.13's pkgutil.resolve_name rejects hyphenated module names
like "condprof-addons" when passed as a string to mock.patch.multiple.
Use a lazy import to pass the module object directly instead.

Pushed by asilaghi@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9cd1694cc6ab https://hg.mozilla.org/integration/autoland/rev/ddb443dbda7c Revert "Bug 2023410, Bug 2023411 - Add moz-linter CI toolchain task and fetch it in lint jobs r=linter-reviewers,sergesanspaille" for causing lint failures

Addresses review comments from ahal on D288082:

  • The batch mode can emit multiple fixed-summary lines, so accumulate
    into the running total instead of overwriting it.
  • Replace the SKIP_KEYS allow-list with a dedicated check-config YAML
    key so extra fields can't drift when new top-level keys are added.
    Migrate rejected-words.yml and file-perm.yml to the new shape.
Pushed by sledru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d58507b4e338 https://hg.mozilla.org/integration/autoland/rev/d837bb4851d1 Add mozcheck Rust crate skeleton with batch mode r=linter-reviewers,ahal https://github.com/mozilla-firefox/firefox/commit/f6877d824f39 https://hg.mozilla.org/integration/autoland/rev/12114988264a Add rust linter support to mozlint r=linter-reviewers,ahal https://github.com/mozilla-firefox/firefox/commit/fb6af1bc91c1 https://hg.mozilla.org/integration/autoland/rev/fa853673fe27 Add moz-linter CI toolchain task and fetch it in lint jobs r=linter-reviewers,sergesanspaille https://github.com/mozilla-firefox/firefox/commit/ca172699cb12 https://hg.mozilla.org/integration/autoland/rev/6571d9f20e55 Fix test_condprof_addons for Python 3.13 compatibility r=linter-reviewers,sergesanspaille,ahal
Pushed by sledru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/df1645ea9f80 https://hg.mozilla.org/integration/autoland/rev/fd6d5227d6c4 Follow-up: accumulate fixed count and read extra config from check-config key r=linter-reviewers,ahal DONTBUILD
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: