Unresolved imports/types have been detected during analysis

Hi guys,
following the details of my issue:

  • Sonarqube server version: 8.9 LTS
  • SonarScanner: Gradle plugin 3.2.0
  • Java version: zulu8.48.0.53-ca-fx-jdk8.0.265-linux_x64

ERROR observed:

     09:51:01.924 [WARN] [org.sonarqube.gradle.SonarQubeTask] Unresolved imports/types have been 
     detected during analysis. Enable DEBUG mode to see them.
     09:51:01.925 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Unresolved imports/types:
     - __ cannot be resolved to a type
     - log cannot be resolved

PIECE OF CODE affected:

 @Slf4j
 @RequiredArgsConstructor(onConstructor = @__(@Autowired))
 public class XXXX {
 	public void blaBla() {
 		doSomethingh();
 		log.debug("here I log something");
 	}
 }

Seems that because of the 2 lombok annotations the gradleScanner got some strange WARN…
There’s already a solution for this? If not can be addressed?

Thanks

Hey @andreatera ,

Thanks for reporting this.

These warnings are raised when our Java parser does not recognize some types and can not find them in bytecode.
Lombok, precisely, has deep impacts on bytecode (the bytecode of the annotated class does not reflect the actual code that we parse), altering the way you write Java code, and confusing our parser. Our parser requires valid compilable java code as input, and this code can not be compiled with javac “as is”.

More precisely, the annotation @__ is actually not defined anywhere, and the log field is only generated in the bytecode thanks to @Slf4j annotation.

In your case, however,there is nothing to worry about these warnings, they are to be expected when using Lombok, and there is not much we/you can do about it. Feel free to ignore them.

Hope this helps,
Michael

2 Likes

thanks @Michael clear :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.