From 95edd30b4141e1b9e135fc62a879228d7e463b3f Mon Sep 17 00:00:00 2001 From: Abirdcfly Date: Mon, 25 Sep 2023 12:05:11 +0800 Subject: [PATCH] build(deps): bump github.com/Abirdcfly/dupword from 0.0.12 to 0.0.13 (#4104) Co-authored-by: Fernandez Ludovic --- .golangci.reference.yml | 10 +++++++--- go.mod | 2 +- go.sum | 4 ++-- pkg/config/linters_settings.go | 1 + pkg/golinters/dupword.go | 1 + test/testdata/configs/dupword_ignore_the.yml | 4 ++++ test/testdata/dupword_ignore_the.go | 16 ++++++++++++++++ 7 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 test/testdata/configs/dupword_ignore_the.yml create mode 100644 test/testdata/dupword_ignore_the.go diff --git a/.golangci.reference.yml b/.golangci.reference.yml index cfc88f7f..be40f258 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -235,9 +235,13 @@ linters-settings: # If this list is not empty, only the words defined in this list will be detected. # Default: [] keywords: - - "the" - - "and" - - "a" + - "the" + - "and" + - "a" + # Keywords used to ignore detection. + # Default: [] + ignore: + - "0C0C" errcheck: # Report about not checking of errors in type assertions: `a := b.(MyStruct)`. diff --git a/go.mod b/go.mod index dad6b73f..49266d66 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( 4d63.com/gocheckcompilerdirectives v1.2.1 4d63.com/gochecknoglobals v0.2.1 github.com/4meepo/tagalign v1.3.2 - github.com/Abirdcfly/dupword v0.0.12 + github.com/Abirdcfly/dupword v0.0.13 github.com/Antonboom/errname v0.1.12 github.com/Antonboom/nilnil v0.1.7 github.com/BurntSushi/toml v1.3.2 diff --git a/go.sum b/go.sum index d452550a..a292f873 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.3.2 h1:1idD3yxlRGV18VjqtDbqYvQ5pXqQS0wO2dn6M3XstvI= github.com/4meepo/tagalign v1.3.2/go.mod h1:Q9c1rYMZJc9dPRkbQPpcBNCLEmY2njbAsXhQOZFE2dE= -github.com/Abirdcfly/dupword v0.0.12 h1:56NnOyrXzChj07BDFjeRA+IUzSz01jmzEq+G4kEgFhc= -github.com/Abirdcfly/dupword v0.0.12/go.mod h1:+us/TGct/nI9Ndcbcp3rgNcQzctTj68pq7TcgNpLfdI= +github.com/Abirdcfly/dupword v0.0.13 h1:SMS17YXypwP000fA7Lr+kfyBQyW14tTT+nRv9ASwUUo= +github.com/Abirdcfly/dupword v0.0.13/go.mod h1:Ut6Ue2KgF/kCOawpW4LnExT+xZLQviJPE4klBPMK/5Y= github.com/Antonboom/errname v0.1.12 h1:oh9ak2zUtsLp5oaEd/erjB4GPu9w19NyoIskZClDcQY= github.com/Antonboom/errname v0.1.12/go.mod h1:bK7todrzvlaZoQagP1orKzWXv59X/x0W0Io2XT1Ssro= github.com/Antonboom/nilnil v0.1.7 h1:ofgL+BA7vlA1K2wNQOsHzLJ2Pw5B5DpWRLdDAVvvTow= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 805d0ff4..9c2b2ad3 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -292,6 +292,7 @@ type DuplSettings struct { type DupWordSettings struct { Keywords []string `mapstructure:"keywords"` + Ignore []string `mapstructure:"ignore"` } type ErrcheckSettings struct { diff --git a/pkg/golinters/dupword.go b/pkg/golinters/dupword.go index f5a99bc0..6f079ffc 100644 --- a/pkg/golinters/dupword.go +++ b/pkg/golinters/dupword.go @@ -17,6 +17,7 @@ func NewDupWord(setting *config.DupWordSettings) *goanalysis.Linter { if setting != nil { cfgMap[a.Name] = map[string]any{ "keyword": strings.Join(setting.Keywords, ","), + "ignore": strings.Join(setting.Ignore, ","), } } diff --git a/test/testdata/configs/dupword_ignore_the.yml b/test/testdata/configs/dupword_ignore_the.yml new file mode 100644 index 00000000..6fdb8464 --- /dev/null +++ b/test/testdata/configs/dupword_ignore_the.yml @@ -0,0 +1,4 @@ +linters-settings: + dupword: + ignore: + - "the" diff --git a/test/testdata/dupword_ignore_the.go b/test/testdata/dupword_ignore_the.go new file mode 100644 index 00000000..f321b005 --- /dev/null +++ b/test/testdata/dupword_ignore_the.go @@ -0,0 +1,16 @@ +//golangcitest:args -Edupword +//golangcitest:config_path testdata/configs/dupword_ignore_the.yml +package testdata + +import "fmt" + +func duplicateWordInComments() { + // this line include duplicated word the the + fmt.Println("hello") +} + +func duplicateWordInStr() { + a := "this line include duplicate word and and" // want `Duplicate words \(and\) found` + b := "print the\n the line, print the the \n\t the line. and and" // want `Duplicate words \(and\) found` + fmt.Println(a, b) +}