go-tools
go-tools copied to clipboard
stylecheck: flag capitalized local variable names
I see this style mistake from time to time.
I think that this is closer to a stylecheck
check than it is to a staticcheck
one.
I don't know about/use "stylecheck". I'm referring to ST???? checks in staticcheck.
The checks in staticcheck are grouped into categories (and the implementation into packages): simple, staticcheck, stylecheck and unused (S, SA, ST and U). But you don't have to worry about that distinction, I'll happily edit issue titles to match my organizational scheme.
As for actually adding the check: I'll have to play around with it. There are certainly valid capitalized local variable names. For example, T
is a common occurrence in this very code base, referring to an object's type. Unfortunately that includes variations of the name with random suffixes.
I'll have to sample a large code base and see how many noisy positives there are, and whether the check can be useful, at least as a disabled-by-default one.
As for actually adding the check: I'll have to play around with it. There are certainly valid capitalized local variable names. For example,
T
is a common occurrence in this very code base, referring to an object's type. Unfortunately that includes variations of the name with random suffixes.
Interesting. I disagree with this -- I wouldn't use T
for these cases. (I often use typ
.)
But I'm happy with a disabled-by-default check, if you're willing to add it.
In 2023 I think this check ought to enforce that function parameters and local vars use lowercase names and type parameters start with uppercase.