openhab / static-code-analysis

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

Using with Checkstyle extension for VS Code #391

Closed SRGDamia1 closed 2 years ago

SRGDamia1 commented 4 years ago

Is there any way to get at least the checkstyle portion of the tool to work with the checkstyle extension for VS Code? https://marketplace.visualstudio.com/items?itemName=shengchen.vscode-checkstyle

I can't figure out how to set up the extension so that it can find the modules needed for the custom rules.

Hilbrand commented 4 years ago

Did you try pointing to the raw rules file here: https://raw.githubusercontent.com/openhab/static-code-analysis/master/sat-plugin/src/main/resources/rulesets/checkstyle/rules.xml there are some other files, so it might not work perfectly.

SRGDamia1 commented 4 years ago

Yes. It gives errors and won't load the modules:

Module org.openhab.tools.analysis.checkstyle.ParameterizedRegexpHeaderCheck initialization failed. It may be caused by wrong configuraiton or incompatible version.

with further detail:

{"message":"cannot initialize module org.openhab.tools.analysis.checkstyle.ParameterizedRegexpHeaderCheck - Unable to instantiate 'org.openhab.tools.analysis.checkstyle.ParameterizedRegexpHeaderCheck' class, it is also not possible to instantiate it as null. Please recheck that class name is specified as canonical name or read how to configure short name usage https://checkstyle.org/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly."}

I tried pointing cloning and compiling this repo and then pointing it to the generated jar (openhab-codestyle-0.11.0-SNAPSHOT.jar) as a module but it gave the same error.

wborn commented 2 years ago

Try using the checkstyle-0.12.0.jar as module instead. That JAR contains the custom openHAB check classes. The codestyle JAR is only used by the spotless Maven plugin.