diff --git a/.golangci.yml b/.golangci.yml index 0a94959e..cc80993a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -78,6 +78,7 @@ linters: - bodyclose - contextcheck - dupl + - dupword - durationcheck - errname - errorlint @@ -91,6 +92,7 @@ linters: - goprintffuncname - gosec - makezero + - mirror - nakedret - nilerr - nilnil @@ -105,8 +107,10 @@ linters: - sqlclosecheck - stylecheck - tenv + - thelper - tparallel - unconvert - unparam + - usestdlibvars - wastedassign - whitespace diff --git a/cmd/vale/api.go b/cmd/vale/api.go index 0bd1e0f3..19b3493f 100644 --- a/cmd/vale/api.go +++ b/cmd/vale/api.go @@ -61,7 +61,7 @@ func fetch(src, dst string) error { if err != nil { return err - } else if resp.StatusCode != 200 { + } else if resp.StatusCode != http.StatusOK { return fmt.Errorf("could not fetch '%s' (status code '%d')", src, resp.StatusCode) } diff --git a/internal/check/existence.go b/internal/check/existence.go index 1ced5ecc..ff2ce671 100644 --- a/internal/check/existence.go +++ b/internal/check/existence.go @@ -69,7 +69,7 @@ func NewExistence(cfg *core.Config, generic baseCheck, path string) (Existence, return rule, nil } -// Run executes the the `existence`-based rule. +// Run executes the `existence`-based rule. // // This is simplest of the available extension points: it looks for any matches // of its internal `pattern` (calculated from `NewExistence`) against the diff --git a/internal/check/repetition.go b/internal/check/repetition.go index 13eeeed8..d03a929b 100644 --- a/internal/check/repetition.go +++ b/internal/check/repetition.go @@ -58,7 +58,7 @@ func NewRepetition(cfg *core.Config, generic baseCheck, path string) (Repetition return rule, nil } -// Run executes the the `repetition`-based rule. +// Run executes the `repetition`-based rule. // // The rule looks for repeated matches of its regex -- such as "this this". func (o Repetition) Run(blk nlp.Block, _ *core.File) ([]core.Alert, error) { diff --git a/internal/check/substitution.go b/internal/check/substitution.go index 2b6a2f3b..7f429b52 100644 --- a/internal/check/substitution.go +++ b/internal/check/substitution.go @@ -97,7 +97,7 @@ func NewSubstitution(cfg *core.Config, generic baseCheck, path string) (Substitu return rule, nil } -// Run executes the the `substitution`-based rule. +// Run executes the `substitution`-based rule. // // The rule looks for one pattern and then suggests a replacement. func (s Substitution) Run(blk nlp.Block, _ *core.File) ([]core.Alert, error) { diff --git a/internal/core/util.go b/internal/core/util.go index 40951f0e..40cf8fb8 100755 --- a/internal/core/util.go +++ b/internal/core/util.go @@ -286,7 +286,7 @@ func ReplaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func([]str result := "" lastIndex := 0 - for _, v := range re.FindAllSubmatchIndex([]byte(str), -1) { + for _, v := range re.FindAllStringSubmatchIndex(str, -1) { groups := []string{} for i := 0; i < len(v); i += 2 { if v[i] == -1 || v[i+1] == -1 { diff --git a/internal/lint/lint_test.go b/internal/lint/lint_test.go index 1fd61a98..8a75323a 100755 --- a/internal/lint/lint_test.go +++ b/internal/lint/lint_test.go @@ -59,7 +59,9 @@ func initLinter() (*Linter, error) { return NewLinter(cfg) } -func benchmarkLint(path string, b *testing.B) { +func benchmarkLint(b *testing.B, path string) { + b.Helper() + linter, err := initLinter() if err != nil { b.Fatal(err) @@ -79,9 +81,9 @@ func benchmarkLint(path string, b *testing.B) { } func BenchmarkLintRST(b *testing.B) { - benchmarkLint("../../testdata/fixtures/benchmarks/bench.rst", b) + benchmarkLint(b, "../../testdata/fixtures/benchmarks/bench.rst") } func BenchmarkLintMD(b *testing.B) { - benchmarkLint("../../testdata/fixtures/benchmarks/bench.md", b) + benchmarkLint(b, "../../testdata/fixtures/benchmarks/bench.md") }