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

False positive caused by brackets #14

Closed
sb10 opened this issue May 10, 2021 · 6 comments · Fixed by #15
Closed

False positive caused by brackets #14

sb10 opened this issue May 10, 2021 · 6 comments · Fixed by #15

Comments

@sb10
Copy link

sb10 commented May 10, 2021

time.Duration(attempts) * time.Millisecond is fine, but
time.Duration((attempts)) * time.Millisecond causes a false positive.

(The real scenario was doing some maths inside the time.Duration(): time.Duration((attempts-1)*2)*time.Millisecond).)

@charithe
Copy link
Owner

Thanks. This is fixed in v0.0.7.

@Gentoli
Copy link

Gentoli commented May 21, 2021

Seems when the bracketed case have no space it will still fail:
time.Duration((c + 1) * 200) * time.Millisecond will pass,
time.Duration((c+1)*200) * time.Millisecond fails

@charithe
Copy link
Owner

Hmm...I can't reproduce that case. First of all, I had to disable gofmt to even type in the expression without spaces. When I eventually did, the linter was still happy. I can't see why it wouldn't be because it's using the AST produced by the Go parser and spaces are irrelevant to the parser.

@Gentoli
Copy link

Gentoli commented May 21, 2021

I am using https://github.com/golangci/golangci-lint to call durationcheck, maybe something is wrong on their side..

@charithe
Copy link
Owner

I still can't reproduce with either golangcl-lint (1.40.2) or the standalone linter. Weird! 🤷🏽

@Gentoli
Copy link

Gentoli commented May 25, 2021

I just realized golangcl-lint (1.40.1) is still on 0.6 🤦. Installing the latest resolved the issue. Thank you for checking 🙏.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants