Skip to content

Commit ef44e11

Browse files
authored
Merge branch 'master' into asb/nolintlint-internal
2 parents 909f628 + 224515a commit ef44e11

File tree

12 files changed

+101
-30
lines changed

12 files changed

+101
-30
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ There is the most valuable changes log:
33

44
### April 2020
55

6-
1. Add new linters: `testpackage`, `nestif`, `godot`, `gomodguard`
6+
1. Add new linters: `testpackage`, `nestif`, `godot`, `gomodguard`, `asciicheck`
77
2. Add github actions output format
8-
3. Update linters: `wsl`
8+
3. Update linters: `wsl`, `gomodguard`, `gosec`
99
4. Support `disabled-tags` setting for `gocritic`
1010
5. Mitigate OOM and "failed prerequisites"
1111
6. Self-isolate due to unexpected pandemics
12+
7. Support case-sensitive excludes
13+
8. Allow granular re-enabling excludes by ID, e.g. `EXC0002`
1214

1315
### September 2019
1416

README.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ use deprecated option `--enable-all` and a new linter is added or even without `
7373

7474
It's highly recommended to install a specific version of golangci-lint available on the [releases page](https://github.com/golangci/golangci-lint/releases).
7575

76-
Here is the recommended way to install golangci-lint v1.25.0:
76+
Here is the recommended way to install golangci-lint v1.25.1:
7777

7878
```bash
7979
# binary will be $(go env GOPATH)/bin/golangci-lint
80-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.25.0
80+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.25.1
8181

8282
# or install it into ./bin/
83-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.25.0
83+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.25.1
8484

8585
# In alpine linux (as it does not come with curl by default)
86-
wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.25.0
86+
wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.25.1
8787

8888
golangci-lint --version
8989
```
@@ -103,15 +103,15 @@ brew upgrade golangci/tap/golangci-lint
103103
### Docker
104104

105105
```bash
106-
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.25.0 golangci-lint run -v
106+
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.25.1 golangci-lint run -v
107107
```
108108

109109
### Go
110110

111111
Go source installations are supported for the two most recent Go releases.
112112

113113
```bash
114-
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.25.0
114+
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.25.1
115115
```
116116

117117
## Trusted By
@@ -218,6 +218,7 @@ gocritic: The most opinionated Go source code linter [fast: true, auto-fix: fals
218218
gocyclo: Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
219219
godot: Check if comments end in a period [fast: true, auto-fix: false]
220220
godox: Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
221+
goerr113: Golang linter to check the errors handling expressions [fast: true, auto-fix: false]
221222
gofmt: Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
222223
goimports: Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true]
223224
golint: Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: true, auto-fix: false]
@@ -493,6 +494,7 @@ golangci-lint help linters
493494
- [wsl](https://github.com/bombsimon/wsl) - Whitespace Linter - Forces you to use empty lines!
494495
- [goprintffuncname](https://github.com/jirfag/go-printf-func-name) - Checks that printf-like functions are named with `f` at the end
495496
- [gomnd](https://github.com/tommy-muehle/go-mnd) - An analyzer to detect magic numbers.
497+
- [goerr113](https://github.com/Djarvur/go-err113) - Golang linter to check the errors handling expressions
496498
- [gomodguard](https://github.com/ryancurrah/gomodguard) - Allow and block list linter for direct Go module dependencies.
497499
- [godot](https://github.com/tetafro/godot) - Check if comments end in a period
498500
- [testpackage](https://github.com/maratori/testpackage) - linter that makes you use a separate _test package
@@ -570,7 +572,7 @@ Flags:
570572
- Subprocess launch(ed with variable|ing should be audited)
571573
572574
# EXC0008 gosec: Duplicated errcheck checks
573-
- G104
575+
- (G104|G307)
574576
575577
# EXC0009 gosec: Too many issues in popular repos
576578
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
@@ -1313,6 +1315,7 @@ Thanks to developers and authors of used linters:
13131315
- [bombsimon](https://github.com/bombsimon)
13141316
- [jirfag](https://github.com/jirfag)
13151317
- [tommy-muehle](https://github.com/tommy-muehle)
1318+
- [Djarvur](https://github.com/Djarvur)
13161319
- [ryancurrah](https://github.com/ryancurrah)
13171320
- [tetafro](https://github.com/tetafro)
13181321
- [maratori](https://github.com/maratori)
@@ -1326,12 +1329,14 @@ There is the most valuable changes log:
13261329
13271330
### April 2020
13281331
1329-
1. Add new linters: `testpackage`, `nestif`, `godot`, `gomodguard`
1332+
1. Add new linters: `testpackage`, `nestif`, `godot`, `gomodguard`, `asciicheck`
13301333
2. Add github actions output format
1331-
3. Update linters: `wsl`
1334+
3. Update linters: `wsl`, `gomodguard`, `gosec`
13321335
4. Support `disabled-tags` setting for `gocritic`
13331336
5. Mitigate OOM and "failed prerequisites"
13341337
6. Self-isolate due to unexpected pandemics
1338+
7. Support case-sensitive excludes
1339+
8. Allow granular re-enabling excludes by ID, e.g. `EXC0002`
13351340
13361341
### September 2019
13371342

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/golangci/golangci-lint
33
go 1.12
44

55
require (
6+
github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157
67
github.com/OpenPeeDeeP/depguard v1.0.1
78
github.com/bombsimon/wsl/v3 v3.0.0
89
github.com/fatih/color v1.7.0
@@ -33,7 +34,7 @@ require (
3334
github.com/nakabonne/nestif v0.3.0
3435
github.com/pkg/errors v0.8.1
3536
github.com/ryancurrah/gomodguard v1.0.4
36-
github.com/securego/gosec v0.0.0-20200103095621-79fbf3af8d83
37+
github.com/securego/gosec v0.0.0-20200316084457-7da9f46445fd
3738
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada // v2.19.8
3839
github.com/sirupsen/logrus v1.4.2
3940
github.com/sourcegraph/go-diff v0.5.1

go.sum

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
33
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4+
github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157 h1:hY39LwQHh+1kaovmIjOrlqnXNX6tygSRfLkkK33IkZU=
5+
github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
46
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
57
github.com/OpenPeeDeeP/depguard v1.0.1 h1:VlW4R6jmBIv3/u1JNlawEvJMM4J+dPORPaZasQee8Us=
68
github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM=
@@ -184,7 +186,7 @@ github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b h1:9+ke9YJ9KGWw5AN
184186
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk=
185187
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
186188
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
187-
github.com/mozilla/tls-observatory v0.0.0-20190404164649-a3c1b6cfecfd/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
189+
github.com/mozilla/tls-observatory v0.0.0-20200220173314-aae45faa4006/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk=
188190
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
189191
github.com/nakabonne/nestif v0.3.0 h1:+yOViDGhg8ygGrmII72nV9B/zGxY188TYpfolntsaPw=
190192
github.com/nakabonne/nestif v0.3.0/go.mod h1:dI314BppzXjJ4HsCnbo7XzrJHPszZsjnk5wEBSYHI2c=
@@ -194,10 +196,11 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
194196
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
195197
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
196198
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
197-
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
198-
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
199-
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
200-
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
199+
github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
200+
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
201+
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
202+
github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg=
203+
github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
201204
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
202205
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
203206
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
@@ -223,8 +226,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
223226
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
224227
github.com/ryancurrah/gomodguard v1.0.4 h1:oCreMAt9GuFXDe9jW4HBpc3GjdX3R/sUEcLAGh1zPx8=
225228
github.com/ryancurrah/gomodguard v1.0.4/go.mod h1:9T/Cfuxs5StfsocWr4WzDL36HqnX0fVb9d5fSEaLhoE=
226-
github.com/securego/gosec v0.0.0-20200103095621-79fbf3af8d83 h1:AtnWoOvTioyDXFvu96MWEeE8qj4COSQnJogzLy/u41A=
227-
github.com/securego/gosec v0.0.0-20200103095621-79fbf3af8d83/go.mod h1:vvbZ2Ae7AzSq3/kywjUDxSNq2SJ27RxCz2un0H3ePqE=
229+
github.com/securego/gosec v0.0.0-20200316084457-7da9f46445fd h1:qB+l4fYZsH78xORC1aqVS0zNmgkQp4rkj2rvfxQMtzc=
230+
github.com/securego/gosec v0.0.0-20200316084457-7da9f46445fd/go.mod h1:NurAFZsWJAEZjogSwdVPlHkOZB3DOAU7gsPP8VFZCHc=
228231
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada h1:WokF3GuxBeL+n4Lk4Fa8v9mbdjlrl7bHuneF4N1bk2I=
229232
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
230233
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
@@ -295,6 +298,7 @@ github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOV
295298
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
296299
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
297300
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
301+
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
298302
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
299303
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
300304
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
@@ -307,6 +311,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
307311
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
308312
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
309313
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
314+
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
310315
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
311316
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
312317
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
@@ -343,8 +348,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
343348
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
344349
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
345350
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
346-
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLgaVbMHMn2ISQXJeJ5EM=
347-
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
351+
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA=
352+
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
348353
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
349354
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
350355
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
@@ -366,8 +371,9 @@ golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDq
366371
golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
367372
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
368373
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
369-
golang.org/x/tools v0.0.0-20200102140908-9497f49d5709 h1:AfG1EmoRkFK24HWWLxSrRKNg2G+oA3JVOG8GJsHWypQ=
370-
golang.org/x/tools v0.0.0-20200102140908-9497f49d5709/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
374+
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
375+
golang.org/x/tools v0.0.0-20200228224639-71482053b885/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
376+
golang.org/x/tools v0.0.0-20200324003944-a576cf524670/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
371377
golang.org/x/tools v0.0.0-20200414032229-332987a829c3/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
372378
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e h1:3Dzrrxi54Io7Aoyb0PYLsI47K2TxkRQg+cqUn+m04do=
373379
golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -402,8 +408,6 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
402408
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
403409
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
404410
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
405-
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
406-
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
407411
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
408412
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
409413
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var DefaultExcludePatterns = []ExcludePattern{
8383
},
8484
{
8585
ID: "EXC0008",
86-
Pattern: "G104",
86+
Pattern: "(G104|G307)",
8787
Linter: "gosec",
8888
Why: "Duplicated errcheck checks",
8989
},

pkg/golinters/goerr113.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package golinters
2+
3+
import (
4+
"github.com/Djarvur/go-err113"
5+
"golang.org/x/tools/go/analysis"
6+
7+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8+
)
9+
10+
func NewGoerr113() *goanalysis.Linter {
11+
return goanalysis.NewLinter(
12+
"goerr113",
13+
"Golang linter to check the errors handling expressions",
14+
[]*analysis.Analyzer{
15+
err113.NewAnalyzer(),
16+
},
17+
nil,
18+
).WithLoadMode(goanalysis.LoadModeTypesInfo)
19+
}

pkg/golinters/unused.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func NewUnused() *goanalysis.Linter {
3333
for _, ur := range u.Result() {
3434
p := u.ProblemObject(lintCtx.Packages[0].Fset, ur)
3535
pkg := typesToPkg[ur.Pkg()]
36-
issues = append(issues, goanalysis.NewIssue(&result.Issue{
36+
i := &result.Issue{
3737
FromLinter: name,
3838
Text: p.Message,
3939
Pos: p.Pos,
@@ -42,11 +42,16 @@ func NewUnused() *goanalysis.Linter {
4242
From: p.Pos.Line,
4343
To: p.End.Line,
4444
},
45-
Replacement: &result.Replacement{
45+
}
46+
// See https://github.com/golangci/golangci-lint/issues/1048
47+
// If range is invalid, this will break `--fix` mode.
48+
if i.LineRange.To >= i.LineRange.From {
49+
i.Replacement = &result.Replacement{
4650
// Suggest deleting unused stuff.
4751
NeedOnlyDelete: true,
48-
},
49-
}, nil))
52+
}
53+
}
54+
issues = append(issues, goanalysis.NewIssue(i, nil))
5055
}
5156
return issues
5257
}).WithContextSetter(func(lintCtx *linter.Context) {

pkg/lint/lintersdb/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
252252
linter.NewConfig(golinters.NewGoMND(m.cfg)).
253253
WithPresets(linter.PresetStyle).
254254
WithURL("https://github.com/tommy-muehle/go-mnd"),
255+
linter.NewConfig(golinters.NewGoerr113()).
256+
WithPresets(linter.PresetStyle).
257+
WithURL("https://github.com/Djarvur/go-err113"),
255258
linter.NewConfig(golinters.NewGomodguard()).
256259
WithPresets(linter.PresetStyle).
257260
WithLoadForGoAnalysis().

pkg/result/processors/fixer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ func (f Fixer) writeFixedFile(origFileLines [][]byte, issues []result.Issue, tmp
223223
} else {
224224
nextIssueIndex++
225225
rng := nextIssue.GetLineRange()
226+
if rng.From > rng.To {
227+
// Maybe better decision is to skip such issues, re-evaluate if regressed.
228+
f.log.Warnf("[fixer]: issue line range is probably invalid, fix can be incorrect (from=%d, to=%d, linter=%s)",
229+
rng.From, rng.To, nextIssue.FromLinter,
230+
)
231+
}
226232
i += rng.To - rng.From
227233
if nextIssue.Replacement.NeedOnlyDelete {
228234
continue

test/testdata/fix/in/unused.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//args: -Eunused
2+
package p
3+
4+
type (
5+
unused struct{}
6+
)
7+
8+
func X() {}

test/testdata/fix/out/unused.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//args: -Eunused
2+
package p
3+
4+
type (
5+
unused struct{}
6+
)
7+
8+
func X() {}

test/testdata/goerr113.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//args: -Egoerr113
2+
package testdata
3+
4+
func SimpleEqual(e1, e2 error) bool {
5+
return e1 == e2 // ERROR `err113: do not compare errors directly, use errors.Is() instead: "e1 == e2"`
6+
}
7+
8+
func SimpleNotEqual(e1, e2 error) bool {
9+
return e1 != e2 // ERROR `err113: do not compare errors directly, use errors.Is() instead: "e1 != e2"`
10+
}

0 commit comments

Comments
 (0)