diff --git a/.golangci.reference.yml b/.golangci.reference.yml
index 013c7c9779ac..121dfe152ef5 100644
--- a/.golangci.reference.yml
+++ b/.golangci.reference.yml
@@ -1372,6 +1372,8 @@ linters-settings:
- name: context-as-argument
severity: warning
disabled: false
+ arguments:
+ - allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
- name: context-keys-type
severity: warning
@@ -1906,7 +1908,7 @@ linters-settings:
# Allow multiple var/declaration statements to be cuddled.
allow-cuddle-declarations: false
- # Aa list of call idents that everything can be cuddled with.
+ # A list of call idents that everything can be cuddled with.
# Defaults to calls looking like locks.
allow-cuddle-with-calls: [ "Lock", "RLock" ]
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bcb3a24d039b..a7d0ad469d0e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,36 @@
Follow the news and releases on our [twitter](https://twitter.com/golangci) and our [blog](https://medium.com/golangci).
There is the most valuable changes log:
+### v1.50.0
+
+1. new linters
+ * `dupword`: https://github.com/Abirdcfly/dupword
+ * `testableexamples`: https://github.com/maratori/testableexamples
+2. updated linters
+ * `contextcheck`: change owner
+ * `contextcheck`: from 1.0.6 to 1.1.2
+ * `depguard`: from 1.1.0 to 1.1.1
+ * `exhaustive`: add missing config
+ * `exhaustive`: from 0.8.1 to 0.8.3
+ * `gci`: from 0.6.3 to 0.8.0
+ * `go-critic`: from 0.6.4 to 0.6.5
+ * `go-errorlint`: from 1.0.2 to 1.0.5
+ * `go-reassign`: v0.1.2 to v0.2.0
+ * `gofmt`: add option `rewrite-rules`
+ * `gofumpt` from 0.3.1 to 0.4.0
+ * `goimports`: update to HEAD
+ * `interfacebloat`: fix configuration loading
+ * `logrlint`: rename `logrlint` to `loggercheck`
+ * `paralleltest`: add tests of the ignore-missing option
+ * `revive`: from 1.2.3 to 1.2.4
+ * `usestdlibvars`: from 1.13.0 to 1.20.0
+ * `wsl`: support all configs and update docs
+3. misc.
+ * Normalize `exclude-rules` paths for Windows
+ * add riscv64 to the install script
+4. Documentation
+ * cli: remove reference to old service
+
### v1.49.0
IMPORTANT: `varcheck` and `deadcode` has been removed of default linters.
diff --git a/README.md b/README.md
index 792d8ab00eb0..7611266d60ba 100644
--- a/README.md
+++ b/README.md
@@ -76,26 +76,26 @@ The Core Team has the following responsibilities:
 Sascha Grunert |
 @iwankgb |
 Andrew Shannon Brown |
-  sivchari |
+  Marat Reymers |
 @golangci-releaser |
-  Sasha Melentyev |
 Pierre Durand |
+  sivchari |
+  Sasha Melentyev |
 Ryan Currah |
-  Denis Tingaikin |
 Sebastien Rosset |
-  Marat Reymers |
+  Denis Tingaikin |
 David Lobe |
 Alexey Palazhchenko |
 Duco van Amstel |
-  Nishanth Shanmugham |
+  Nishanth Shanmugham |
 Kensei Nakada |
 Melvin |
-  Denis Krivak |
 Iskander (Alex) Sharipov |
+  Denis Krivak |
 Maik Schreiber |
 Steve Coffman |
@@ -111,7 +111,7 @@ The Core Team has the following responsibilities:
-And 331 more our team members
+And 344 more our team members
diff --git a/assets/github-action-config.json b/assets/github-action-config.json
index 92f6d9b99625..6d1a9aa51936 100644
--- a/assets/github-action-config.json
+++ b/assets/github-action-config.json
@@ -1,8 +1,8 @@
{
"MinorVersionToConfig": {
"latest": {
- "TargetVersion": "v1.49.0",
- "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.49.0/golangci-lint-1.49.0-linux-amd64.tar.gz"
+ "TargetVersion": "v1.50.0",
+ "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.50.0/golangci-lint-1.50.0-linux-amd64.tar.gz"
},
"v1.10": {
"Error": "golangci-lint version 'v1.10' isn't supported: we support only v1.14.0 and later versions"
@@ -169,6 +169,10 @@
"v1.5": {
"Error": "golangci-lint version 'v1.5' isn't supported: we support only v1.14.0 and later versions"
},
+ "v1.50": {
+ "TargetVersion": "v1.50.0",
+ "AssetURL": "https://github.com/golangci/golangci-lint/releases/download/v1.50.0/golangci-lint-1.50.0-linux-amd64.tar.gz"
+ },
"v1.6": {
"Error": "golangci-lint version 'v1.6' isn't supported: we support only v1.14.0 and later versions"
},
diff --git a/docs/package-lock.json b/docs/package-lock.json
index 9c1dafba84bf..72aa3004e06d 100644
--- a/docs/package-lock.json
+++ b/docs/package-lock.json
@@ -14126,9 +14126,9 @@
}
},
"node_modules/gatsby-telemetry": {
- "version": "3.22.0",
- "resolved": "https://registry.npmjs.org/gatsby-telemetry/-/gatsby-telemetry-3.22.0.tgz",
- "integrity": "sha512-ZQIbPj0CVmElSc/XNGDru34MDFBkqYq9XtQgugqeiZErfdfDw8ukuJ2EUYafeSSfw+0BFTON+uSq96ixL88coQ==",
+ "version": "3.24.0",
+ "resolved": "https://registry.npmjs.org/gatsby-telemetry/-/gatsby-telemetry-3.24.0.tgz",
+ "integrity": "sha512-ioBzkmImRuyEAGtnyJgpln4LKTQ61MAjFaU+SFLVKDATcVh86rfNbD2ks5DzZgCtsP1/zVmHv2a7s4z/TQCZjA==",
"hasInstallScript": true,
"dependencies": {
"@babel/code-frame": "^7.14.0",
@@ -14138,8 +14138,8 @@
"boxen": "^4.2.0",
"configstore": "^5.0.1",
"fs-extra": "^10.1.0",
- "gatsby-core-utils": "^3.22.0",
- "git-up": "^6.0.0",
+ "gatsby-core-utils": "^3.24.0",
+ "git-up": "^7.0.0",
"is-docker": "^2.2.1",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7"
@@ -14958,12 +14958,12 @@
}
},
"node_modules/git-up": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/git-up/-/git-up-6.0.0.tgz",
- "integrity": "sha512-6RUFSNd1c/D0xtGnyWN2sxza2bZtZ/EmI9448n6rCZruFwV/ezeEn2fJP7XnUQGwf0RAtd/mmUCbtH6JPYA2SA==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz",
+ "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==",
"dependencies": {
"is-ssh": "^1.4.0",
- "parse-url": "^7.0.2"
+ "parse-url": "^8.1.0"
}
},
"node_modules/github-from-package": {
@@ -19423,9 +19423,9 @@
}
},
"node_modules/parse-path": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-5.0.0.tgz",
- "integrity": "sha512-qOpH55/+ZJ4jUu/oLO+ifUKjFPNZGfnPJtzvGzKN/4oLMil5m9OH4VpOj6++9/ytJcfks4kzH2hhi87GL/OU9A==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz",
+ "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==",
"dependencies": {
"protocols": "^2.0.0"
}
@@ -19436,14 +19436,11 @@
"integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE="
},
"node_modules/parse-url": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-7.0.2.tgz",
- "integrity": "sha512-PqO4Z0eCiQ08Wj6QQmrmp5YTTxpYfONdOEamrtvK63AmzXpcavIVQubGHxOEwiIoDZFb8uDOoQFS0NCcjqIYQg==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz",
+ "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==",
"dependencies": {
- "is-ssh": "^1.4.0",
- "normalize-url": "^6.1.0",
- "parse-path": "^5.0.0",
- "protocols": "^2.0.1"
+ "parse-path": "^7.0.0"
}
},
"node_modules/parse5": {
@@ -36355,9 +36352,9 @@
}
},
"gatsby-telemetry": {
- "version": "3.22.0",
- "resolved": "https://registry.npmjs.org/gatsby-telemetry/-/gatsby-telemetry-3.22.0.tgz",
- "integrity": "sha512-ZQIbPj0CVmElSc/XNGDru34MDFBkqYq9XtQgugqeiZErfdfDw8ukuJ2EUYafeSSfw+0BFTON+uSq96ixL88coQ==",
+ "version": "3.24.0",
+ "resolved": "https://registry.npmjs.org/gatsby-telemetry/-/gatsby-telemetry-3.24.0.tgz",
+ "integrity": "sha512-ioBzkmImRuyEAGtnyJgpln4LKTQ61MAjFaU+SFLVKDATcVh86rfNbD2ks5DzZgCtsP1/zVmHv2a7s4z/TQCZjA==",
"requires": {
"@babel/code-frame": "^7.14.0",
"@babel/runtime": "^7.15.4",
@@ -36366,8 +36363,8 @@
"boxen": "^4.2.0",
"configstore": "^5.0.1",
"fs-extra": "^10.1.0",
- "gatsby-core-utils": "^3.22.0",
- "git-up": "^6.0.0",
+ "gatsby-core-utils": "^3.24.0",
+ "git-up": "^7.0.0",
"is-docker": "^2.2.1",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7"
@@ -36742,12 +36739,12 @@
}
},
"git-up": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/git-up/-/git-up-6.0.0.tgz",
- "integrity": "sha512-6RUFSNd1c/D0xtGnyWN2sxza2bZtZ/EmI9448n6rCZruFwV/ezeEn2fJP7XnUQGwf0RAtd/mmUCbtH6JPYA2SA==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz",
+ "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==",
"requires": {
"is-ssh": "^1.4.0",
- "parse-url": "^7.0.2"
+ "parse-url": "^8.1.0"
}
},
"github-from-package": {
@@ -40183,9 +40180,9 @@
}
},
"parse-path": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-5.0.0.tgz",
- "integrity": "sha512-qOpH55/+ZJ4jUu/oLO+ifUKjFPNZGfnPJtzvGzKN/4oLMil5m9OH4VpOj6++9/ytJcfks4kzH2hhi87GL/OU9A==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz",
+ "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==",
"requires": {
"protocols": "^2.0.0"
}
@@ -40196,14 +40193,11 @@
"integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE="
},
"parse-url": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-7.0.2.tgz",
- "integrity": "sha512-PqO4Z0eCiQ08Wj6QQmrmp5YTTxpYfONdOEamrtvK63AmzXpcavIVQubGHxOEwiIoDZFb8uDOoQFS0NCcjqIYQg==",
+ "version": "8.1.0",
+ "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz",
+ "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==",
"requires": {
- "is-ssh": "^1.4.0",
- "normalize-url": "^6.1.0",
- "parse-path": "^5.0.0",
- "protocols": "^2.0.1"
+ "parse-path": "^7.0.0"
}
},
"parse5": {
diff --git a/docs/src/docs/usage/configuration.mdx b/docs/src/docs/usage/configuration.mdx
index 8b4d0e735a28..373ef0e974a3 100644
--- a/docs/src/docs/usage/configuration.mdx
+++ b/docs/src/docs/usage/configuration.mdx
@@ -6,7 +6,7 @@ The config file has lower priority than command-line options. If the same bool/s
and in the config file, the option from command-line will be used.
Slice options (e.g. list of enabled/disabled linters) are combined from the command-line and config file.
-To see a list of enabled by your configuration linters:
+To see a list of linters enabled by your configuration use:
```sh
golangci-lint linters
diff --git a/docs/template_data.state b/docs/template_data.state
index bd4b15c9c69b..e9428aa72845 100755
--- a/docs/template_data.state
+++ b/docs/template_data.state
@@ -1,2 +1,2 @@
This file stores hash of website templates to trigger Netlify rebuild when something changes, e.g. new linter is added.
-aa465b5c54517267990f78b0e06634befcd58ea971c3f925d7ec02cb3149057e
\ No newline at end of file
+1462e6935a8caa71d909cd4da3d9c6c1e47e1db9c3d80ee5dc1c84c343388d0e
\ No newline at end of file
diff --git a/go.mod b/go.mod
index 10b6279e63da..0050eca9e8bd 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
github.com/Abirdcfly/dupword v0.0.7
github.com/Antonboom/errname v0.1.7
github.com/Antonboom/nilnil v0.1.1
- github.com/BurntSushi/toml v1.2.0
+ github.com/BurntSushi/toml v1.2.1
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0
github.com/OpenPeeDeeP/depguard v1.1.1
@@ -23,7 +23,7 @@ require (
github.com/butuzov/ireturn v0.1.1
github.com/charithe/durationcheck v0.0.9
github.com/curioswitch/go-reassign v0.2.0
- github.com/daixiang0/gci v0.8.0
+ github.com/daixiang0/gci v0.8.1
github.com/denis-tingaikin/go-header v0.4.3
github.com/esimonov/ifshort v1.0.4
github.com/fatih/color v1.13.0
@@ -52,7 +52,7 @@ require (
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af
github.com/julz/importas v0.1.0
github.com/kisielk/errcheck v1.6.2
- github.com/kkHAIKE/contextcheck v1.1.2
+ github.com/kkHAIKE/contextcheck v1.1.3
github.com/kulti/thelper v0.6.3
github.com/kunwardeep/paralleltest v1.0.6
github.com/kyoh86/exportloopref v0.1.8
@@ -88,9 +88,9 @@ require (
github.com/sivchari/tenv v1.7.0
github.com/sonatard/noctx v0.0.1
github.com/sourcegraph/go-diff v0.6.1
- github.com/spf13/cobra v1.5.0
+ github.com/spf13/cobra v1.6.0
github.com/spf13/pflag v1.0.5
- github.com/spf13/viper v1.13.0
+ github.com/spf13/viper v1.12.0
github.com/ssgreg/nlreturn/v2 v2.2.1
github.com/stbenjam/no-sprintf-host-port v0.1.1
github.com/stretchr/testify v1.8.0
@@ -98,8 +98,8 @@ require (
github.com/tetafro/godot v1.4.11
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
github.com/timonwong/loggercheck v0.9.3
- github.com/tomarrell/wrapcheck/v2 v2.6.2
- github.com/tommy-muehle/go-mnd/v2 v2.5.0
+ github.com/tomarrell/wrapcheck/v2 v2.7.0
+ github.com/tommy-muehle/go-mnd/v2 v2.5.1
github.com/ultraware/funlen v0.0.3
github.com/ultraware/whitespace v0.0.5
github.com/uudashr/gocognit v1.0.6
@@ -107,7 +107,7 @@ require (
github.com/yagipy/maintidx v1.0.0
github.com/yeya24/promlinter v0.2.0
gitlab.com/bosi/decorder v0.2.3
- golang.org/x/tools v0.1.12
+ golang.org/x/tools v0.2.0
gopkg.in/yaml.v3 v3.0.1
honnef.co/go/tools v0.3.3
mvdan.cc/gofumpt v0.4.0
@@ -139,7 +139,7 @@ require (
github.com/gostaticanalysis/comment v1.4.2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
- github.com/inconshreveable/mousetrap v1.0.0 // indirect
+ github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/kisielk/gotool v1.0.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
@@ -177,10 +177,10 @@ require (
go.uber.org/zap v1.17.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect
- golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
+ golang.org/x/mod v0.6.0 // indirect
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
- golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect
- golang.org/x/text v0.3.7 // indirect
+ golang.org/x/sys v0.1.0 // indirect
+ golang.org/x/text v0.3.8 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
diff --git a/go.sum b/go.sum
index b344c2fc5522..4fb2714e3dc7 100644
--- a/go.sum
+++ b/go.sum
@@ -45,8 +45,8 @@ github.com/Antonboom/errname v0.1.7/go.mod h1:g0ONh16msHIPgJSGsecu1G/dcF2hlYR/0S
github.com/Antonboom/nilnil v0.1.1 h1:PHhrh5ANKFWRBh7TdYmyyq2gyT2lotnvFvvFbylF81Q=
github.com/Antonboom/nilnil v0.1.1/go.mod h1:L1jBqoWM7AOeTD+tSquifKSesRHs4ZdaxvZR+xdJEaI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
-github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
+github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
+github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM=
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
@@ -107,8 +107,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/cristalhq/acmd v0.8.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ=
github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo=
github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc=
-github.com/daixiang0/gci v0.8.0 h1:DzWYUm4+bc+taVUtuq1tsIMb/QFMMYgDIiykSoO98ZU=
-github.com/daixiang0/gci v0.8.0/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+MB0V0c=
+github.com/daixiang0/gci v0.8.1 h1:T4xpSC+hmsi4CSyuYfIJdMZAr9o7xZmHpQVygMghGZ4=
+github.com/daixiang0/gci v0.8.1/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+MB0V0c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -289,8 +289,8 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
-github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
-github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
+github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jgautheron/goconst v1.5.1 h1:HxVbL1MhydKs8R8n/HE5NPvzfaYmQJA3o879lE4+WcM=
github.com/jgautheron/goconst v1.5.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4=
github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs=
@@ -313,8 +313,8 @@ github.com/kisielk/errcheck v1.6.2 h1:uGQ9xI8/pgc9iOoCe7kWQgRE6SBTrCGmTSf0LrEtY7
github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw=
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
-github.com/kkHAIKE/contextcheck v1.1.2 h1:BYUSG/GhMhqVz//yjl8IkBDlMEws+9DtCmkz18QO1gg=
-github.com/kkHAIKE/contextcheck v1.1.2/go.mod h1:PG/cwd6c0705/LM0KTr1acO2gORUxkSVWyLJOFW5qoo=
+github.com/kkHAIKE/contextcheck v1.1.3 h1:l4pNvrb8JSwRd51ojtcOxOeHJzHek+MtOyXbaR0uvmw=
+github.com/kkHAIKE/contextcheck v1.1.3/go.mod h1:PG/cwd6c0705/LM0KTr1acO2gORUxkSVWyLJOFW5qoo=
github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@@ -498,14 +498,14 @@ github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo=
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
-github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
-github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
+github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI=
+github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
-github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU=
-github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw=
+github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ=
+github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI=
github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0=
github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I=
github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc=
@@ -541,10 +541,10 @@ github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03O
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
-github.com/tomarrell/wrapcheck/v2 v2.6.2 h1:3dI6YNcrJTQ/CJQ6M/DUkc0gnqYSIk6o0rChn9E/D0M=
-github.com/tomarrell/wrapcheck/v2 v2.6.2/go.mod h1:ao7l5p0aOlUNJKI0qVwB4Yjlqutd0IvAB9Rdwyilxvg=
-github.com/tommy-muehle/go-mnd/v2 v2.5.0 h1:iAj0a8e6+dXSL7Liq0aXPox36FiN1dBbjA6lt9fl65s=
-github.com/tommy-muehle/go-mnd/v2 v2.5.0/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
+github.com/tomarrell/wrapcheck/v2 v2.7.0 h1:J/F8DbSKJC83bAvC6FoZaRjZiZ/iKoueSdrEkmGeacA=
+github.com/tomarrell/wrapcheck/v2 v2.7.0/go.mod h1:ao7l5p0aOlUNJKI0qVwB4Yjlqutd0IvAB9Rdwyilxvg=
+github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw=
+github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw=
github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA=
github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI=
@@ -635,8 +635,9 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
-golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
+golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -674,8 +675,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -760,8 +761,8 @@ golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 h1:ohgcoMbSofXygzo6AD2I1kz3BFmW1QArPYTtwEM3UXc=
-golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
+golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -771,8 +772,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
+golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -854,8 +856,9 @@ golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da/go.mod h1:nABZi5QlRsZVlz
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
-golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
+golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
diff --git a/pkg/fsutils/path_unix.go b/pkg/fsutils/path_unix.go
new file mode 100644
index 000000000000..2a171ecc0c85
--- /dev/null
+++ b/pkg/fsutils/path_unix.go
@@ -0,0 +1,8 @@
+//go:build !windows
+
+package fsutils
+
+// NormalizePathInRegex it's a noop function on Unix.
+func NormalizePathInRegex(path string) string {
+ return path
+}
diff --git a/pkg/fsutils/path_windows.go b/pkg/fsutils/path_windows.go
new file mode 100644
index 000000000000..650aae1e16eb
--- /dev/null
+++ b/pkg/fsutils/path_windows.go
@@ -0,0 +1,28 @@
+//go:build windows
+
+package fsutils
+
+import (
+ "path/filepath"
+ "regexp"
+ "strings"
+)
+
+var separatorToReplace = regexp.QuoteMeta(string(filepath.Separator))
+
+// NormalizePathInRegex normalizes path in regular expressions.
+// noop on Unix.
+// This replacing should be safe because "/" are disallowed in Windows
+// https://docs.microsoft.com/windows/win32/fileio/naming-a-file
+func NormalizePathInRegex(path string) string {
+ // remove redundant character escape "\/" https://github.com/golangci/golangci-lint/issues/3277
+ clean := regexp.MustCompile(`\\+/`).
+ ReplaceAllStringFunc(path, func(s string) string {
+ if strings.Count(s, "\\")%2 == 0 {
+ return s
+ }
+ return s[1:]
+ })
+
+ return strings.ReplaceAll(clean, "/", separatorToReplace)
+}
diff --git a/pkg/golinters/depguard.go b/pkg/golinters/depguard.go
index 3e0171f5c919..eb7b0f3304b2 100644
--- a/pkg/golinters/depguard.go
+++ b/pkg/golinters/depguard.go
@@ -2,8 +2,6 @@ package golinters
import (
"fmt"
- "path/filepath"
- "regexp"
"strings"
"sync"
@@ -12,6 +10,7 @@ import (
"golang.org/x/tools/go/loader" //nolint:staticcheck // require changes in github.com/OpenPeeDeeP/depguard
"github.com/golangci/golangci-lint/pkg/config"
+ "github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
@@ -106,16 +105,6 @@ func (d depGuard) run(pass *analysis.Pass) ([]goanalysis.Issue, error) {
return resIssues, nil
}
-var separatorToReplace = regexp.QuoteMeta(string(filepath.Separator))
-
-// normalizePathInRegex normalizes path in regular expressions.
-// noop on Unix.
-// This replacing should be safe because "/" are disallowed in Windows
-// https://docs.microsoft.com/windows/win32/fileio/naming-a-file
-func normalizePathInRegex(path string) string {
- return strings.ReplaceAll(path, "/", separatorToReplace)
-}
-
type guardian struct {
*depguard.Depguard
pkgsWithErrorMessage map[string]string
@@ -124,7 +113,7 @@ type guardian struct {
func newGuardian(settings *config.DepGuardSettings) (*guardian, error) {
var ignoreFileRules []string
for _, rule := range settings.IgnoreFileRules {
- ignoreFileRules = append(ignoreFileRules, normalizePathInRegex(rule))
+ ignoreFileRules = append(ignoreFileRules, fsutils.NormalizePathInRegex(rule))
}
dg := &depguard.Depguard{
diff --git a/pkg/golinters/lll.go b/pkg/golinters/lll.go
index 8b5ebd3cf57f..551ff98a2c87 100644
--- a/pkg/golinters/lll.go
+++ b/pkg/golinters/lll.go
@@ -84,11 +84,29 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
}
defer f.Close()
- lineNumber := 1
+ lineNumber := 0
+ multiImportEnabled := false
+
scanner := bufio.NewScanner(f)
for scanner.Scan() {
+ lineNumber++
+
line := scanner.Text()
line = strings.ReplaceAll(line, "\t", tabSpaces)
+
+ if strings.HasPrefix(line, "import") {
+ multiImportEnabled = strings.HasSuffix(line, "(")
+ continue
+ }
+
+ if multiImportEnabled {
+ if line == ")" {
+ multiImportEnabled = false
+ }
+
+ continue
+ }
+
lineLen := utf8.RuneCountInString(line)
if lineLen > maxLineLen {
res = append(res, result.Issue{
@@ -100,7 +118,6 @@ func getLLLIssuesForFile(filename string, maxLineLen int, tabSpaces string) ([]r
FromLinter: lllName,
})
}
- lineNumber++
}
if err := scanner.Err(); err != nil {
diff --git a/pkg/printers/checkstyle.go b/pkg/printers/checkstyle.go
index bb347bd2baa6..307a8e7a0a85 100644
--- a/pkg/printers/checkstyle.go
+++ b/pkg/printers/checkstyle.go
@@ -12,6 +12,8 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
+const defaultCheckstyleSeverity = "error"
+
type checkstyleOutput struct {
XMLName xml.Name `xml:"checkstyle"`
Version string `xml:"version,attr"`
@@ -31,8 +33,6 @@ type checkstyleError struct {
Source string `xml:"source,attr"`
}
-const defaultCheckstyleSeverity = "error"
-
type Checkstyle struct {
w io.Writer
}
diff --git a/pkg/printers/codeclimate.go b/pkg/printers/codeclimate.go
index 8127632e74d6..8a90f145dd4f 100644
--- a/pkg/printers/codeclimate.go
+++ b/pkg/printers/codeclimate.go
@@ -9,8 +9,12 @@ import (
"github.com/golangci/golangci-lint/pkg/result"
)
-// CodeClimateIssue is a subset of the Code Climate spec - https://github.com/codeclimate/spec/blob/master/SPEC.md#data-types
-// It is just enough to support GitLab CI Code Quality - https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html
+const defaultCodeClimateSeverity = "critical"
+
+// CodeClimateIssue is a subset of the Code Climate spec.
+// https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#data-types
+// It is just enough to support GitLab CI Code Quality.
+// https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html
type CodeClimateIssue struct {
Description string `json:"description"`
Severity string `json:"severity,omitempty"`
@@ -40,6 +44,7 @@ func (p CodeClimate) Print(ctx context.Context, issues []result.Issue) error {
codeClimateIssue.Location.Path = issue.Pos.Filename
codeClimateIssue.Location.Lines.Begin = issue.Pos.Line
codeClimateIssue.Fingerprint = issue.Fingerprint()
+ codeClimateIssue.Severity = defaultCodeClimateSeverity
if issue.Severity != "" {
codeClimateIssue.Severity = issue.Severity
diff --git a/pkg/printers/codeclimate_test.go b/pkg/printers/codeclimate_test.go
index 5c25002a8907..3776e685fb82 100644
--- a/pkg/printers/codeclimate_test.go
+++ b/pkg/printers/codeclimate_test.go
@@ -1,4 +1,3 @@
-//nolint:dupl
package printers
import (
@@ -42,6 +41,21 @@ func TestCodeClimate_Print(t *testing.T) {
Column: 9,
},
},
+ {
+ FromLinter: "linter-c",
+ Text: "issue c",
+ SourceLines: []string{
+ "func foo() {",
+ "\tfmt.Println(\"ccc\")",
+ "}",
+ },
+ Pos: token.Position{
+ Filename: "path/to/filec.go",
+ Offset: 6,
+ Line: 200,
+ Column: 2,
+ },
+ },
}
buf := new(bytes.Buffer)
@@ -51,7 +65,7 @@ func TestCodeClimate_Print(t *testing.T) {
require.NoError(t, err)
//nolint:lll
- expected := `[{"description":"linter-a: some issue","severity":"warning","fingerprint":"BA73C5DF4A6FD8462FFF1D3140235777","location":{"path":"path/to/filea.go","lines":{"begin":10}}},{"description":"linter-b: another issue","severity":"error","fingerprint":"0777B4FE60242BD8B2E9B7E92C4B9521","location":{"path":"path/to/fileb.go","lines":{"begin":300}}}]`
+ expected := `[{"description":"linter-a: some issue","severity":"warning","fingerprint":"BA73C5DF4A6FD8462FFF1D3140235777","location":{"path":"path/to/filea.go","lines":{"begin":10}}},{"description":"linter-b: another issue","severity":"error","fingerprint":"0777B4FE60242BD8B2E9B7E92C4B9521","location":{"path":"path/to/fileb.go","lines":{"begin":300}}},{"description":"linter-c: issue c","severity":"critical","fingerprint":"BEE6E9FBB6BFA4B7DB9FB036697FB036","location":{"path":"path/to/filec.go","lines":{"begin":200}}}]`
assert.Equal(t, expected, buf.String())
}
diff --git a/pkg/printers/github_test.go b/pkg/printers/github_test.go
index 1e7772d25550..f62185182e99 100644
--- a/pkg/printers/github_test.go
+++ b/pkg/printers/github_test.go
@@ -1,3 +1,4 @@
+//nolint:dupl
package printers
import (
diff --git a/pkg/result/processors/exclude_rules.go b/pkg/result/processors/exclude_rules.go
index e9f474b98c54..62533b811533 100644
--- a/pkg/result/processors/exclude_rules.go
+++ b/pkg/result/processors/exclude_rules.go
@@ -44,7 +44,7 @@ func createRules(rules []ExcludeRule, prefix string) []excludeRule {
parsedRule.source = regexp.MustCompile(prefix + rule.Source)
}
if rule.Path != "" {
- path := normalizePathInRegex(rule.Path)
+ path := fsutils.NormalizePathInRegex(rule.Path)
parsedRule.path = regexp.MustCompile(path)
}
parsedRules = append(parsedRules, parsedRule)
diff --git a/pkg/result/processors/path_unix.go b/pkg/result/processors/path_unix.go
deleted file mode 100644
index b0c7c33826cb..000000000000
--- a/pkg/result/processors/path_unix.go
+++ /dev/null
@@ -1,8 +0,0 @@
-//go:build !windows
-
-package processors
-
-// normalizePathInRegex it's a noop function on Unix.
-func normalizePathInRegex(path string) string {
- return path
-}
diff --git a/pkg/result/processors/path_windows.go b/pkg/result/processors/path_windows.go
deleted file mode 100644
index 7f3e3622bb75..000000000000
--- a/pkg/result/processors/path_windows.go
+++ /dev/null
@@ -1,19 +0,0 @@
-//go:build windows
-
-package processors
-
-import (
- "path/filepath"
- "regexp"
- "strings"
-)
-
-var separatorToReplace = regexp.QuoteMeta(string(filepath.Separator))
-
-// normalizePathInRegex normalizes path in regular expressions.
-// noop on Unix.
-// This replacing should be safe because "/" are disallowed in Windows
-// https://docs.microsoft.com/windows/win32/fileio/naming-a-file
-func normalizePathInRegex(path string) string {
- return strings.ReplaceAll(path, "/", separatorToReplace)
-}
diff --git a/pkg/result/processors/severity_rules.go b/pkg/result/processors/severity_rules.go
index 4077b34057d1..85c1866a21d9 100644
--- a/pkg/result/processors/severity_rules.go
+++ b/pkg/result/processors/severity_rules.go
@@ -49,7 +49,7 @@ func createSeverityRules(rules []SeverityRule, prefix string) []severityRule {
parsedRule.source = regexp.MustCompile(prefix + rule.Source)
}
if rule.Path != "" {
- path := normalizePathInRegex(rule.Path)
+ path := fsutils.NormalizePathInRegex(rule.Path)
parsedRule.path = regexp.MustCompile(path)
}
parsedRules = append(parsedRules, parsedRule)
diff --git a/pkg/result/processors/skip_dirs.go b/pkg/result/processors/skip_dirs.go
index d657c5a04d00..11ab99104f79 100644
--- a/pkg/result/processors/skip_dirs.go
+++ b/pkg/result/processors/skip_dirs.go
@@ -7,6 +7,7 @@ import (
"github.com/pkg/errors"
+ "github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/golangci-lint/pkg/result"
)
@@ -31,7 +32,7 @@ const goFileSuffix = ".go"
func NewSkipDirs(patterns []string, log logutils.Log, runArgs []string) (*SkipDirs, error) {
var patternsRe []*regexp.Regexp
for _, p := range patterns {
- p = normalizePathInRegex(p)
+ p = fsutils.NormalizePathInRegex(p)
patternRe, err := regexp.Compile(p)
if err != nil {
return nil, errors.Wrapf(err, "can't compile regexp %q", p)
diff --git a/pkg/result/processors/skip_files.go b/pkg/result/processors/skip_files.go
index 1e2ca7aebf5c..b7b86bed06ce 100644
--- a/pkg/result/processors/skip_files.go
+++ b/pkg/result/processors/skip_files.go
@@ -4,6 +4,7 @@ import (
"fmt"
"regexp"
+ "github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/result"
)
@@ -16,7 +17,7 @@ var _ Processor = (*SkipFiles)(nil)
func NewSkipFiles(patterns []string) (*SkipFiles, error) {
var patternsRe []*regexp.Regexp
for _, p := range patterns {
- p = normalizePathInRegex(p)
+ p = fsutils.NormalizePathInRegex(p)
patternRe, err := regexp.Compile(p)
if err != nil {
return nil, fmt.Errorf("can't compile regexp %q: %s", p, err)
diff --git a/scripts/gen_github_action_config/go.mod b/scripts/gen_github_action_config/go.mod
index a4d3bba1e454..c896001f0f50 100644
--- a/scripts/gen_github_action_config/go.mod
+++ b/scripts/gen_github_action_config/go.mod
@@ -1,9 +1,16 @@
module github.com/golangci/golangci-lint/scripts/gen_github_action_config
-go 1.16
+go 1.18
require (
- github.com/shurcooL/githubv4 v0.0.0-20200627185320-e003124d66e4
- github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
- golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
+ github.com/shurcooL/githubv4 v0.0.0-20220922232305-70b4d362a8cb
+ golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783
+)
+
+require (
+ github.com/golang/protobuf v1.5.2 // indirect
+ github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 // indirect
+ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
+ google.golang.org/appengine v1.6.7 // indirect
+ google.golang.org/protobuf v1.28.0 // indirect
)
diff --git a/scripts/gen_github_action_config/go.sum b/scripts/gen_github_action_config/go.sum
index b22428e2d1f9..05a78d29a013 100644
--- a/scripts/gen_github_action_config/go.sum
+++ b/scripts/gen_github_action_config/go.sum
@@ -1,17 +1,27 @@
-cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
-github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
-github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/shurcooL/githubv4 v0.0.0-20200627185320-e003124d66e4 h1:cjmR6xY0f89IwBYMSwUrkFs4/1+KKw30Df3SqT7nZ6Q=
-github.com/shurcooL/githubv4 v0.0.0-20200627185320-e003124d66e4/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo=
-github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f h1:tygelZueB1EtXkPI6mQ4o9DQ0+FKW41hTbunoXZCTqk=
-github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg=
-golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
-golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
-golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
-golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
+github.com/shurcooL/githubv4 v0.0.0-20220922232305-70b4d362a8cb h1:Ptg7eUGaD22iZMracv+h7ghDJkGaeQ1FQ9BnkRB6DOo=
+github.com/shurcooL/githubv4 v0.0.0-20220922232305-70b4d362a8cb/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo=
+github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 h1:B1PEwpArrNp4dkQrfxh/abbBAOZBVp0ds+fBEOUOqOc=
+github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ=
+golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk=
+golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
-google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
+google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
+google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
diff --git a/scripts/gen_github_action_config/main.go b/scripts/gen_github_action_config/main.go
index 7d8c5b34b009..e5998f869dea 100644
--- a/scripts/gen_github_action_config/main.go
+++ b/scripts/gen_github_action_config/main.go
@@ -211,7 +211,7 @@ func fetchAllReleases(ctx context.Context) ([]release, error) {
EndCursor githubv4.String
HasNextPage bool
}
- } `graphql:"releases(first: 100, after: $releasesCursor)"`
+ } `graphql:"releases(first: 100, orderBy: { field: CREATED_AT, direction: DESC }, after: $releasesCursor)"`
} `graphql:"repository(owner: $owner, name: $name)"`
}
diff --git a/test/testdata/configs/lll_import.yml b/test/testdata/configs/lll_import.yml
new file mode 100644
index 000000000000..e281e3d24513
--- /dev/null
+++ b/test/testdata/configs/lll_import.yml
@@ -0,0 +1,4 @@
+linters-settings:
+ lll:
+ tab-width: 4
+ line-length: 60
diff --git a/test/testdata/lll_multi_import.go b/test/testdata/lll_multi_import.go
new file mode 100644
index 000000000000..4c2ab5ab477e
--- /dev/null
+++ b/test/testdata/lll_multi_import.go
@@ -0,0 +1,14 @@
+//golangcitest:args -Elll
+//golangcitest:config_path testdata/configs/lll_import.yml
+//golangcitest:expected_exitcode 0
+package testdata
+
+import (
+ anotherVeryLongImportAliasNameForTest "github.com/golangci/golangci-lint/internal/golinters"
+ veryLongImportAliasNameForTest "github.com/golangci/golangci-lint/internal/golinters"
+)
+
+func LllMultiImport() {
+ _ = veryLongImportAliasNameForTest.NewLLL(nil)
+ _ = anotherVeryLongImportAliasNameForTest.NewLLL(nil)
+}
diff --git a/test/testdata/lll_single_import.go b/test/testdata/lll_single_import.go
new file mode 100644
index 000000000000..ed86985aa568
--- /dev/null
+++ b/test/testdata/lll_single_import.go
@@ -0,0 +1,10 @@
+//golangcitest:args -Elll
+//golangcitest:config_path testdata/configs/lll_import.yml
+//golangcitest:expected_exitcode 0
+package testdata
+
+import veryLongImportAliasNameForTest "github.com/golangci/golangci-lint/internal/golinters"
+
+func LllSingleImport() {
+ _ = veryLongImportAliasNameForTest.NewLLL(nil)
+}
diff --git a/test/testshared/runner.go b/test/testshared/runner.go
index 70e2533bc23a..329411a9cbec 100644
--- a/test/testshared/runner.go
+++ b/test/testshared/runner.go
@@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/golangci/golangci-lint/pkg/exitcodes"
+ "github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/logutils"
)
@@ -304,7 +305,7 @@ func (r *RunnerResult) ExpectExitCode(possibleCodes ...int) *RunnerResult {
func (r *RunnerResult) ExpectOutputRegexp(s string) *RunnerResult {
r.tb.Helper()
- assert.Regexp(r.tb, normalizePathInRegex(s), r.output, "exit code is %d", r.exitCode)
+ assert.Regexp(r.tb, fsutils.NormalizePathInRegex(s), r.output, "exit code is %d", r.exitCode)
return r
}
diff --git a/test/testshared/runner_unix.go b/test/testshared/runner_unix.go
index c36669b1c6b6..edba71d54537 100644
--- a/test/testshared/runner_unix.go
+++ b/test/testshared/runner_unix.go
@@ -29,8 +29,3 @@ func defaultBinaryName() string {
func normalizeFilePath(in string) string {
return in
}
-
-// normalizePathInRegex it's a noop function on Unix.
-func normalizePathInRegex(path string) string {
- return path
-}
diff --git a/test/testshared/runner_windows.go b/test/testshared/runner_windows.go
index 69afec9c5bca..d6aa865ea182 100644
--- a/test/testshared/runner_windows.go
+++ b/test/testshared/runner_windows.go
@@ -41,11 +41,3 @@ func normalizeFilePath(in string) string {
return strings.ReplaceAll(s, "/", "\\")
})
}
-
-// normalizePathInRegex normalizes path in regular expressions.
-// Replace all `/` with `\\`.
-// This replacing should be safe because "/" are disallowed in Windows
-// https://docs.microsoft.com/windows/win32/fileio/naming-a-file
-func normalizePathInRegex(path string) string {
- return strings.ReplaceAll(path, "/", regexp.QuoteMeta(string(filepath.Separator)))
-}