From b9bd12676c77ee146263510be3bd2688414e5b6b Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 18 Jun 2023 14:54:05 +0200 Subject: [PATCH 1/3] misspell: set ignore-words to lowercase --- pkg/golinters/misspell.go | 6 +++++- test/testdata/configs/misspell.yml | 2 ++ test/testdata/misspell.go | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/golinters/misspell.go b/pkg/golinters/misspell.go index ce2b79a7c1f8..0593b428151a 100644 --- a/pkg/golinters/misspell.go +++ b/pkg/golinters/misspell.go @@ -95,7 +95,11 @@ func createMisspellReplacer(settings *config.MisspellSettings) (*misspell.Replac } if len(settings.IgnoreWords) != 0 { - replacer.RemoveRule(settings.IgnoreWords) + var ignoreWords []string + for _, word := range settings.IgnoreWords { + ignoreWords = append(ignoreWords, strings.ToLower(word)) + } + replacer.RemoveRule(ignoreWords) } // It can panic. diff --git a/test/testdata/configs/misspell.yml b/test/testdata/configs/misspell.yml index ccb7772c8df8..d115cba91b06 100644 --- a/test/testdata/configs/misspell.yml +++ b/test/testdata/configs/misspell.yml @@ -1,4 +1,6 @@ linters-settings: misspell: + locale: US ignore-words: - langauge + - Dialogue diff --git a/test/testdata/misspell.go b/test/testdata/misspell.go index a866f117a37f..7646066e9b7e 100644 --- a/test/testdata/misspell.go +++ b/test/testdata/misspell.go @@ -7,3 +7,4 @@ func Misspell() { } // the word langauge should be ignored here: it's set in config +// the word Dialogue should be ignored here: it's set in config From e51b9eaf55009d670b2096de9a47810c5cef04e9 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 18 Jun 2023 21:42:15 +0200 Subject: [PATCH 2/3] chore: rename local variable to reduce ambiguity --- pkg/config/linters_settings.go | 3 ++- pkg/golinters/misspell.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index c219be1b792d..68ec1118b643 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -609,7 +609,8 @@ type MalignedSettings struct { } type MisspellSettings struct { - Locale string + Locale string + // TODO(ldez): v2 the options must be renamed to `IgnoredRules`. IgnoreWords []string `mapstructure:"ignore-words"` } diff --git a/pkg/golinters/misspell.go b/pkg/golinters/misspell.go index 0593b428151a..1cb2cff98bd0 100644 --- a/pkg/golinters/misspell.go +++ b/pkg/golinters/misspell.go @@ -95,11 +95,11 @@ func createMisspellReplacer(settings *config.MisspellSettings) (*misspell.Replac } if len(settings.IgnoreWords) != 0 { - var ignoreWords []string + var ignoredRules []string for _, word := range settings.IgnoreWords { - ignoreWords = append(ignoreWords, strings.ToLower(word)) + ignoredRules = append(ignoredRules, strings.ToLower(word)) } - replacer.RemoveRule(ignoreWords) + replacer.RemoveRule(ignoredRules) } // It can panic. From 62dfa022c322953fbc2edb25d668cdc0ad076f7e Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 19 Jun 2023 02:08:01 +0200 Subject: [PATCH 3/3] feat: update misspell to 0.4.1 --- go.mod | 2 +- go.sum | 4 ++-- pkg/golinters/misspell.go | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 5630980bb0b4..a7526449e96a 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( github.com/golangci/gofmt v0.0.0-20220901101216-f2edd75033f2 github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca - github.com/golangci/misspell v0.4.0 + github.com/golangci/misspell v0.4.1 github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 diff --git a/go.sum b/go.sum index c62d13ec0c5d..9984192a4785 100644 --- a/go.sum +++ b/go.sum @@ -223,8 +223,8 @@ github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 h1:MfyDlzVjl1hoaPz github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA= github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o= -github.com/golangci/misspell v0.4.0 h1:KtVB/hTK4bbL/S6bs64rYyk8adjmh1BygbBiaAiX+a0= -github.com/golangci/misspell v0.4.0/go.mod h1:W6O/bwV6lGDxUCChm2ykw9NQdd5bYd1Xkjo88UcWyJc= +github.com/golangci/misspell v0.4.1 h1:+y73iSicVy2PqyX7kmUefHusENlrP9YwuHZHPLGQj/g= +github.com/golangci/misspell v0.4.1/go.mod h1:9mAN1quEo3DlpbaIKKyEvRxK1pwqR9s/Sea1bJCtlNI= github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 h1:DIPQnGy2Gv2FSA4B/hh8Q7xx3B7AIDk3DAMeHclH1vQ= github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6/go.mod h1:0AKcRCkMoKvUvlf89F6O7H2LYdhr1zBh736mBItOdRs= github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 h1:zwtduBRr5SSWhqsYNgcuWO2kFlpdOZbP0+yRjmvPGys= diff --git a/pkg/golinters/misspell.go b/pkg/golinters/misspell.go index 1cb2cff98bd0..ce2b79a7c1f8 100644 --- a/pkg/golinters/misspell.go +++ b/pkg/golinters/misspell.go @@ -95,11 +95,7 @@ func createMisspellReplacer(settings *config.MisspellSettings) (*misspell.Replac } if len(settings.IgnoreWords) != 0 { - var ignoredRules []string - for _, word := range settings.IgnoreWords { - ignoredRules = append(ignoredRules, strings.ToLower(word)) - } - replacer.RemoveRule(ignoredRules) + replacer.RemoveRule(settings.IgnoreWords) } // It can panic.