aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ssgreg
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/ssgreg
parent475a4c203afb8b7d3af51c4fd32bb170ff32a45e (diff)
vendor: delete
Diffstat (limited to 'vendor/github.com/ssgreg')
-rw-r--r--vendor/github.com/ssgreg/nlreturn/v2/LICENSE21
-rw-r--r--vendor/github.com/ssgreg/nlreturn/v2/pkg/nlreturn/nlreturn.go95
2 files changed, 0 insertions, 116 deletions
diff --git a/vendor/github.com/ssgreg/nlreturn/v2/LICENSE b/vendor/github.com/ssgreg/nlreturn/v2/LICENSE
deleted file mode 100644
index 0a5b4d106..000000000
--- a/vendor/github.com/ssgreg/nlreturn/v2/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2018 Grigory Zubankov
-
-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/ssgreg/nlreturn/v2/pkg/nlreturn/nlreturn.go b/vendor/github.com/ssgreg/nlreturn/v2/pkg/nlreturn/nlreturn.go
deleted file mode 100644
index 42b15e9b3..000000000
--- a/vendor/github.com/ssgreg/nlreturn/v2/pkg/nlreturn/nlreturn.go
+++ /dev/null
@@ -1,95 +0,0 @@
-package nlreturn
-
-import (
- "flag"
- "fmt"
- "go/ast"
- "go/token"
-
- "golang.org/x/tools/go/analysis"
-)
-
-const (
- linterName = "nlreturn"
- linterDoc = `Linter requires a new line before return and branch statements except when the return is alone inside a statement group (such as an if statement) to increase code clarity.`
-)
-
-var blockSize int
-
-// NewAnalyzer returns a new nlreturn analyzer.
-func NewAnalyzer() *analysis.Analyzer {
- a := &analysis.Analyzer{
- Name: linterName,
- Doc: linterDoc,
- Run: run,
- }
-
- a.Flags.Init("nlreturn", flag.ExitOnError)
- a.Flags.IntVar(&blockSize, "block-size", 1, "set block size that is still ok")
-
- return a
-}
-
-func run(pass *analysis.Pass) (interface{}, error) {
- for _, f := range pass.Files {
- ast.Inspect(f, func(node ast.Node) bool {
- switch c := node.(type) {
- case *ast.CaseClause:
- inspectBlock(pass, c.Body)
- case *ast.CommClause:
- inspectBlock(pass, c.Body)
- case *ast.BlockStmt:
- inspectBlock(pass, c.List)
- }
-
- return true
- })
- }
-
- return nil, nil
-}
-
-func inspectBlock(pass *analysis.Pass, block []ast.Stmt) {
- for i, stmt := range block {
- switch stmt.(type) {
- case *ast.BranchStmt, *ast.ReturnStmt:
-
- if i == 0 || line(pass, stmt.Pos())-line(pass, block[0].Pos()) < blockSize {
- return
- }
-
- if line(pass, stmt.Pos())-line(pass, block[i-1].End()) <= 1 {
- pass.Report(analysis.Diagnostic{
- Pos: stmt.Pos(),
- Message: fmt.Sprintf("%s with no blank line before", name(stmt)),
- SuggestedFixes: []analysis.SuggestedFix{
- {
- TextEdits: []analysis.TextEdit{
- {
- Pos: stmt.Pos(),
- NewText: []byte("\n"),
- End: stmt.Pos(),
- },
- },
- },
- },
- })
- }
- }
- }
-}
-
-func name(stmt ast.Stmt) string {
- switch c := stmt.(type) {
- case *ast.BranchStmt:
- return c.Tok.String()
- case *ast.ReturnStmt:
- return "return"
- default:
- return "unknown"
- }
-}
-
-func line(pass *analysis.Pass, pos token.Pos) int {
- return pass.Fset.Position(pos).Line
-}