-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
S1000: don't suggest for range
when case statement has side effects
#503
Comments
Theoretically this is a false positive (because the case statement contains a function call), yes. Practically, this only affects the output message of the check. If it weren't for the I.e., the concrete alternative would be
I will repurpose this issue to document the fact we need to improve what message S1000 emits. |
for range
when case statement has side effects
I just ran into this, the cool thing is I learned something from the warning, I really like this idea from @dominikh: |
I was bitten by this too. I was told that my |
Thank you camerone! I love you! Just saved so much time! |
Also ran into this recently, in my case:
Don't think the warning here is valid either because I'm pretty sure you can't do a:
I think that's syntactically incorrect? |
Maybe if you keep the 'for', but remove the 'select' and turn it into an 'if'. You wouldn't need the range operator. |
Good point, I think I had this structure with the intent of adding another |
* Adds `odo dev --no-watch` * Remove select for a single case More details on - dominikh/go-tools#503 (comment) * Update mocks * Update tests/integration/devfile/cmd_dev_test.go Co-authored-by: Armel Soro <[email protected]> * Rename CleanupFunc to Cleanup * Add usage doc for --no-watch * Remove infinite for loop Co-authored-by: Armel Soro <[email protected]>
* Adds `odo dev --no-watch` * Remove select for a single case More details on - dominikh/go-tools#503 (comment) * Update mocks * Update tests/integration/devfile/cmd_dev_test.go Co-authored-by: Armel Soro <[email protected]> * Rename CleanupFunc to Cleanup * Add usage doc for --no-watch * Remove infinite for loop Co-authored-by: Armel Soro <[email protected]>
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@dominikh Was the documentation updated without updating the actual tool output? I got this lint, googled "golang s1000 for range select" (because the warning came from my IDE and I didn't know it originated in The documentation is helpful, but the tool still suggests |
The two examples (ignoring side-effects changing what channel is being received from) only differ in behavior if the channel gets closed. And if it does get closed, the The documentation hasn't been changed, it is merely incomplete. It only covers one of the two distinct diagnostics that S1000 can emit. S1000 recommends that
be turned into a simple and it recommends that
be turned into |
* introduce messenger and toEngine channel * get rid of avalanchego libs, add toEngine * get rid of grpcutils * regenerate proto files with buf 1.31.0 * close goroutine that listen toEngine * add transport credentials * add http import * use mock for gRPC client connection for unit tests * mempool handler: trigger `toEngine` channel when transaction appear in mempool * fix static check error: should use for range instead of for { select {} } (S1000) dominikh/go-tools#503 (comment) --------- Co-authored-by: Ivan Sukach <[email protected]> Co-authored-by: ramil <[email protected]>
S1000: should use for range instead of for { select {} }
I get this lint error on this code:
How does range replace a for(ever) loop? This seems like a false positive to me. Or the description needs to be better at least? How is gosimple suggesting this should be fixed?
The text was updated successfully, but these errors were encountered: