Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ linters-settings:
- "and"
- "a"

# Keywords used to ignore detection.
# Default: []
ignore:
- "0C0C"

errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ type DuplSettings struct {

type DupWordSettings struct {
Keywords []string `mapstructure:"keywords"`
Ignore []string `mapstructure:"ignore"`
}

type ErrcheckSettings struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/golinters/dupword.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ","),
}
}

Expand Down
4 changes: 4 additions & 0 deletions test/testdata/configs/dupword_ignore_the.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linters-settings:
dupword:
ignore:
- "the"
16 changes: 16 additions & 0 deletions test/testdata/dupword_ignore_the.go
Original file line number Diff line number Diff line change
@@ -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)
}