@@ -178,21 +178,29 @@ func (lintErrorStrings) checkArg(expr *ast.CallExpr, arg int) (s *ast.BasicLit,
178
178
func lintErrorString (s string ) (isClean bool , conf float64 ) {
179
179
const basicConfidence = 0.8
180
180
const capConfidence = basicConfidence - 0.2
181
- first , firstN := utf8 . DecodeRuneInString ( s )
181
+
182
182
last , _ := utf8 .DecodeLastRuneInString (s )
183
183
if last == '.' || last == ':' || last == '!' || last == '\n' {
184
184
return false , basicConfidence
185
185
}
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
191
197
}
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)
195
201
}
196
202
}
197
- return true , 0
203
+
204
+ // Flag strings starting with something that doesn't look like an initialism.
205
+ return false , capConfidence
198
206
}
0 commit comments