rspec/rules/S2133/java/rule.adoc
2021-04-28 18:08:03 +02:00

19 lines
346 B
Plaintext

Creating an object for the sole purpose of calling ``++getClass++`` on it is a waste of memory and cycles. Instead, simply use the class' ``++.class++`` property.
== Noncompliant Code Example
----
MyObject myOb = new MyObject(); // Noncompliant
Class c = myOb.getClass();
----
== Compliant Solution
----
Class c = MyObject.class;
----