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

Backwards for-loop boundary check #750

Open
ynsehoornenborg opened this issue Feb 5, 2024 · 0 comments
Open

Backwards for-loop boundary check #750

ynsehoornenborg opened this issue Feb 5, 2024 · 0 comments
Labels
new analyzer New Diagnostic Analyzer

Comments

@ynsehoornenborg
Copy link
Contributor

ynsehoornenborg commented Feb 5, 2024

A very common mistake when defining backwards for-loops, is the loop condition:

for (var index = list.Count - 1; index > 0; index--) {
    // Code here...
}

Where this is meant:

for (var index = list.Count - 1; index >= 0; index--) {
    // Code here...
}
@ynsehoornenborg ynsehoornenborg added the new analyzer New Diagnostic Analyzer label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new analyzer New Diagnostic Analyzer
Projects
None yet
Development

No branches or pull requests

1 participant