Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ linters:
# Default: []
ignore:
- "0C0C"
# Checks only comments, skip strings.
# Default: false
comments-only: true

embeddedstructfieldcheck:
# Checks that there is an empty space between the embedded fields and regular fields.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
4d63.com/gochecknoglobals v0.2.2
dev.gaijin.team/go/exhaustruct/v4 v4.0.0
github.com/4meepo/tagalign v1.4.3
github.com/Abirdcfly/dupword v0.1.6
github.com/Abirdcfly/dupword v0.1.7
github.com/AdminBenni/iota-mixing v1.0.0
github.com/AlwxSin/noinlineerr v1.0.5
github.com/Antonboom/errname v1.1.1
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.

5 changes: 5 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,11 @@
"type": "string",
"examples": ["0C0C"]
}
},
"comments-only": {
"description": "Checks only comments, skip strings.",
"type": "boolean",
"default": false
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ type DuplSettings struct {
}

type DupWordSettings struct {
Keywords []string `mapstructure:"keywords"`
Ignore []string `mapstructure:"ignore"`
Keywords []string `mapstructure:"keywords"`
Ignore []string `mapstructure:"ignore"`
CommentsOnly bool `mapstructure:"comments-only"`
}

type EmbeddedStructFieldCheckSettings struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/golinters/dupword/dupword.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ func New(settings *config.DupWordSettings) *goanalysis.Linter {

if settings != nil {
cfg = map[string]any{
"keyword": strings.Join(settings.Keywords, ","),
"ignore": strings.Join(settings.Ignore, ","),
"keyword": strings.Join(settings.Keywords, ","),
"ignore": strings.Join(settings.Ignore, ","),
"comments-only": settings.CommentsOnly,
}
}

Expand Down
16 changes: 16 additions & 0 deletions pkg/golinters/dupword/testdata/dupword_comments_only.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//golangcitest:args -Edupword
//golangcitest:config_path testdata/dupword_comments_only.yml
package testdata

import "fmt"

func _() {
// want +2 `Duplicate words \(and\) found`
// want +2 `Duplicate words \(and,the\) found`
// this line include duplicate word and and
// print the\n the line, print the the \n\t the line. and and

a := "this line include duplicate word and and"
b := "print the\n the line, print the the \n\t the line. and and"
fmt.Println(a, b)
}
6 changes: 6 additions & 0 deletions pkg/golinters/dupword/testdata/dupword_comments_only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "2"

linters:
settings:
dupword:
comments-only: true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Edupword
//golangcitest:config_path testdata/dupword_ignore_the.yml
//golangcitest:config_path testdata/dupword_ignore.yml
package testdata

import "fmt"
Expand Down
Loading