Static Code Analysis Tool


(Kai Kreuzer) #61

Which is really an ugly workaround that we should address in some better way. The static analysis is correct to mark it as an error as it is against the “standard” coding guidelines.

The xsd states the minimum number of parameter elements is 0 - not 1

Indeed. @svilenvul Could you check why this error is reported?


(Martin van Wingerden) #62

@chris is this about the version at: https://github.com/openhab/org.openhab.binding.zwave/blob/development/ESH-INF/thing/_controller_serial.xml


(Chris Jackson) #63

Yes - but this was just an example - this error is indicated 500+ times as it’s in nearly every zwave thing definition.


(Chris Jackson) #64

Yes, but do you have any ideas? I remember we spent quite a lot of time looking at how to configure the repository and this was the only solution we had at the time. Maybe there are better tools/concepts out there now?


(Martin van Wingerden) #65

But I see a config-description containing both parameter-group and parameter elements, just like for example: https://github.com/openhab/openhab2-addons/blob/f354e7204be87f7ffe0abc2ce17e24344d09232f/addons/binding/org.openhab.binding.zoneminder/ESH-INF/config/zoneminderserver.xml

I believe that xs:sequence states that elements have an order, you must first define all the groups, then all the parameters. [source]

The sequence element specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times.

Can you test that for one of the files?


(Chris Jackson) #66

Yes, you’re right - thanks. I guess the Eclipse checker is not so strict :wink:


(Kai Kreuzer) #67

My suggestion would be this and that. The mockito optional dependencies are not ideal in the manifest, but I think it is something we can live with.

The static analysis nonetheless still gives more than 500 errors - you should spend some time on that :slight_smile:


(Karel Goderis) #68

I am running the SCA tool, and I get this on a .md file:

[ERROR] Failed to execute goal org.openhab.tools:static-code-analysis:0.3.0:checkstyle (default) on project org.openhab.binding.exec: Unable to execute mojo: An error has occurred in Checkstyle report generation. Failed during checkstyle configuration: Exception was thrown while processing /Users/kgoderis/openhab2-master/git/openhab2-addons/addons/binding/org.openhab.binding.exec/README.md: NullPointerException -> [Help 1]

What could this be?


(Martin van Wingerden) #69

Does running it with a debug flag give some more information like a stacktrace?

mvn clean install -X


(Karel Goderis) #70

Nope

[ERROR] Failed to execute goal org.openhab.tools:static-code-analysis:0.3.0:checkstyle (default) on project org.openhab.binding.exec: Unable to execute mojo: An error has occurred in Checkstyle report generation. Failed during checkstyle configuration: Exception was thrown while processing /Users/kgoderis/openhab2-master/git/openhab2-addons/addons/binding/org.openhab.binding.exec/README.md: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.openhab.tools:static-code-analysis:0.3.0:checkstyle (default) on project org.openhab.binding.exec: Unable to execute mojo
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to execute mojo
	at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:96)
	at org.openhab.tools.analysis.tools.AbstractChecker.executeCheck(AbstractChecker.java:106)
	at org.openhab.tools.analysis.tools.CheckstyleChecker.execute(CheckstyleChecker.java:123)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	... 20 more
Caused by: org.apache.maven.plugin.MojoExecutionException: An error has occurred in Checkstyle report generation.
	at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:171)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:94)
	... 24 more
Caused by: org.apache.maven.reporting.MavenReportException: Failed during checkstyle configuration
	at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:488)
	at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:154)
	at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:255)
	at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:143)
	... 26 more
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing /Users/kgoderis/openhab2-master/git/openhab2-addons/addons/binding/org.openhab.binding.exec/README.md
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:295)
	at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:213)
	at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:252)
	at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:473)
	... 29 more
Caused by: java.lang.NullPointerException
	at java.lang.String.contains(String.java:2133)
	at org.openhab.tools.analysis.checkstyle.api.AbstractStaticCheck.findLineNumber(AbstractStaticCheck.java:69)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownCheck.access$000(MarkdownCheck.java:63)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownCheck$1.findLineNumber(MarkdownCheck.java:116)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownVisitor.markDownListProcessing(MarkdownVisitor.java:216)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownVisitor.processListBlock(MarkdownVisitor.java:187)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownVisitor.visit(MarkdownVisitor.java:198)
	at org.commonmark.node.BulletList.accept(BulletList.java:9)
	at org.commonmark.node.AbstractVisitor.visitChildren(AbstractVisitor.java:132)
	at org.commonmark.node.AbstractVisitor.visit(AbstractVisitor.java:28)
	at org.commonmark.node.Document.accept(Document.java:7)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownCheck.checkReadMe(MarkdownCheck.java:126)
	at org.openhab.tools.analysis.checkstyle.readme.MarkdownCheck.processFiltered(MarkdownCheck.java:81)
	at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:79)
	at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:316)
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:286)
	... 32 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :org.openhab.binding.exec

(Martin van Wingerden) #71

@svilenvul can you assist @kgoderis?


(Svilenvul) #72

For me it seems to be a problem in the check. Let’s continue it in: https://github.com/openhab/static-code-analysis/issues/244