From 0eefc6cc8ef2d1afc9605d8ab19a70372d49db06 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 13 Dec 2022 21:55:21 +0100 Subject: [PATCH] fix: don't warn on duplicate numbers --- dupword.go | 3 +++ dupword_test.go | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dupword.go b/dupword.go index 7b8eb71..508caca 100644 --- a/dupword.go +++ b/dupword.go @@ -289,6 +289,9 @@ func (a *analyzer) Check(raw string) (update string, keyword string, find bool) // e.g. %s, 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 } diff --git a/dupword_test.go b/dupword_test.go index ba97c59..665401b 100644 --- a/dupword_test.go +++ b/dupword_test.go @@ -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",