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

Fix S2183: Add 2 exceptions to the rule to reduce the noise #777

Closed
jccollet opened this issue Sep 14, 2017 · 0 comments
Closed

Fix S2183: Add 2 exceptions to the rule to reduce the noise #777

jccollet opened this issue Sep 14, 2017 · 0 comments
Assignees
Labels
Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@jccollet
Copy link
Contributor

Implementation of RSPEC-2183 (Ints and longs should not be shifted by zero or more than their number of bits-1) is currently raising issues which can be perceived as noise. These issues should be removed.

Very often this is used for cosmetic reasons, to make the code more readable:

bytes[loc+0] = (byte)(value >> 8);
bytes[loc+1] = (byte)(value >> 0);

We can reduce the noise significantly by using the following 2 exceptions:

  • When the value shifted is a literal (e.g. 1 << 0)
  • When there is a similar shift at the same position in the line before or the line after (next or previous statement).
@jccollet jccollet added Area: Rules Type: False Positive Rule IS triggered when it shouldn't be. labels Sep 14, 2017
@jccollet jccollet added this to the 6.5 milestone Sep 14, 2017
@Evangelink Evangelink changed the title S2183: Add 2 exceptions Fix S2183: Add 2 exceptions to the rule to reduce the noise Sep 14, 2017
@Evangelink Evangelink self-assigned this Sep 14, 2017
@Evangelink Evangelink removed their assignment Oct 4, 2017
@Evangelink Evangelink removed this from the 6.5 milestone Oct 4, 2017
@michalb-sonar michalb-sonar added this to the 6.6 milestone Oct 16, 2017
@Evangelink Evangelink removed this from the 6.6 milestone Oct 25, 2017
@michalb-sonar michalb-sonar added this to the 6.8 milestone Jan 3, 2018
@michalb-sonar michalb-sonar self-assigned this Jan 4, 2018
@ghost ghost removed the Status: Needs Review label Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

3 participants