openhab / static-code-analysis

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

Exclude swagger auto generated files from code analysis #438

Closed andrewfg closed 2 years ago

andrewfg commented 2 years ago

Refers to https://github.com/openhab/openhab-addons/issues/12498

Background

The tado binding uses Swagger code gen to dynamically create java source files for inclusion in the binding. The OH code style analysis produces about four hundred style warning messages those generated files. And I see no way to modify Swagger code gen to produce code which is acceptable to the OH code style analyser.

Solution

My suggestion is to add a filter to OH code analysis settings to exclude the tado swagger generated code directory from its analysis scope..

Exclude folder: openhab-addons\bundles\org.openhab.binding.tado\target\generated-sources\

wborn commented 2 years ago

The OH code style analysis produces about four hundred style warning messages those generated files

It's the compiler that generates these warnings not SAT:

[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ org.openhab.binding.tado ---
[INFO] Changes detected - recompiling the module!
[WARNING] /home/wouter/git/openhab/openhab-addons/bundles/org.openhab.binding.tado/target/generated-sources/swagger/src/main/java/org/openhab/binding/tado/internal/api/model/MobileDevice.java:[4,8] The import java.util.Arrays is never used
[WARNING] /home/wouter/git/openhab/openhab-addons/bundles/org.openhab.binding.tado/target/generated-sources/swagger/src/main/java/org/openhab/binding/tado/internal/api/model/MobileDevice.java:[6,8] The import com.google.gson.TypeAdapter is never used
[WARNING] /home/wouter/git/openhab/openhab-addons/bundles/org.openhab.binding.tado/target/generated-sources/swagger/src/main/java/org/openhab/binding/tado/internal/api/model/MobileDevice.java:[7,8] The import com.google.gson.annotations.JsonAdapter is never used
[WARNING] /home/wouter/git/openhab/openhab-addons/bundles/org.openhab.binding.tado/target/generated-sources/swagger/src/main/java/org/openhab/binding/tado/internal/api/model/MobileDevice.java:[8,8] The import com.google.gson.annotations.SerializedName is never used
...

SAT thinks the binding is almost in excellent condition :slightly_smiling_face: :+1: :

Screenshot from 2022-07-09 15-16-30