Skip to content

Commit deb63b1

Browse files
committed
docs: update README after #320
1 parent e672537 commit deb63b1

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed

.golangci.example.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,39 @@ issues:
191191
exclude:
192192
- abcdef
193193

194+
# Excluding configuration per-path and per-linter
195+
exclude-rules:
196+
# Exclude some linters from running on tests files.
197+
- path: _test\.go
198+
linters:
199+
- gocyclo
200+
- errcheck
201+
- dupl
202+
- gosec
203+
204+
# Ease some gocritic warnings on test files.
205+
- path: _test\.go
206+
text: "(unnamedResult|exitAfterDefer)"
207+
linters:
208+
- gocritic
209+
210+
# Exclude known linters from partially hard-vendored code,
211+
# which is impossible to exclude via "nolint" comments.
212+
- path: internal/hmac/
213+
text: "weak cryptographic primitive"
214+
linters:
215+
- gosec
216+
- path: internal/hmac/
217+
text: "Write\\` is not checked"
218+
linters:
219+
- errcheck
220+
221+
# Ease linting on benchmarking code.
222+
- path: cmd/stun-bench/
223+
linters:
224+
- gosec
225+
- errcheck
226+
194227
# Independently from option `exclude` we use default exclude patterns,
195228
# it can be disabled by this option. To list all
196229
# excluded by default patterns execute `golangci-lint run --help`.

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ linters:
3737
disable:
3838
- maligned
3939
- prealloc
40-
- gosec
4140
- gochecknoglobals
4241

4342
run:
@@ -50,3 +49,9 @@ service:
5049
golangci-lint-version: 1.13.x # use fixed version to not introduce new linters unexpectedly
5150
prepare:
5251
- echo "here I can run custom commands, but no preparation needed"
52+
53+
issues:
54+
exclude-rules:
55+
- text: "weak cryptographic primitive"
56+
linters:
57+
- gosec

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,39 @@ issues:
715715
exclude:
716716
- abcdef
717717
718+
# Excluding configuration per-path and per-linter
719+
exclude-rules:
720+
# Exclude some linters from running on tests files.
721+
- path: _test\.go
722+
linters:
723+
- gocyclo
724+
- errcheck
725+
- dupl
726+
- gosec
727+
728+
# Ease some gocritic warnings on test files.
729+
- path: _test\.go
730+
text: "(unnamedResult|exitAfterDefer)"
731+
linters:
732+
- gocritic
733+
734+
# Exclude known linters from partially hard-vendored code,
735+
# which is impossible to exclude via "nolint" comments.
736+
- path: internal/hmac/
737+
text: "weak cryptographic primitive"
738+
linters:
739+
- gosec
740+
- path: internal/hmac/
741+
text: "Write\\` is not checked"
742+
linters:
743+
- errcheck
744+
745+
# Ease linting on benchmarking code.
746+
- path: cmd/stun-bench/
747+
linters:
748+
- gosec
749+
- errcheck
750+
718751
# Independently from option `exclude` we use default exclude patterns,
719752
# it can be disabled by this option. To list all
720753
# excluded by default patterns execute `golangci-lint run --help`.
@@ -785,7 +818,6 @@ linters:
785818
disable:
786819
- maligned
787820
- prealloc
788-
- gosec
789821
- gochecknoglobals
790822
791823
run:
@@ -798,17 +830,24 @@ service:
798830
golangci-lint-version: 1.13.x # use fixed version to not introduce new linters unexpectedly
799831
prepare:
800832
- echo "here I can run custom commands, but no preparation needed"
833+
834+
issues:
835+
exclude-rules:
836+
- text: "weak cryptographic primitive"
837+
linters:
838+
- gosec
801839
```
802840
803841
## False Positives
804842
805843
False positives are inevitable, but we did our best to reduce their count. For example, we have a default enabled set of [exclude patterns](#command-line-options). If a false positive occurred you have the following choices:
806844
807-
1. Exclude issue by text using command-line option `-e` or config option `issues.exclude`. It's helpful when you decided to ignore all issues of this type.
845+
1. Exclude issue by text using command-line option `-e` or config option `issues.exclude`. It's helpful when you decided to ignore all issues of this type. Also, you can use `issues.exclude-rules` config option for per-path or per-linter configuration.
808846
2. Exclude this one issue by using special comment `//nolint[:linter1,linter2,...]` on issued line.
809847
Comment `//nolint` disables all issues reporting on this line. Comment e.g. `//nolint:govet` disables only govet issues for this line.
810848
If you would like to completely exclude all issues for some function prepend this comment
811849
above function:
850+
3. Exclude issues in path by `run.skip-dirs`, `run.skip-files` or `issues.exclude-rules` config options.
812851
813852
```go
814853
//nolint

README.tmpl.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,12 @@ than the default and have more strict settings:
407407

408408
False positives are inevitable, but we did our best to reduce their count. For example, we have a default enabled set of [exclude patterns](#command-line-options). If a false positive occurred you have the following choices:
409409

410-
1. Exclude issue by text using command-line option `-e` or config option `issues.exclude`. It's helpful when you decided to ignore all issues of this type.
410+
1. Exclude issue by text using command-line option `-e` or config option `issues.exclude`. It's helpful when you decided to ignore all issues of this type. Also, you can use `issues.exclude-rules` config option for per-path or per-linter configuration.
411411
2. Exclude this one issue by using special comment `//nolint[:linter1,linter2,...]` on issued line.
412412
Comment `//nolint` disables all issues reporting on this line. Comment e.g. `//nolint:govet` disables only govet issues for this line.
413413
If you would like to completely exclude all issues for some function prepend this comment
414414
above function:
415+
3. Exclude issues in path by `run.skip-dirs`, `run.skip-files` or `issues.exclude-rules` config options.
415416

416417
```go
417418
//nolint

0 commit comments

Comments
 (0)