Skip to content
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

Merged
merged 1 commit into from
Jan 23, 2020

Conversation

nfnt
Copy link
Member

@nfnt nfnt commented Jan 22, 2020

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.

'scopelint' checks for unpinned variables in 'range'-loops. This helps to avoid subtle bugs.
'unconvert' checks for unnecessary type conversions.
@porridge
Copy link
Member

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 {
Copy link
Contributor

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?

Suggested change
for i, test := range tests {
for _, tt := range tests {
...

Copy link
Member Author

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 ;)

Copy link
Contributor

@zen-dog zen-dog Jan 22, 2020

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 😂

Copy link
Member Author

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 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, resisting?

Copy link
Contributor

@zen-dog zen-dog left a 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. 🚢

@nfnt
Copy link
Member Author

nfnt commented Jan 22, 2020

@porridge Yes, these are false positives. I'm okay with that, rather have some false positives than subtle bugs.

@porridge
Copy link
Member

porridge commented Jan 22, 2020 via email

@zen-dog
Copy link
Contributor

zen-dog commented Jan 22, 2020

then calling one t and the other tt could be a source of confusion.

...and the resistance is growing 😂 Again, you could argue that using i/j/k as loop indexes is stupid but that's the convention. And in Go's case using for _, tt := range tests gives you 1M+ search results in Github so accept the convention 😆

@porridge
Copy link
Member

porridge commented Jan 22, 2020 via email

@nfnt
Copy link
Member Author

nfnt commented Jan 22, 2020

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.

Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kensipe kensipe merged commit abb1219 into master Jan 23, 2020
@kensipe kensipe deleted the nfnt/additional-linters branch January 23, 2020 19:10
ANeumann82 pushed a commit that referenced this pull request Feb 13, 2020
'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>
runyontr pushed a commit that referenced this pull request Mar 11, 2020
'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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants