SonarCloud Warning - Type is unavailable for declaration FUN]

  • ALM used Azure DevOps
  • CI system used Azure DevOps
  • Scanner command used when applicable (private details masked)
  • Languages of the repository Java
  • Error observed
    ``` ERROR Cannot analyse 'data/src/main/java/**//DataModules.kt’ with ‘KtChecksVisitor’: Expected unresolved ErrorType but UNAVAILABLE_TYPE_FOR_DECLARATION found for [Error type: Type is unavailable for declaration FUN]

Any suggestions how to fix the warning?

Hey there.

Can you share this specific file? I can also open up a private message if you aren’t comfortable sharing it publicly.

If you need to exclude this file from analysis for now, you can always adjust the analysis scope.

I don’t want to exclude the file in analysis scope. Please open a private message session, I will share the file.

@Colin Can you please share the link to upload file?

I sent you a private message.

You can find it here!

Hello @RamaKrishna,

From the logs I can see that you analyze your project using scanner cli. For the JVM based projects if they’re using Maven or Gradle, we recommend to used scanners for Maven or Gradle. If this is your case, could you please try analyzing the project with the specific scanner.

A few side notes:

  • To analyze Jvm-based languages properly, Sonar analysis needs classpath. Maven/Gradle plugins set them automatically, for SonarScanner you need to set classpath manualy.
  • If classpath (sonar.java.binaries) is not set Java Sensor will fail.
  • I don’t see Java Sensor in the logs, so looks like you don’t actually analyze your Java files.
  • I also see many excluded sources (probably all Java sources)

About your issue:

Looks like it might happen because your project is misconfigured. To solve this either use scanners for Maven/Gradle. If you can’t use them, please, make sure you provide properties (sonar.java.binaries and sonar.java.libraries), so the analyzer can pick up the classpath. And get back to me with the results.

Meanwhile, I will have a look at your source file, maybe I will be able to reproduce the issue, if there’s indeed a bug there.

Best,
Margarita