openhab / static-code-analysis

Maven tooling for static code analysis
https://www.openhab.org/
Other
32 stars 21 forks source link

Fix UseSLF4JLoggerRule throws NPEs with Java 10+ var type #382

Closed wborn closed 4 years ago

wborn commented 4 years ago

The PMD type resolution for inferred types using the var keyword is very simple (see Java 10 Support). As a result it's usually not possible to get the type of such variables during analysis. So for now it's probably best to make sure not any NPEs occur whenever the type cannot be inferred. Since var can only be used with local variables, it's not likely loggers will be instantiated often this way.

Fixes #379


Draft because this builds upon the changes made in UseSLF4JLoggerRule part of https://github.com/openhab/static-code-analysis/pull/380

wborn commented 4 years ago

I assume, everything is then ready for the new SAT release.

Yes I think it's all ready now! :slightly_smiling_face: