Skip to content

Commit a2a9f54

Browse files
committed
fix: CLI flags
1 parent 037ef4e commit a2a9f54

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

nakedret.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package nakedret
33
import (
44
"bytes"
55
"errors"
6-
"flag"
76
"fmt"
87
"go/ast"
98
"go/build"
@@ -24,17 +23,18 @@ const pwd = "./"
2423

2524
func NakedReturnAnalyzer(defaultLines uint, skipTestFiles bool) *analysis.Analyzer {
2625
nakedRet := &NakedReturnRunner{}
27-
flags := flag.NewFlagSet("nakedret", flag.ExitOnError)
28-
flags.UintVar(&nakedRet.MaxLength, "l", defaultLines, "maximum number of lines for a naked return function")
29-
flags.BoolVar(&nakedRet.SkipTestFiles, "skip-test-files", skipTestFiles, "set to true to skip test files")
30-
var analyzer = &analysis.Analyzer{
26+
27+
a := &analysis.Analyzer{
3128
Name: "nakedret",
3229
Doc: "Checks that functions with naked returns are not longer than a maximum size (can be zero).",
3330
Run: nakedRet.run,
34-
Flags: *flags,
3531
Requires: []*analysis.Analyzer{inspect.Analyzer},
3632
}
37-
return analyzer
33+
34+
a.Flags.UintVar(&nakedRet.MaxLength, "l", defaultLines, "maximum number of lines for a naked return function")
35+
a.Flags.BoolVar(&nakedRet.SkipTestFiles, "skip-test-files", skipTestFiles, "set to true to skip test files")
36+
37+
return a
3838
}
3939

4040
type NakedReturnRunner struct {

0 commit comments

Comments
 (0)