Sonarqube error java.lang.ClassCastException: org.sonar.java.resolve.SemanticModel could not be added to org.sonar.java.resolve.SemanticModel

Hi, I wrote my own plugin for sonar 5.1.2 based on some checks from java-web-plugin 3.5 (dependency in pom for java-checks 3.5), and when I try to run analysis on a project, I get an error:

Caused by: java.lang.ClassCastException: org.sonar.java.resolve.SemanticModel cannot be cast to org.sonar.java.resolve.SemanticModel
    at org.sonar.java.checks.SubscriptionBaseVisitor.scanFile(SubscriptionBaseVisitor.java:32)
    at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:123)
    at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:94)
    ... 38 more

for example, I copied my plugin code from BadMethodName_S00100_Check.java and changed only the class name, description and information about the problem. Why am I getting an error? Other checks that do not use semanticModel work fine.

+4
source share
1 answer
+3

Source: https://habr.com/ru/post/1607671/


All Articles