aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/macabu
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/macabu')
-rw-r--r--vendor/github.com/macabu/inamedparam/.gitignore1
-rw-r--r--vendor/github.com/macabu/inamedparam/.golangci.yml33
-rw-r--r--vendor/github.com/macabu/inamedparam/README.md22
-rw-r--r--vendor/github.com/macabu/inamedparam/inamedparam.go33
4 files changed, 85 insertions, 4 deletions
diff --git a/vendor/github.com/macabu/inamedparam/.gitignore b/vendor/github.com/macabu/inamedparam/.gitignore
index 3b735ec4a..f8d51e94c 100644
--- a/vendor/github.com/macabu/inamedparam/.gitignore
+++ b/vendor/github.com/macabu/inamedparam/.gitignore
@@ -7,6 +7,7 @@
*.dll
*.so
*.dylib
+inamedparam
# Test binary, built with `go test -c`
*.test
diff --git a/vendor/github.com/macabu/inamedparam/.golangci.yml b/vendor/github.com/macabu/inamedparam/.golangci.yml
new file mode 100644
index 000000000..f0efa1cb6
--- /dev/null
+++ b/vendor/github.com/macabu/inamedparam/.golangci.yml
@@ -0,0 +1,33 @@
+run:
+ deadline: 30s
+
+linters:
+ enable-all: true
+ disable:
+ - cyclop
+ - deadcode
+ - depguard
+ - exhaustivestruct
+ - exhaustruct
+ - forcetypeassert
+ - gochecknoglobals
+ - gocognit
+ - golint
+ - ifshort
+ - interfacer
+ - maligned
+ - nilnil
+ - nosnakecase
+ - paralleltest
+ - scopelint
+ - structcheck
+ - varcheck
+
+linters-settings:
+ gci:
+ sections:
+ - standard
+ - default
+ - prefix(github.com/macabu/inamedparam)
+ section-separators:
+ - newLine
diff --git a/vendor/github.com/macabu/inamedparam/README.md b/vendor/github.com/macabu/inamedparam/README.md
index 80911c9d7..3336cb950 100644
--- a/vendor/github.com/macabu/inamedparam/README.md
+++ b/vendor/github.com/macabu/inamedparam/README.md
@@ -2,10 +2,16 @@
A linter that reports interfaces with unnamed method parameters.
+## Flags/Config
+```sh
+-skip-single-param
+ skip interfaces with a single unnamed parameter
+```
+
## Usage
### Standalone
-You can also run it standalone through `go vet`.
+You can run it standalone through `go vet`.
You must install the binary to your `$GOBIN` folder like so:
```sh
@@ -16,3 +22,17 @@ And then navigate to your Go project's root folder, where can run `go vet` in th
```sh
$ go vet -vettool=$(which inamedparam) ./...
```
+
+### golangci-lint
+`inamedparam` was added as a linter to `golangci-lint` on version `v1.55.0`. It is disabled by default.
+
+To enable it, you can add it to your `.golangci.yml` file, as such:
+```yaml
+run:
+ deadline: 30s
+
+linters:
+ disable-all: true
+ enable:
+ - inamedparam
+```
diff --git a/vendor/github.com/macabu/inamedparam/inamedparam.go b/vendor/github.com/macabu/inamedparam/inamedparam.go
index 433e04e5b..8ba7fe188 100644
--- a/vendor/github.com/macabu/inamedparam/inamedparam.go
+++ b/vendor/github.com/macabu/inamedparam/inamedparam.go
@@ -1,6 +1,7 @@
package inamedparam
import (
+ "flag"
"go/ast"
"golang.org/x/tools/go/analysis"
@@ -8,15 +9,30 @@ import (
"golang.org/x/tools/go/ast/inspector"
)
+const (
+ analyzerName = "inamedparam"
+
+ flagSkipSingleParam = "skip-single-param"
+)
+
var Analyzer = &analysis.Analyzer{
- Name: "inamedparam",
- Doc: "reports interfaces with unnamed method parameters",
- Run: run,
+ Name: analyzerName,
+ Doc: "reports interfaces with unnamed method parameters",
+ Run: run,
+ Flags: flags(),
Requires: []*analysis.Analyzer{
inspect.Analyzer,
},
}
+func flags() flag.FlagSet {
+ flags := flag.NewFlagSet(analyzerName, flag.ExitOnError)
+
+ flags.Bool(flagSkipSingleParam, false, "skip interface methods with a single unnamed parameter")
+
+ return *flags
+}
+
func run(pass *analysis.Pass) (interface{}, error) {
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
@@ -24,6 +40,8 @@ func run(pass *analysis.Pass) (interface{}, error) {
&ast.InterfaceType{},
}
+ skipSingleParam := pass.Analyzer.Flags.Lookup(flagSkipSingleParam).Value.(flag.Getter).Get().(bool)
+
inspect.Preorder(types, func(n ast.Node) {
interfaceType, ok := n.(*ast.InterfaceType)
if !ok || interfaceType == nil || interfaceType.Methods == nil {
@@ -36,8 +54,17 @@ func run(pass *analysis.Pass) (interface{}, error) {
continue
}
+ // Improvement: add test case to reproduce this. Help wanted.
+ if len(method.Names) == 0 {
+ continue
+ }
+
methodName := method.Names[0].Name
+ if skipSingleParam && len(interfaceFunc.Params.List) == 1 {
+ continue
+ }
+
for _, param := range interfaceFunc.Params.List {
if param.Names == nil {
var builtParamType string