-
Notifications
You must be signed in to change notification settings - Fork 30
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
Create rule S7200: Avoid resizing a vector to zero using vec.resize(0, value)
#4677
base: master
Are you sure you want to change the base?
Conversation
vec.resize(0, value)
0df66fa
to
d8aaa9d
Compare
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.
Looks good to me! I've left a comment regarding the classification of the rule.
rules/S7200/rust/metadata.json
Outdated
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "5min" | ||
}, | ||
"tags": [ | ||
"clippy", | ||
"vec_resize_to_zero" | ||
], | ||
"defaultSeverity": "Major", | ||
"ruleSpecification": "RSPEC-7200", | ||
"sqKey": "S7200", | ||
"scope": "All", | ||
"defaultQualityProfiles": ["Sonar way"], | ||
"quickfix": "unknown", | ||
"code": { | ||
"impacts": { | ||
"MAINTAINABILITY": "LOW" |
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.
This rule seems like a correctness issue to me and not merely a code smell. If you write vec.resize(0, 5)
(a vector of size 0) and meant vec.resize(5, 0)
(a vector with a size of 5 possibly extended with zeros) this will be a bug. What do you think?
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.
Yes, you are absolutely right. I will change the type to bug.
|
|
You can preview this rule here (updated a few minutes after each push).
Review
A dedicated reviewer checked the rule description successfully for: