Skip to content

Commit

Permalink
Added support for noclippy tag
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Jul 10, 2021
1 parent 0c74f0e commit da84aa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/rust_clippy.vm
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ build --output_groups=+clippy_checks
```

This will enable clippy on all [Rust targets](./defs.md).

Note that targets tagged with `noclippy` will not perform clippy checks
9 changes: 7 additions & 2 deletions rust/private/clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ load(
)
load("//rust/private:utils.bzl", "determine_output_hash", "find_cc_toolchain", "find_toolchain")

def _get_clippy_ready_crate_info(target):
def _get_clippy_ready_crate_info(target, aspect_ctx):
"""Check that a target is suitable for clippy and extract the `CrateInfo` provider from it.
Args:
target (Target): The target the aspect is running on.
aspect_ctx (ctx, optional): The aspect's context object.
Returns:
CrateInfo, optional: A `CrateInfo` provider if clippy should be run or `None`.
Expand All @@ -37,14 +38,18 @@ def _get_clippy_ready_crate_info(target):
if target.label.workspace_root.startswith("external"):
return None

# Targets annotated with `noclippy` will not be formatted
if aspect_ctx and "noclippy" in aspect_ctx.rule.attr.tags:
return None

# Obviously ignore any targets that don't contain `CrateInfo`
if rust_common.crate_info not in target:
return None

return target[rust_common.crate_info]

def _clippy_aspect_impl(target, ctx):
crate_info = _get_clippy_ready_crate_info(target)
crate_info = _get_clippy_ready_crate_info(target, ctx)
if not crate_info:
return []

Expand Down

0 comments on commit da84aa2

Please sign in to comment.