aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/karamaru-alpha
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-01-22 16:07:17 +0100
committerTaras Madan <tarasmadan@google.com>2025-01-23 10:42:36 +0000
commit7b4377ad9d8a7205416df8d6217ef2b010f89481 (patch)
treee6fec4fd12ff807a16d847923f501075bf71d16c /vendor/github.com/karamaru-alpha
parent475a4c203afb8b7d3af51c4fd32bb170ff32a45e (diff)
vendor: delete
Diffstat (limited to 'vendor/github.com/karamaru-alpha')
-rw-r--r--vendor/github.com/karamaru-alpha/copyloopvar/.gitignore2
-rw-r--r--vendor/github.com/karamaru-alpha/copyloopvar/LICENSE21
-rw-r--r--vendor/github.com/karamaru-alpha/copyloopvar/README.md27
-rw-r--r--vendor/github.com/karamaru-alpha/copyloopvar/copyloopvar.go133
4 files changed, 0 insertions, 183 deletions
diff --git a/vendor/github.com/karamaru-alpha/copyloopvar/.gitignore b/vendor/github.com/karamaru-alpha/copyloopvar/.gitignore
deleted file mode 100644
index 816abbd92..000000000
--- a/vendor/github.com/karamaru-alpha/copyloopvar/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.idea/
-copyloopvar
diff --git a/vendor/github.com/karamaru-alpha/copyloopvar/LICENSE b/vendor/github.com/karamaru-alpha/copyloopvar/LICENSE
deleted file mode 100644
index e2567fd0c..000000000
--- a/vendor/github.com/karamaru-alpha/copyloopvar/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2024 Ryosei Karaki
-
-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/karamaru-alpha/copyloopvar/README.md b/vendor/github.com/karamaru-alpha/copyloopvar/README.md
deleted file mode 100644
index d31d1abd9..000000000
--- a/vendor/github.com/karamaru-alpha/copyloopvar/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# copyloopvar
-
-copyloopvar is a linter detects places where loop variables are copied.
-
-cf. [Fixing For Loops in Go 1.22](https://go.dev/blog/loopvar-preview)
-
-## Example
-
-```go
-for i, v := range []int{1, 2, 3} {
- i := i // The copy of the 'for' variable "i" can be deleted (Go 1.22+)
- v := v // The copy of the 'for' variable "v" can be deleted (Go 1.22+)
- _, _ = i, v
-}
-
-for i := 1; i <= 3; i++ {
- i := i // The copy of the 'for' variable "i" can be deleted (Go 1.22+)
- _ = i
-}
-```
-
-## Install
-
-```bash
-go install github.com/karamaru-alpha/copyloopvar/cmd/copyloopvar@latest
-go vet -vettool=`which copyloopvar` ./...
-```
diff --git a/vendor/github.com/karamaru-alpha/copyloopvar/copyloopvar.go b/vendor/github.com/karamaru-alpha/copyloopvar/copyloopvar.go
deleted file mode 100644
index 79dc6afcc..000000000
--- a/vendor/github.com/karamaru-alpha/copyloopvar/copyloopvar.go
+++ /dev/null
@@ -1,133 +0,0 @@
-package copyloopvar
-
-import (
- "fmt"
- "go/ast"
- "go/token"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/passes/inspect"
- "golang.org/x/tools/go/ast/inspector"
-)
-
-var checkAlias bool
-
-func NewAnalyzer() *analysis.Analyzer {
- analyzer := &analysis.Analyzer{
- Name: "copyloopvar",
- Doc: "copyloopvar is a linter detects places where loop variables are copied",
- Run: run,
- Requires: []*analysis.Analyzer{
- inspect.Analyzer,
- },
- }
- analyzer.Flags.BoolVar(&checkAlias, "check-alias", false, "check all assigning the loop variable to another variable")
- return analyzer
-}
-
-func run(pass *analysis.Pass) (any, error) {
- pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).Preorder([]ast.Node{
- (*ast.RangeStmt)(nil),
- (*ast.ForStmt)(nil),
- }, func(n ast.Node) {
- switch node := n.(type) {
- case *ast.RangeStmt:
- checkRangeStmt(pass, node)
- case *ast.ForStmt:
- checkForStmt(pass, node)
- }
- })
-
- return nil, nil
-}
-
-func checkRangeStmt(pass *analysis.Pass, rangeStmt *ast.RangeStmt) {
- key, ok := rangeStmt.Key.(*ast.Ident)
- if !ok {
- return
- }
- var value *ast.Ident
- if rangeStmt.Value != nil {
- if value, ok = rangeStmt.Value.(*ast.Ident); !ok {
- return
- }
- }
- for _, stmt := range rangeStmt.Body.List {
- assignStmt, ok := stmt.(*ast.AssignStmt)
- if !ok {
- continue
- }
- if assignStmt.Tok != token.DEFINE {
- continue
- }
- for i, rh := range assignStmt.Rhs {
- right, ok := rh.(*ast.Ident)
- if !ok {
- continue
- }
- if right.Name != key.Name && (value == nil || right.Name != value.Name) {
- continue
- }
- if !checkAlias {
- left, ok := assignStmt.Lhs[i].(*ast.Ident)
- if !ok {
- continue
- }
- if left.Name != right.Name {
- continue
- }
- }
- pass.Report(analysis.Diagnostic{
- Pos: assignStmt.Pos(),
- Message: fmt.Sprintf(`The copy of the 'for' variable "%s" can be deleted (Go 1.22+)`, right.Name),
- })
- }
- }
-}
-
-func checkForStmt(pass *analysis.Pass, forStmt *ast.ForStmt) {
- if forStmt.Init == nil {
- return
- }
- initAssignStmt, ok := forStmt.Init.(*ast.AssignStmt)
- if !ok {
- return
- }
- initVarNameMap := make(map[string]interface{}, len(initAssignStmt.Lhs))
- for _, lh := range initAssignStmt.Lhs {
- if initVar, ok := lh.(*ast.Ident); ok {
- initVarNameMap[initVar.Name] = struct{}{}
- }
- }
- for _, stmt := range forStmt.Body.List {
- assignStmt, ok := stmt.(*ast.AssignStmt)
- if !ok {
- continue
- }
- if assignStmt.Tok != token.DEFINE {
- continue
- }
- for i, rh := range assignStmt.Rhs {
- right, ok := rh.(*ast.Ident)
- if !ok {
- continue
- }
- if _, ok := initVarNameMap[right.Name]; !ok {
- continue
- }
- if !checkAlias {
- left, ok := assignStmt.Lhs[i].(*ast.Ident)
- if !ok {
- continue
- }
- if left.Name != right.Name {
- continue
- }
- }
- pass.Report(analysis.Diagnostic{
- Pos: assignStmt.Pos(),
- Message: fmt.Sprintf(`The copy of the 'for' variable "%s" can be deleted (Go 1.22+)`, right.Name),
- })
- }
- }
-}