Skip to content

Commit 403437e

Browse files
authored
docs: explain limitation of new-from-rev and new-from-patch (#4377)
1 parent bf5008a commit 403437e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/src/docs/usage/faq.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,27 @@ Or you can create a [GitHub Issue](https://github.com/golangci/golangci-lint/iss
99

1010
## How to integrate `golangci-lint` into large project with thousands of issues
1111

12-
We are sure that every project can easily integrate `golangci-lint`, even the large one. The idea is to not fix all existing issues. Fix only newly added issue: issues in new code. To do this setup CI to run `golangci-lint` with option `--new-from-rev=HEAD~1`. Also, take a look at option `--new`, but consider that CI scripts that generate unstaged files will make `--new` only point out issues in those files and not in the last commit. In that regard `--new-from-rev=HEAD~1` is safer.
12+
We are sure that every project can easily integrate `golangci-lint`, even the large one.
13+
14+
The idea is to not fix all existing issues. Fix only newly added issue: issues in new code.
15+
To do this setup CI to run `golangci-lint` with option `--new-from-rev=HEAD~1`.
16+
17+
Also, take a look at option `--new`, but consider that CI scripts that generate unstaged files will make `--new` only point out issues in those files and not in the last commit.
18+
In that regard `--new-from-rev=HEAD~1` is safer.
19+
1320
By doing this you won't create new issues in your code and can choose fix existing issues (or not).
1421

22+
## Why `--new-from-rev` or `--new-from-patch` don't seem to be working in some cases?
23+
24+
The options `--new-from-rev` and `--new-from-patch` work by comparing `git diff` output and issues.
25+
26+
If an issue is not reported as the same line as the changes then the issue will be skipped.
27+
This is the line of the issue is not inside the lines changed.
28+
29+
To fix that you have to use the option `--whole-files`.
30+
31+
The side effect is the issues inside file that contains changes but not directly related to the changes themselves will be reported.
32+
1533
## How to use `golangci-lint` in CI
1634

1735
Run `golangci-lint` in CI and check the exit code. If it's non-zero - fail the build.

0 commit comments

Comments
 (0)