
de.jball.sonar.hybris.java.checks.ModelConstructor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-hybris Show documentation
Show all versions of sonar-hybris Show documentation
SonarQube Rules for Hybris
package de.jball.sonar.hybris.java.checks;
import org.sonar.check.Rule;
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
import org.sonar.plugins.java.api.semantic.Type;
import org.sonar.plugins.java.api.tree.NewClassTree;
import org.sonar.plugins.java.api.tree.Tree;
import java.util.Collections;
import java.util.List;
@Rule(key = "ModelConstructor")
public class ModelConstructor extends IssuableSubscriptionVisitor {
private static final List NODES_TO_VISIT = Collections.singletonList(Tree.Kind.NEW_CLASS);
@Override
public List nodesToVisit() {
return NODES_TO_VISIT;
}
@Override
public void visitNode(final Tree tree) {
NewClassTree newClassTree = (NewClassTree) tree;
Type typeOfNewObject = newClassTree.symbolType();
if (typeOfNewObject.is("de.hybris.platform.core.model.ItemModel") || typeOfNewObject.isSubtypeOf("de.hybris.platform.core.model.ItemModel")) {
reportIssue(tree, "Use \"modelService.create()\" instead.");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy