resources.report.rules.pmd.InstantiationToGetClass.html Maven / Gradle / Ivy
InstantiationToGetClass
InstantiationToGetClass
Avoid instantiating an object just to call getClass() on it; use the .class public member instead.
//PrimarySuffix
[@Image='getClass']
[parent::PrimaryExpression
[PrimaryPrefix/AllocationExpression]
[count(PrimarySuffix) = 2]
]
Example(s):
// replace this
Class c = new String().getClass();
// with this:
Class c = String.class;