Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

shorthand_operator: false positive: seconds = seconds * 60 + value #1254

Closed
dusek opened this issue Jan 27, 2017 · 4 comments
Closed

shorthand_operator: false positive: seconds = seconds * 60 + value #1254

dusek opened this issue Jan 27, 2017 · 4 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@dusek
Copy link

dusek commented Jan 27, 2017

seconds = seconds * 60 + value

We don't want to rewrite it to

seconds *= 60
seconds += value

as that is simply 2 lines and somehow destroys the code and mind flow.

Swiflint: 0.16.1

@marcelofabri marcelofabri added the repro-needed Issues that cannot be reproduced or miss proper descriptive examples. label Jan 27, 2017
@marcelofabri
Copy link
Collaborator

Are you sure you're using 0.16.1? This should be fixed on it (and I couldn't reproduce it).

@dusek
Copy link
Author

dusek commented Jan 28, 2017

@marcelofabri I am using 0.16.1. However I made mistake in the repro in this issue, I am very sorry. My original comment is now updated with the correct repro.

@marcelofabri
Copy link
Collaborator

@dusek Thanks for updating, I could reproduce it now.

For now, you can either wrap the multiplication in parentheses (seconds = (seconds * 60) + value) or change the order of operands (seconds = 60 * seconds + value) to prevent this false positive.

@marcelofabri marcelofabri added bug Unexpected and reproducible misbehavior. and removed repro-needed Issues that cannot be reproduced or miss proper descriptive examples. labels Jan 28, 2017
@dusek dusek changed the title shorthand_operator: false positive: seconds = 60*seconds + value shorthand_operator: false positive: seconds = seconds * 60 + value Feb 2, 2017
sammy-SC added a commit to sammy-SC/SwiftLint that referenced this issue Apr 2, 2017
`seconds = seconds * 60 + value` is no longer triggered

see realm#1254
@farzadshbfn
Copy link

using 0.18.1 and this problem still exists.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

3 participants