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

Rule Request: [HashValue overflow] #2108

Closed
2 tasks done
kimdv opened this issue Mar 23, 2018 · 1 comment · Fixed by #2496
Closed
2 tasks done

Rule Request: [HashValue overflow] #2108

kimdv opened this issue Mar 23, 2018 · 1 comment · Fixed by #2496
Labels
rule-request Requests for a new rules.

Comments

@kimdv
Copy link
Contributor

kimdv commented Mar 23, 2018

New Issue Checklist

Rule Request

I don't know 100% if this should be a rule, but it is possible in swift to overflow hash value by doing "test-1".hashValue + "test-2".hashValue

And for avoiding it it should be done like this "test-1".hashValue &+ "test-2".hashValue

It should be a optional rule.

It could prevent some crashes that people don't think about :)

@SDGGiesbrecht
Copy link
Contributor

Maybe more in general, within computed properties named hashValue, prohibit all known checked operations (+, *, etc.) and recommend their unchecked variants (&+, &*, etc.)?


It should be a optional rule.

I cannot think of any reasonable hashing situation where the checked variations would actually be better. Such a rule may as well be on by default.

@marcelofabri marcelofabri added the rule-request Requests for a new rules. label Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants