Browse Source

Fix some lint errors

renovate/configure
Yota Toyama 7 years ago
parent
commit
7fece7d3a4
  1. 6
      arguments.go
  2. 26
      arguments_test.go
  3. 1
      rakefile.rb

6
arguments.go

@ -29,13 +29,13 @@ type arguments struct {
documentRoot string documentRoot string
concurrency int concurrency int
timeout time.Duration timeout time.Duration
recursive bool
excludedPattern *regexp.Regexp excludedPattern *regexp.Regexp
recursive bool
verbose bool verbose bool
} }
func getArguments(argv []string) (arguments, error) { func getArguments(argv []string) (arguments, error) {
args, err := docopt.Parse(fmt.Sprintf(usage, defaultConcurrency), argv, true, "liche", true) args, err := docopt.ParseArgs(fmt.Sprintf(usage, defaultConcurrency), argv, "0.1.0")
if err != nil { if err != nil {
return arguments{}, err return arguments{}, err
@ -76,8 +76,8 @@ func getArguments(argv []string) (arguments, error) {
args["--document-root"].(string), args["--document-root"].(string),
int(c), int(c),
time.Duration(t) * time.Second, time.Duration(t) * time.Second,
args["--recursive"].(bool),
r, r,
args["--recursive"].(bool),
args["--verbose"].(bool), args["--verbose"].(bool),
}, nil }, nil
} }

26
arguments_test.go

@ -15,55 +15,55 @@ func TestGetArguments(t *testing.T) {
}{ }{
{ {
argv: []string{"file"}, argv: []string{"file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, false, nil, false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, nil, false, false},
}, },
{ {
argv: []string{"-c", "42", "file"}, argv: []string{"-c", "42", "file"},
args: arguments{[]string{"file"}, "", 42, 0, false, nil, false}, args: arguments{[]string{"file"}, "", 42, 0, nil, false, false},
}, },
{ {
argv: []string{"--concurrency", "42", "file"}, argv: []string{"--concurrency", "42", "file"},
args: arguments{[]string{"file"}, "", 42, 0, false, nil, false}, args: arguments{[]string{"file"}, "", 42, 0, nil, false, false},
}, },
{ {
argv: []string{"-d", "directory", "file"}, argv: []string{"-d", "directory", "file"},
args: arguments{[]string{"file"}, "directory", defaultConcurrency, 0, false, nil, false}, args: arguments{[]string{"file"}, "directory", defaultConcurrency, 0, nil, false, false},
}, },
{ {
argv: []string{"--document-root", "directory", "file"}, argv: []string{"--document-root", "directory", "file"},
args: arguments{[]string{"file"}, "directory", defaultConcurrency, 0, false, nil, false}, args: arguments{[]string{"file"}, "directory", defaultConcurrency, 0, nil, false, false},
}, },
{ {
argv: []string{"-r", "file"}, argv: []string{"-r", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, true, nil, false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, nil, true, false},
}, },
{ {
argv: []string{"--recursive", "file"}, argv: []string{"--recursive", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, true, nil, false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, nil, true, false},
}, },
{ {
argv: []string{"-t", "42", "file"}, argv: []string{"-t", "42", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 42 * time.Second, false, nil, false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 42 * time.Second, nil, false, false},
}, },
{ {
argv: []string{"--timeout", "42", "file"}, argv: []string{"--timeout", "42", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 42 * time.Second, false, nil, false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 42 * time.Second, nil, false, false},
}, },
{ {
argv: []string{"-x", "^.*$", "file"}, argv: []string{"-x", "^.*$", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, false, regexp.MustCompile(`^.*$`), false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, regexp.MustCompile(`^.*$`), false, false},
}, },
{ {
argv: []string{"--exclude", "^.*$", "file"}, argv: []string{"--exclude", "^.*$", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, false, regexp.MustCompile(`^.*$`), false}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, regexp.MustCompile(`^.*$`), false, false},
}, },
{ {
argv: []string{"-v", "file"}, argv: []string{"-v", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, false, nil, true}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, nil, false, true},
}, },
{ {
argv: []string{"--verbose", "file"}, argv: []string{"--verbose", "file"},
args: arguments{[]string{"file"}, "", defaultConcurrency, 0, false, nil, true}, args: arguments{[]string{"file"}, "", defaultConcurrency, 0, nil, false, true},
}, },
} { } {
args, err := getArguments(c.argv) args, err := getArguments(c.argv)

1
rakefile.rb

@ -45,6 +45,7 @@ task :lint do
sh %w[gometalinter sh %w[gometalinter
--deadline 300s --deadline 300s
--disable gocyclo --disable gocyclo
--disable gosec
--disable vetshadow --disable vetshadow
--enable gofmt --enable gofmt
--enable goimports --enable goimports

Loading…
Cancel
Save