You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See [Formatting](./docs/formatting.md) for more ways to use the formatter, such as a pre-commit hook or a CI check.
103
+
See [Formatting](./docs/formatting.md) for more ways to use the formatter.
132
104
133
105
### Lint
134
106
135
-
To lint code, we recommend using the Aspect CLI to get the missing `lint` command.
107
+
To lint code, we recommend using the [Aspect CLI] to get the missing `lint` command, and [Aspect Workflows] to provide first-class support for "linters as code reviewers".
136
108
137
109
For example, running `bazel lint //src:all` prints lint warnings to the terminal for all targets in the `//src` package:
Copy file name to clipboardExpand all lines: docs/linting.md
+25-6Lines changed: 25 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,32 @@ Finally, register those linter aspects in the lint runner. See details below.
18
18
19
19
## Usage
20
20
21
-
### 1. (Coming Soon) Linter as Code Review Bot
21
+
### 1. Linter as Code Review Bot
22
22
23
-
An upcoming release of [Aspect Workflows](https://docs.aspect.build/workflows/) will include a `lint` task, which wires the reports from bazel-out directly into your code review.
23
+
[Aspect Workflows] includes a `lint` task, which wires the reports from bazel-out directly into your code review.
24
24
The fixes produced by the tool are shown as suggested edits, so you can just accept without a context-switch back to your development machine.
25
25
26
26

27
27
28
+
We recommend this workflow for several reasons:
29
+
30
+
1. Forcing engineers to fix lint violations on code they're still iterating is a waste of time.
31
+
Code review is the right time to consider whether the code changes meet your teams quality bar.
32
+
2. Code review has at least two parties, which means that comments aren't simply ignored.
33
+
The reviewer has to agree with the author whether a suggested lint violation should be corrected.
34
+
Compare this with the usual complaint "developers just ignore warnings" - that's because the warnings were presented in their local build.
35
+
3. Adding a new linter (or adjusting its configuration to be stricter) doesn't require that you fix or suppress all existing warnings in the repository.
36
+
This makes it more feasible for an enthusiastic engineer to setup a linter, without having the burden of "making it green" on all existing code.
37
+
4. Linters shouldn't be required to have zero false-positives. Some lint checks are quite valuable when they detect a problem, but cannot always avoid overdetection.
38
+
Since code review comments are always subject to human review, it's the right time to evaluate the suggestions and ignore those which don't make sense.
39
+
5. This is how Google does it, in the [Tricorder] tool that's integrated into code review (Critique) to present static analysis results.
40
+
With [Aspect Workflows] we've provided a similar experience.
Aspect CLI adds the missing 'lint' command, so users just type `bazel lint //path/to:targets`.
46
+
[Aspect CLI] adds the missing 'lint' command, so users just type `bazel lint //path/to:targets`.
31
47
32
48
Reports are then written to the terminal.
33
49
@@ -45,9 +61,9 @@ lint:
45
61
46
62
### 3. Warnings in the terminal with a wrapper
47
63
48
-
If you don't use Aspect CLI, you can use vanilla Bazel with some wrapper like a shell script that runs the linter aspects over the requested targets.
64
+
If you don't use [Aspect CLI], you can use vanilla Bazel with some wrapper like a shell script that runs the linter aspects over the requested targets.
49
65
50
-
See the `example/lint.sh` file as an example.
66
+
See the `example/lint.sh` file as an example, and pay attention to the comments at the top about fitting it into your repo.
0 commit comments