rspec/rules/S1847/rule.adoc

31 lines
511 B
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
To remove all the elements of a collection ``++c++`` the method ``++c.clear()++`` should be used. Calling the method ``++c.removeAll(c)++`` will lead to the same result but with a high CPU overhead.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,text]
----
c.removeAll(c);
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,text]
----
c.clear();
----
2022-01-25 18:36:46 +01:00
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== duplicates: S2114
2022-01-25 18:36:46 +01:00
endif::env-github,rspecator-view[]