@@ -178,21 +178,29 @@ func (lintErrorStrings) checkArg(expr *ast.CallExpr, arg int) (s *ast.BasicLit,
178178func lintErrorString (s string ) (isClean bool , conf float64 ) {
179179const basicConfidence = 0.8
180180const capConfidence = basicConfidence - 0.2
181- first , firstN := utf8 . DecodeRuneInString ( s )
181+
182182last , _ := utf8 .DecodeLastRuneInString (s )
183183if last == '.' || last == ':' || last == '!' || last == '\n' {
184184return false , basicConfidence
185185}
186- if unicode .IsUpper (first ) {
187- // People use proper nouns and exported Go identifiers in error strings,
188- // so decrease the confidence of warnings for capitalization.
189- if len (s ) <= firstN {
190- return false , capConfidence
186+
187+ first , firstN := utf8 .DecodeRuneInString (s )
188+ if ! unicode .IsUpper (first ) {
189+ return true , 0
190+ }
191+
192+ // People use proper nouns and exported Go identifiers in error strings,
193+ // so decrease the confidence of warnings for capitalization.
194+ for _ , r := range s [firstN :] {
195+ if unicode .IsSpace (r ) {
196+ break
191197}
192- // Flag strings starting with something that doesn't look like an initialism.
193- if second , _ := utf8 . DecodeRuneInString ( s [ firstN :]); ! unicode .IsUpper ( second ) {
194- return false , capConfidence
198+
199+ if unicode . IsUpper ( r ) || unicode .IsDigit ( r ) {
200+ return true , 0 // accept words with more than 2 capital letters or digits (e.g. GitHub, URLs, I2000)
195201}
196202}
197- return true , 0
203+
204+ // Flag strings starting with something that doesn't look like an initialism.
205+ return false , capConfidence
198206}
0 commit comments