Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check target tags before ignore tags for lint/fmt aspects #2913

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions rust/private/clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ def _get_clippy_ready_crate_info(target, aspect_ctx = None):
# Targets with specific tags will not be formatted
if aspect_ctx:
ignore_tags = [
"no_clippy",
"no_lint",
"noclippy",
"no-clippy",
]

for tag in ignore_tags:
if tag in aspect_ctx.rule.attr.tags:
for tag in aspect_ctx.rule.attr.tags:
if tag.replace("-", "_").lower() in ignore_tags:
return None

# Obviously ignore any targets that don't contain `CrateInfo`
Expand Down Expand Up @@ -192,6 +192,7 @@ def _clippy_aspect_impl(target, ctx):
tools = [toolchain.clippy_driver],
arguments = args.all,
mnemonic = "Clippy",
progress_message = "Clippy %{label}",
toolchain = "@rules_rust//rust:toolchain_type",
)

Expand Down
9 changes: 5 additions & 4 deletions rust/private/rustfmt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ def _find_rustfmtable_srcs(crate_info, aspect_ctx = None):
# Targets with specific tags will not be formatted
if aspect_ctx:
ignore_tags = [
"no-format",
"no-rustfmt",
"no_format",
"no_rustfmt",
"norustfmt",
]

for tag in ignore_tags:
if tag in aspect_ctx.rule.attr.tags:
for tag in aspect_ctx.rule.attr.tags:
if tag.replace("-", "_").lower() in ignore_tags:
return []

# Filter out any generated files
Expand Down Expand Up @@ -92,6 +92,7 @@ def _perform_check(edition, srcs, ctx):
tools = [rustfmt_toolchain.all_files],
arguments = [args],
mnemonic = "Rustfmt",
progress_message = "Rustfmt %{label}",
)

return marker
Expand Down
Loading