diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-01-22 16:07:17 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-01-23 10:42:36 +0000 |
| commit | 7b4377ad9d8a7205416df8d6217ef2b010f89481 (patch) | |
| tree | e6fec4fd12ff807a16d847923f501075bf71d16c /vendor/github.com/sashamelentyev/interfacebloat/pkg | |
| parent | 475a4c203afb8b7d3af51c4fd32bb170ff32a45e (diff) | |
vendor: delete
Diffstat (limited to 'vendor/github.com/sashamelentyev/interfacebloat/pkg')
| -rw-r--r-- | vendor/github.com/sashamelentyev/interfacebloat/pkg/analyzer/analyzer.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/vendor/github.com/sashamelentyev/interfacebloat/pkg/analyzer/analyzer.go b/vendor/github.com/sashamelentyev/interfacebloat/pkg/analyzer/analyzer.go deleted file mode 100644 index 4a6afdf8c..000000000 --- a/vendor/github.com/sashamelentyev/interfacebloat/pkg/analyzer/analyzer.go +++ /dev/null @@ -1,57 +0,0 @@ -package analyzer - -import ( - "flag" - "go/ast" - - "golang.org/x/tools/go/analysis" - "golang.org/x/tools/go/analysis/passes/inspect" - "golang.org/x/tools/go/ast/inspector" -) - -const InterfaceMaxMethodsFlag = "max" - -const defaultMaxMethods = 10 - -// New returns new interfacebloat analyzer. -func New() *analysis.Analyzer { - return &analysis.Analyzer{ - Name: "interfacebloat", - Doc: "A linter that checks the number of methods inside an interface.", - Run: run, - Flags: flags(), - Requires: []*analysis.Analyzer{inspect.Analyzer}, - } -} - -func flags() flag.FlagSet { - flags := flag.NewFlagSet("", flag.ExitOnError) - flags.Int(InterfaceMaxMethodsFlag, 10, "maximum number of methods") - return *flags -} - -func run(pass *analysis.Pass) (interface{}, error) { - maxMethods, ok := pass.Analyzer.Flags.Lookup(InterfaceMaxMethodsFlag).Value.(flag.Getter).Get().(int) - if !ok { - maxMethods = defaultMaxMethods - } - - insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) - - filter := []ast.Node{ - (*ast.InterfaceType)(nil), - } - - insp.Preorder(filter, func(node ast.Node) { - i, ok := node.(*ast.InterfaceType) - if !ok { - return - } - - if len(i.Methods.List) > maxMethods { - pass.Reportf(node.Pos(), `the interface has more than %d methods: %d`, maxMethods, len(i.Methods.List)) - } - }) - - return nil, nil -} |
