-
Notifications
You must be signed in to change notification settings - Fork 29
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
NET-913 Modify rule S1264: Improve description to match the implementation #4587
Conversation
0824772
to
314fb16
Compare
314fb16
to
69277e1
Compare
Quality Gate passed for 'rspec-tools'Issues Measures |
Quality Gate passed for 'rspec-frontend'Issues Measures |
---- | ||
int i; | ||
|
||
for (i = 0; i < 10;) // Noncompliant; the initializer section should contain a variable declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the message correct? the initializer section should contain a variable declaration
Shouldn't it be the initializer section should contain an increment statement
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initializer section here contains only an initialization without a variable declaration.
The increment section is missing in this example.
The wording could be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the rule reporting also for missing variable declarations?
ie:
var i;
for (i = 0; i <100; i++) { }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not it won't, for now it is checking if both the initializer and the increment section are valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then // Noncompliant; the initializer section should contain a variable declaration
is not a good comment. It shouldn't raise for that and it's not why the rule is raising in that case, it's just the missing incrementer. Do I miss something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does raise because of the missing declaration.
If there were a variable declaration, the rule won't raise even though there is no incrementer.
The condition for the rule to raise is:
- missing initialization section
- and, missing increment section
In the rule we check if there is a variable declaration.
So if the content of the initialization section is not a declaration and the increment section is empty, we raise the rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will drop this example, it brings more confusion than it helps to understand the rule.
I have added in the description the following:
The initializer section should contain a variable declaration to be considered as a valid initialization.
And I think this should be enough for this case then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
NET-913
Part of NET-255
Fixes SonarSource/sonar-dotnet#8249
Review
A dedicated reviewer checked the rule description successfully for: