You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rule AvoidInstantiatingObjectsInLoops flags a problem if the code creates an object in a loop using the new operator. I suggest creating a rule called AvoidCloningObjectsInLoops that flags a problem if the code calls Cloneable.clone() in a loop since this call will create a new object.
Code Sample demonstrating the issue:
Here is a code sample. The original code was adapted from AvoidInstantiatingObjectsInLoops.
public class Something {
public static void main( String as[] ) {
for (int i = 0; i < 10; i++) {
String copy[] = as.clone(); // Avoid this whenever you can it's really expensive
}
}
}
Running PMD through: Eclipse
The text was updated successfully, but these errors were encountered:
Affects PMD Version: 6.21.0
Rule:
AvoidCloningObjectsInLoops
Description:
The rule
AvoidInstantiatingObjectsInLoops
flags a problem if the code creates an object in a loop using thenew
operator. I suggest creating a rule calledAvoidCloningObjectsInLoops
that flags a problem if the code callsCloneable.clone()
in a loop since this call will create a new object.Code Sample demonstrating the issue:
Here is a code sample. The original code was adapted from
AvoidInstantiatingObjectsInLoops
.Running PMD through: Eclipse
The text was updated successfully, but these errors were encountered: