rspec/rules/S2133/java/rule.adoc

27 lines
507 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
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.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
MyObject myOb = new MyObject(); // Noncompliant
Class c = myOb.getClass();
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
Class c = MyObject.class;
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]