Skip to content

Commit

Permalink
fix: don't warn on duplicate numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne authored and Abirdcfly committed Dec 14, 2022
1 parent ce5f3f4 commit 0eefc6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dupword.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ func (a *analyzer) Check(raw string) (update string, keyword string, find bool)
// e.g. %s, </div> should not be reported.
func ExcludeWords(word string) (exclude bool) {
firstRune, _ := utf8.DecodeRuneInString(word)
if unicode.IsDigit(firstRune) {
return true
}
if unicode.IsPunct(firstRune) {
return true
}
Expand Down
7 changes: 6 additions & 1 deletion dupword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ func TestExcludeWords(t *testing.T) {
{
name: "number should not exclude",
args: args{word: "3"},
wantExclude: false,
wantExclude: true,
},
{
name: "number,number should exclude",
args: args{word: "3,3 3,3"},
wantExclude: true,
},
{
name: "%s should exclude",
Expand Down

0 comments on commit 0eefc6c

Please sign in to comment.