Why method Symbol is MISSING


like above.
and my pom is

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.sonar</groupId>
  <artifactId>MySonarProject</artifactId>
  <packaging>sonar-plugin</packaging>
  <version>0.0.3</version>

  <name>SonarQube Java :: Documentation :: Custom Rules Example</name>
  <description>Java Custom Rules Example for SonarQube</description>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <!-- MAIN sources dependencies -->
    <dependency>
      <groupId>org.sonarsource.sonarqube</groupId>
      <artifactId>sonar-plugin-api</artifactId>
      <version>7.9</version>
      <scope>compile</scope>
    </dependency>
<!--    -->

<!--    <dependency>-->
<!--      <groupId>org.eclipse.jdt</groupId>-->
<!--      <artifactId>org.eclipse.jdt.core</artifactId>-->
<!--      <version>3.20.0</version>-->
<!--      <exclusions>-->
<!--        <exclusion>-->
<!--          <artifactId>org.eclipse.equinox.app</artifactId>-->
<!--          <groupId>org.eclipse.platform</groupId>-->
<!--        </exclusion>-->
<!--        <exclusion>-->
<!--          <artifactId>org.eclipse.equinox.registry</artifactId>-->
<!--          <groupId>org.eclipse.platform</groupId>-->
<!--        </exclusion>-->
<!--      </exclusions>-->
<!--            <classifier>shaded</classifier>-->
<!--    </dependency>-->
    <!-- TEST sources dependencies -->
    <dependency>
      <groupId>org.sonarsource.java</groupId>
      <artifactId>java-checks-testkit</artifactId>
      <version>6.3.3-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>5.6.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.sonarsource.analyzer-commons</groupId>
      <artifactId>sonar-analyzer-recognizers</artifactId>
      <version>1.11.0.541</version>
      <exclusions>
        <exclusion>
          <artifactId>jsr305</artifactId>
          <groupId>com.google.code.findbugs</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.analyzer-commons</groupId>
      <artifactId>sonar-xml-parsing</artifactId>
      <version>1.11.0.541</version>
      <exclusions>
        <exclusion>
          <artifactId>jsr305</artifactId>
          <groupId>com.google.code.findbugs</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.analyzer-commons</groupId>
      <artifactId>sonar-analyzer-test-commons</artifactId>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>junit</artifactId>
          <groupId>junit</groupId>
        </exclusion>
        <exclusion>
          <artifactId>jsr305</artifactId>
          <groupId>com.google.code.findbugs</groupId>
        </exclusion>
      </exclusions>
      <version>1.11.0.541</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>0.9.30</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>2.21.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>26.0-jre</version>
      <exclusions>
        <exclusion>
          <artifactId>jsr305</artifactId>
          <groupId>com.google.code.findbugs</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-migrationsupport</artifactId>
      <version>5.6.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.8.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.sonarsource.sslr</groupId>
      <artifactId>sslr-testing-harness</artifactId>
      <version>1.23</version>
      <exclusions>
        <exclusion>
          <artifactId>junit</artifactId>
          <groupId>junit</groupId>
        </exclusion>
        <exclusion>
          <artifactId>guava</artifactId>
          <groupId>com.google.guava</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
        <artifactId>sonar-packaging-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <pluginKey>java-custom</pluginKey>
          <pluginName>Java Custom Rules</pluginName>
          <pluginClass>org.sonar.samples.java.MyJavaRulesPlugin</pluginClass>
          <sonarLintSupported>true</sonarLintSupported>
          <!-- FIXME: https://jira.sonarsource.com/browse/SLCORE-315 -->
          <!-- SonarLint currently supports only up to SQ 8.5, instead of 8.9 LTS -->
          <sonarQubeMinVersion>7.9</sonarQubeMinVersion>
          <requirePlugins>java:${project.version}</requirePlugins>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>

      <!-- only required to run UT - these are UT dependencies -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>test-compile</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.slf4j</groupId>
                  <artifactId>slf4j-api</artifactId>
                  <version>1.7.30</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.apache.commons</groupId>
                  <artifactId>commons-collections4</artifactId>
                  <version>4.0</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>javax</groupId>
                  <artifactId>javaee-api</artifactId>
                  <version>6.0</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-webmvc</artifactId>
                  <version>4.3.3.RELEASE</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-web</artifactId>
                  <version>4.3.3.RELEASE</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-context</artifactId>
                  <version>4.3.3.RELEASE</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.13.2</version>
                  <type>jar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>com.google.guava</groupId>
                  <artifactId>guava</artifactId>
                  <version>26.0</version>
                  <type>jar</type>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/test-jars</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

I want to create one custom rules project. The other source codes, such as ‘java-checks-testkit’ , are dependent through maven dependencies.
The problem, MISSTYPE, causes the failure of getting annotation Test’s full qualified name, so the annotation Test etc. which should been found in TEST_ANNOTATIONS or JUNIT5_TEST_ANNOTATIONS cannot find now.

Hello @husky

You might want to have a look at this post: Setting up custom sonar rule for Annotations - #6 by Quentin

Hope it helps.
Quentin

Thank you very much.
I read the that post, and I should add all dependencies that will be used in my tests to ‘maven-dependency-plugin’? I add Junit5’s junit-jupiter in ‘maven-dependency-plugin’, and the external library exist in my project. But when I test the tests programmed with Junit5 only, it still does’t work…

A last check: did you correctly set up the classpath during the test?

If yes, I’m unsure how to help you further without having access to the whole project. Is it something you could consider?

emmmm, I tried to set up classpath, but like before. I send you an email with my project, but the sending be refused because of attach over size. Anyway, thank you very much!!! I will attempt to find other ways.

MySonarProject.zip (353.7 KB)
oh!!! I find that I can upload one project. I upload it!

I played a bit with your project and it seems to me that everything is behaving as expected. Could you explain in more detail what you are doing, and what you would expect?

The test dependencies that you set up should be present in \target\test-jars. If the folder does not exist or does not contain all the dependencies, make sure you are correctly building the project before running the tests in the IDE.

thank you very very very much! It works finally. :laughing: I execute mvn install and then the folder \target\test-jars appears in my project. Thank your great patience and help!

1 Like