Skip to content

feat(lint): add buildifier linting for Starlark files - #1255

Closed
LittleHuba wants to merge 11 commits into
mainfrom
spike/buildifier-rules-lint
Closed

LittleHuba wants to merge 11 commits into
mainfrom
spike/buildifier-rules-lint

Conversation

@LittleHuba

Copy link
Copy Markdown
Contributor

Summary

Adds buildifier linting for all Starlark files without any per-BUILD wiring.

  • bazel run //:buildifier.check|fix -- [patterns]: same entry points as ruff/clang-tidy; accepts //pkg, //pkg:target, //pkg/... and - exclusions (default //...). Resolved by tools/lint/buildifier_files.py (unit-tested).
  • //:buildifier_test: gating test, part of bazel test //....
  • //tools/lint:buildifier_sarif: converts findings to SARIF and exits non-zero on findings.
  • New buildifier CI job: uploads SARIF to Code Scanning (category buildifier) and as an artifact, then fails on findings.
  • Docs: quality/quality.md, CI.md, release template.

Known limitations

No --config=buildifier and no hold-the-line (buildifier is not run through a rules_lint aspect, which cannot cover BUILD files).

Note

Existing findings (~124) are intentionally not fixed in this PR, so the failing path of the CI job (SARIF upload + job failure) can be verified. Fixes will follow in a separate change before this is enforced.

LittleHuba and others added 2 commits October 2, 2026 17:13
Add //:buildifier.check and //:buildifier.fix, which accept Bazel-style
package patterns (including `-` exclusions) like the other linters, and a
gating //:buildifier_test. A dedicated CI job converts the findings to SARIF
(//tools/lint:buildifier_sarif), uploads them to Code Scanning and fails on
findings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

import io
import json
import unittest
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

LittleHuba and others added 8 commits October 2, 2026 19:00
With --format=json buildifier exits 0 and flags syntax errors (valid=false)
and unformatted files (formatted=false) without any warning entry, so they
were missing from the SARIF output and could not fail the job. Report them
as syntax-error/reformat results and treat all findings as errors, as
buildifier has no severity levels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Result of `bazel run //:buildifier.fix`: formatting and auto-fixable lint
findings (explicit loads of native rules, unused and unsorted loads).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ing)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…cstring)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…n-docstring-args)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prefix the required but unused parameters of the transition and module
extension implementations with an underscore. rust_unit_test accepted
target_compatible_with but silently ignored it; forward it to the public
test like cc_unit_test does.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… external-path)

The coverage aspect deliberately filters out files from external
repositories by their path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nonical-repository)

- coverage_scope: detect main-repository labels via Label.repo_name instead
  of matching the canonical string prefix.
- message_passing and score_baselibs_stub: derive the canonical unit scope
  with package_relative_label instead of hardcoding "@@..." names. The
  resulting scope strings are unchanged.
- rustfmt wrapper: rename the template placeholders so they no longer look
  like canonical labels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@LittleHuba
LittleHuba force-pushed the spike/buildifier-rules-lint branch from b3bac50 to d5ae1b8 Compare October 2, 2026 18:00

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoe-jo this should probably be done by rules_score itself.
I would consider this only a temporary fix here until this is fixed upstream.

@LittleHuba
LittleHuba marked this pull request as ready for review October 2, 2026 18:03
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@limdor limdor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a lot of different changes in different parts of the code. To get the attention that it deserve, I would like we split at least the PR in 2, one for fixing the issues found by buildifier, and one for adding the job and the scripts for the run.

@LittleHuba

Copy link
Copy Markdown
Contributor Author

Closing in favor of the split PRs: #1271, #1272, #1273, #1274 and #1275

@LittleHuba LittleHuba closed this Oct 5, 2026
@LittleHuba
LittleHuba deleted the spike/buildifier-rules-lint branch October 5, 2026 07:56
NemanjaTrifunovicRTRK pushed a commit to NemanjaTrifunovicRTRK/communication that referenced this pull request Oct 5, 2026
Mechanical buildifier autofixes (formatting, unused/sorted loads,
including unused rules_score loads). No functional change. Split out of
eclipse-score#1255.
etas-contrib-automation Bot pushed a commit to etas-contrib/score_communication that referenced this pull request Oct 5, 2026
…ipse-score#1273)

Adds missing module/function/argument docstrings and moves load
statements below the license header. Stacked on the autofix PR (base:
split/2-buildifier-autofixes); retarget to main after it merges. Split
out of eclipse-score#1255.
etas-contrib-automation Bot pushed a commit to etas-contrib/score_communication that referenced this pull request Oct 5, 2026
…score#1274)

Replaces hardcoded canonical labels (`@@//...`,
`@@score_baselibs+//...`) in rules_score unit scopes with apparent names
(buildifier `canonical-repository`). Split out of eclipse-score#1255.
prabakaranklst pushed a commit to qorix-group/communication that referenced this pull request Oct 21, 2026
Resolves unused variables, documents intentional external-path findings,
and removes hardcoded canonical names in coverage_scope and the rustfmt
wrapper. Split out of eclipse-score#1255.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants