-
Notifications
You must be signed in to change notification settings - Fork 30
SONAPPY-2876: Create rule S7504: Using \"list()\" on already iterable objects is unnecessary and inefficient #5035
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
base: master
Are you sure you want to change the base?
Conversation
f6d4858
to
4a25880
Compare
4a25880
to
f8fde33
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.
LGTM. Just a small comments to make the rule a bit clearer.
rules/S7504/python/metadata.json
Outdated
@@ -0,0 +1,23 @@ | |||
{ | |||
"title": "Using \"list()\" on already iterable objects is unnecessary and inefficient", |
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.
Here for the shape of the title it should be something like
"title": "Using \"list()\" on already iterable objects is unnecessary and inefficient", | |
"title": "Using \"list()\" on already iterable objects should be avoided", |
rules/S7504/python/rule.adoc
Outdated
|
||
== Why is this an issue? | ||
|
||
Using `list()` on already iterable objects adds meaningless code clutter that doesn't provide any functional value when wrapping an already iterable object. Additionally, it creates unnecessary overhead by generating an intermediate list in memory, which inefficiently consumes memory resources and can degrade performance, especially with large data structures. Iterating directly over the original object is cleaner and more efficient. |
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 looks good I would just specify more clearly that we mean in for loops. Maybe starting the sentence with: When using for loops...
b1ff123
to
58c8f3a
Compare
58c8f3a
to
89d55da
Compare
|
|
You can preview this rule here (updated a few minutes after each push).
Review
A dedicated reviewer checked the rule description successfully for: