aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/macabu
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-12-05 15:10:03 +0100
committerTaras Madan <tarasmadan@google.com>2023-12-06 11:31:44 +0000
commit2ab72b4feef2c97f22f90cfbf9e45a6cfcd08bda (patch)
treea6d19b94b6399fcc00a6cfa430885cd349dd1533 /vendor/github.com/macabu
parente08e8f492d31d672cc245944c185f8aadf2ee695 (diff)
vendor: updates
Diffstat (limited to 'vendor/github.com/macabu')
-rw-r--r--vendor/github.com/macabu/inamedparam/.gitignore21
-rw-r--r--vendor/github.com/macabu/inamedparam/LICENSE-MIT21
-rw-r--r--vendor/github.com/macabu/inamedparam/README.md18
-rw-r--r--vendor/github.com/macabu/inamedparam/inamedparam.go67
4 files changed, 127 insertions, 0 deletions
diff --git a/vendor/github.com/macabu/inamedparam/.gitignore b/vendor/github.com/macabu/inamedparam/.gitignore
new file mode 100644
index 000000000..3b735ec4a
--- /dev/null
+++ b/vendor/github.com/macabu/inamedparam/.gitignore
@@ -0,0 +1,21 @@
+# If you prefer the allow list template instead of the deny list, see community template:
+# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
+#
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
+
+# Go workspace file
+go.work
diff --git a/vendor/github.com/macabu/inamedparam/LICENSE-MIT b/vendor/github.com/macabu/inamedparam/LICENSE-MIT
new file mode 100644
index 000000000..b95f480ee
--- /dev/null
+++ b/vendor/github.com/macabu/inamedparam/LICENSE-MIT
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Matheus Macabu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/macabu/inamedparam/README.md b/vendor/github.com/macabu/inamedparam/README.md
new file mode 100644
index 000000000..80911c9d7
--- /dev/null
+++ b/vendor/github.com/macabu/inamedparam/README.md
@@ -0,0 +1,18 @@
+# inamedparam
+
+A linter that reports interfaces with unnamed method parameters.
+
+## Usage
+
+### Standalone
+You can also run it standalone through `go vet`.
+
+You must install the binary to your `$GOBIN` folder like so:
+```sh
+$ go install github.com/macabu/inamedparam/cmd/inamedparam
+```
+
+And then navigate to your Go project's root folder, where can run `go vet` in the following way:
+```sh
+$ go vet -vettool=$(which inamedparam) ./...
+```
diff --git a/vendor/github.com/macabu/inamedparam/inamedparam.go b/vendor/github.com/macabu/inamedparam/inamedparam.go
new file mode 100644
index 000000000..433e04e5b
--- /dev/null
+++ b/vendor/github.com/macabu/inamedparam/inamedparam.go
@@ -0,0 +1,67 @@
+package inamedparam
+
+import (
+ "go/ast"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/passes/inspect"
+ "golang.org/x/tools/go/ast/inspector"
+)
+
+var Analyzer = &analysis.Analyzer{
+ Name: "inamedparam",
+ Doc: "reports interfaces with unnamed method parameters",
+ Run: run,
+ Requires: []*analysis.Analyzer{
+ inspect.Analyzer,
+ },
+}
+
+func run(pass *analysis.Pass) (interface{}, error) {
+ inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
+
+ types := []ast.Node{
+ &ast.InterfaceType{},
+ }
+
+ inspect.Preorder(types, func(n ast.Node) {
+ interfaceType, ok := n.(*ast.InterfaceType)
+ if !ok || interfaceType == nil || interfaceType.Methods == nil {
+ return
+ }
+
+ for _, method := range interfaceType.Methods.List {
+ interfaceFunc, ok := method.Type.(*ast.FuncType)
+ if !ok || interfaceFunc == nil || interfaceFunc.Params == nil {
+ continue
+ }
+
+ methodName := method.Names[0].Name
+
+ for _, param := range interfaceFunc.Params.List {
+ if param.Names == nil {
+ var builtParamType string
+
+ switch paramType := param.Type.(type) {
+ case *ast.SelectorExpr:
+ if ident := paramType.X.(*ast.Ident); ident != nil {
+ builtParamType += ident.Name + "."
+ }
+
+ builtParamType += paramType.Sel.Name
+ case *ast.Ident:
+ builtParamType = paramType.Name
+ }
+
+ if builtParamType != "" {
+ pass.Reportf(param.Pos(), "interface method %v must have named param for type %v", methodName, builtParamType)
+ } else {
+ pass.Reportf(param.Pos(), "interface method %v must have all named params", methodName)
+ }
+ }
+ }
+ }
+ })
+
+ return nil, nil
+}