SonarQube v8.9 (build 43852) complains that we should “Initialize mocks before using them”:
However, as the outer class is annotated as instructed (Rules explorer) this seems to be a false positive?
SonarQube v8.9 (build 43852) complains that we should “Initialize mocks before using them”:
However, as the outer class is annotated as instructed (Rules explorer) this seems to be a false positive?
Hello @fniessink
This issue looks really similar to SONARJAVA-3687, which should already be solved in SonarQube 8.9.
Can you confirm that:
@Nested is from JUnit 5 (org.junit.jupiter.api.Nested)?Unresolved imports/types have been detected during analysis, [...]
Thanks
Hi @Quentin,
@Nested is indeed from org.junit.jupiter.api.Nested.Thanks, Frank
Thank you for the clarifications.
These logs are independent of the rule, if types are missing, you should still be able to see warnings even when the rule is not enabled.
For the record, we decided to remove this rule from the default profile. In any case, it seems worth checking that the types are correctly resolved since it can have an impact on other rules as well.
Found them. I see several log lines like these:
[ERROR] Unable to parse source file : ‘foo.java’
[ERROR] Parse error at line 87 column 54: Lambda expressions are allowed only at source level 1.8 or above
[ERROR] Unable to parse source file : ‘bar.java’
[ERROR] Parse error at line 56 column 44: Lambda expressions are allowed only at source level 1.8 or above
[INFO] 46/46 source files have been analyzed
[WARNING] Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
As I see several instances of errors like above followed by the unresolved imports/types warning I’m wondering whether they are related? Anyway, I’ll turn on DEBUG mode for more info.
They may be related indeed, if the rule needs a type that is unresolved, it can be confused.
I suspect here that a few properties are missing in your configuration. Are you using the default SonarScanner or another one (ex: the Scanner for maven)?
By the way, when possible, you should always try to use the one matching your build system.
If you are using SonarScanner anyway, you might want to check the different properties (see documentation), mainly: