2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-06-08 14:23:48 +02:00
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.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2021-06-08 14:23:48 +02:00
----
c.removeAll(c);
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2021-06-08 14:23:48 +02:00
----
c.clear();
----
2022-01-25 18:36:46 +01:00
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== duplicates: S2114
2022-01-25 18:36:46 +01:00
endif::env-github,rspecator-view[]