Skip to content

Conversation

@fourls
Copy link
Collaborator

@fourls fourls commented Apr 23, 2025

Fixes #95. I haven't added this to the Sonar way quality profile, but it probably could be added depending on how noisy it is. I'll run some tests and see.

@fourls fourls requested a review from cirras April 23, 2025 05:17
@cirras
Copy link
Collaborator

cirras commented Apr 23, 2025

I'd definitely lean towards the default quality profile since this is a common bug pattern.

@fourls
Copy link
Collaborator Author

fourls commented Apr 24, 2025

  • Added to the default quality profile, and
  • Added a test that Pred(X.Count) does not add an issue

Copy link
Collaborator

@cirras cirras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interest of leaning away from false positives, I think we should make this rule more conservative and only flag cases where low = 0 and high = count.

We can then iteratively make it smarter and broader if we see ways to do so without introducing noise/FPs.

@fourls fourls force-pushed the length-minus-1 branch from 2c5b0fc to 64e6135 Compare May 6, 2025 03:23
@fourls fourls requested a review from cirras May 6, 2025 03:23
@fourls
Copy link
Collaborator Author

fourls commented May 6, 2025

Updated to only flag cases where low = 0.

Copy link
Collaborator

@cirras cirras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. 👍

@cirras cirras merged commit 4799e37 into master May 6, 2025
4 checks passed
@cirras cirras deleted the length-minus-1 branch May 6, 2025 03:38
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 this pull request may close these issues.

New rule: Array iteration should be in range

4 participants