This rule raises an issue when list() calls are applied to types that are already directly iterable with for-loops or
comprehensions.
When iterating over an already iterable object with a for loop or a comprehension, wrapping it with list() adds meaningless clutter
that doesn’t provide any functional value. Additionally, it creates unnecessary overhead by generating an intermediate list in memory, which
inefficiently consumes memory and can degrade performance, especially with large data structures. Iterating directly over the original object is
cleaner and more efficient.
Remove the redundant list() call and iterate directly over the original iterable.
some_iterable = range(10)
for i in list(some_iterable): # Noncompliant: unnecessary list() call
print(i)
some_iterable = range(10)
for i in some_iterable: # Compliant
print(i)