aspect-build / aspect-build/rules_lint

[Bug]: 'aspect lint' with clang-tidy exits 0 on violations

Open
#857 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Starlark
Stars
154
Forks
125
Avg merge
3d 21h
Merged PRs (30d)
20

Description

### What happened?

Running `aspect lint` with clang-tidy does **not** exit non-zero when violations are found, even though `.clang-tidy` has `WarningsAsErrors: "*"` set (meaning clang-tidy itself should exit non-zero) and `--strategy hard` is passed.

Violations are printed/reported but the command exits 0.

I would expect that the command:
```bash
aspect lint --aspect=//third_party/lint:linters.bzl%clang_tidy --strategy hard --base-ref origin/main //...
```
shoud exit non-zero when clang-tidy reports violations.

I followed the `example` within the repo, but not all information from there align with the `docs`? So how to properly set it up for the latest version of `aspect cli` and `aspect_rules_lint`?

### Version

Development (host) and target OS/architectures:
Ubuntu 24.04

Output of `bazel --version`:
bazel 8.2.1

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
Aspect CLI: 2026.19.5
bazel_dep(name = "aspect_rules_lint", version = "2.5.2")

Language(s) and/or frameworks involved:
C++

### How to reproduce

`third_party/lint/linters.bzl`:
```
load("@aspect_rules_lint//lint:clang_tidy.bzl", "lint_clang_tidy_aspect")

clang_tidy = lint_clang_tidy_aspect(
binary = Label("//third_party/lint:clang_tidy"),
configs = [Label("//:clang_configs")],
angle_includes_are_system = False,
verbose = False,
)
```
`third_party/lint/BUILD.bazel`:
```
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

native_binary(
name = "clang_tidy",
src = "@llvm_toolchain//:bin/clang-tidy",
out = "clang_tidy",
)
```
`MODULE.bazel` (relevant excerpt):
```
bazel_dep(name = "aspect_rules_lint", version = "2.5.2")
bazel_dep(name = "toolchains_llvm", version = "1.7.0")

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
name = "llvm_toolchain",
llvm_version = "21.1.8",
)
use_repo(llvm, "llvm_toolchain")
```
`.clang-tidy`:
```
---
Checks: "
-*,
misc-const-correctness,
modernize-use-bool-literals,
modernize-use-nullptr,
readability-identifier-naming,
"
FormatStyle: file
WarningsAsErrors: "*"
HeaderFilterRegex: "^(apps|src|tools)/.*"
CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: lower_case
```
`.bazelrc` (relevant excerpt):
```
build:lint --aspects=//third_party/lint:linters.bzl%clang_tidy
```

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by running the documented `aspect lint` command and compare the reported clang-tidy violations with its exit status. Inspect `third_party/lint/linters.bzl`, `third_party/lint/BUILD.bazel`, `.clang-tidy`, and `.bazelrc` to trace how the clang-tidy result reaches Aspect CLI; done means violations cause a non-zero exit under `--strategy hard`.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.