-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable the 'scopelint' and 'unconvert' linters #1299
Conversation
'scopelint' checks for unpinned variables in 'range'-loops. This helps to avoid subtle bugs. 'unconvert' checks for unnecessary type conversions.
Isn't the table test case a false-positive? kyoh86/scopelint#4 |
@@ -68,6 +68,8 @@ func Test_isRelative(t *testing.T) { | |||
} | |||
|
|||
for i, test := range tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily part of this PR, but wdyt of normalizing this test?
for i, test := range tests { | |
for _, tt := range tests { | |
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd normalize to test
, tt
is non-descriptive ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop fighting Go conventions 👅 . Just accept and move on 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone using tt
in a Wiki doesn't make this a convention 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, resisting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is needed once we decide to run tests in parallel. 🚢
@porridge Yes, these are false positives. I'm okay with that, rather have some false positives than subtle bugs. |
I think it is fair to say that if we have a scope where two things can be
called `t` (the testing.T object and the test struct), then calling one `t`
and the other `tt` could be a source of confusion.
In that case I'd also prefer `test` rather than `tt`.
|
...and the resistance is growing 😂 Again, you could argue that using |
I agree about i/j/k, though if used in anything much different than matrix
multiplication I'd say the code needs refactoring :-P
I don't think there is a generally accepted convention about naming
variables t, tt, ttt, tttt though :-D
GitHub search is not perfect. "for _, test := range tests" yields 14M+
results :-)
|
Let's not have this discussion here, but in other channels. This PR is only adding new linters. Let's discuss naming elsewhere and enforce code consistency in follow-up PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
'scopelint' checks for unpinned variables in 'range'-loops. This helps to avoid subtle bugs. 'unconvert' checks for unnecessary type conversions. Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
'scopelint' checks for unpinned variables in 'range'-loops. This helps to avoid subtle bugs. 'unconvert' checks for unnecessary type conversions. Signed-off-by: Thomas Runyon <runyontr@gmail.com>
What this PR does / why we need it:
'scopelint' checks for unpinned variables in 'range'-loops. This helps to avoid subtle bugs.
'unconvert' checks for unnecessary type conversions.