Skip to content
Browse files

Add Static code analysis tool to ESH build (#3995)

* Static analysis added to ESH build

Signed-off-by: Svilen Valkanov <>
  • Loading branch information...
svilenvul authored and kaikreuzer committed Sep 5, 2017
1 parent 89a78cb commit b0812c2e760d9b25533c55d38c0f14dd1c6cab3f
@@ -9,7 +9,7 @@ before_install: echo "MAVEN_OPTS='-Xms1g -Xmx2g -XX:PermSize=512m -XX:MaxPermSiz
#$ mvn test -B

- echo 'mvn clean install -B -V 1> .build.stdout 2> .build.stderr' >
- echo 'mvn clean install -B -V -Dfindbugs.skip=true 1> .build.stdout 2> .build.stderr' >
- chmod 0755
- travis_wait 60 ./
@@ -78,7 +78,7 @@ public static void assertValidItemName(String itemName) throws IllegalArgumentEx

public static State convertToAcceptedState(State state, Item item) {
if (state == null) {
LOGGER.error("A conversion of null was requested", new NullPointerException("state should not be null"));
LOGGER.error("A conversion of null was requested", new NullPointerException("state should not be null")); // NOPMD
return UnDefType.NULL;

@@ -68,3 +68,11 @@ Note that this list also serves as a checklist for code reviews on pull requests
- ```error``` logging should only be used to inform the user that something is tremendously wrong in his setup, the system cannot function normally anymore, and there is a need for immediate action. It should also be used if some code fails irrecoverably and the user should report it as a severe bug.
1. For bindings, you should NOT log errors, if e.g. connections are dropped - this is considered to be an external problem and from a system perspective to be a normal and expected situation. The correct way to inform users about such events is to update the Thing status accordingly. Note that all events (including Thing status events) are anyhow already logged.
1. Likewise, bundles that accept external requests (such as servlets) must not log errors or warnings if incoming requests are incorrect. Instead, appropriate error responses should be returned to the caller.

## Static code analysis

The Eclipse SmartHome Maven build includes [tooling for static code analysis]( that will validate your code against the Coding Guidelines and some additional best practices. Information about the checks can be found [here](

The tool will generate an individual report for each bundle that you can find in `path/to/bundle/target/code-analysis/report.html` file and a report for the whole build that contains links to the individual reports in the `target/summary_report.html`. The tool categorizes the found issues by priority: 1(error),2(warning) or 3(info). If any error is found within your code the Maven build will end with failure. You will receive detailed information (path to the file, line and message) listing all problems with Priority 1 on the console.

Please fix all the Priority 1 issues and all issues with Priority 2 and 3 that are relevant (if you have any doubt don't hesitate to ask). Re-run the build to confirm that the checks are passing.
76 pom.xml
@@ -53,6 +53,7 @@

@@ -469,6 +470,81 @@
<!-- static code analysis profiles -->


<name>JCenter Repository</name>

@@ -0,0 +1,3 @@
checkstyle.headerCheck.content=^/\\*\\*$\\n^ \\* Copyright \\(c\\) \\d\\d\\d\\d-\\d\\d\\d\\d by the respective copyright holders\\.$\\n^ \\* All rights reserved\\. This program and the accompanying materials$\\n^ \\* are made available under the terms of the Eclipse Public License v1\\.0$\\n^ \\* which accompanies this distribution, and is available at$\\n^ \\*\\-v10\\.html$
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"

<!-- These suppressions define which files to be suppressed for which checks. -->
<suppress files=".+[\\/]internal[\\/].+\.java" checks="JavadocType|JavadocVariable|JavadocMethod|JavadocFilterCheck"/>
<suppress files=".+DTO\.java" checks="JavadocType|JavadocVariable|JavadocMethod|JavadocFilterCheck" />
<suppress files=".+Impl\.java" checks="JavadocType|JavadocVariable|JavadocMethod|JavadocFilterCheck"/>
<!-- All generated files will skip the author tag check -->
<suppress files=".+[\\/]gen[\\/].+\.java" checks="AuthorTagCheck"/>
<!-- Some checks will be supressed for test bundles -->
<suppress files=".+.test[\\/].+" checks="RequireBundleCheck|OutsideOfLibExternalLibrariesCheck|ManifestExternalLibrariesCheck|BuildPropertiesExternalLibrariesCheck"/>

<!-- Eclipse SmartHome specific suppressions-->
<!-- These bundles are generated trough XText -->
<suppress files=".+org.eclipse.smarthome.model.+|.+org.eclipse.smarthome.designer.+" checks="RequireBundleCheck|ExportInternalPackageCheck|ManifestPackageVersionCheck|ImportExportedPackagesCheck"/>
<!-- Some source files have different headers -->
<suppress files=".+org.eclipse.smarthome.automation.+" checks="HeaderCheck"/>
<suppress files=".+org.eclipse.smarthome.config.dispatch.test.+" checks="ServiceComponentManifestCheck"/>
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Groovy files produce a lot of warnings and will be ignored -->
<Source name="~.*\.groovy" />
<!-- Excludes all bugs with priority higher than 4 -->
<Rank value="4"/>
<!-- This pattern is not wanted as it reports usage of Throwable.getMessage() as argument to SLF4G logger -->
<!-- Allow util classes to have static loggers -->
<Class name="~.*Utils"/>
<Class name="~.*Util"/>
<!-- The format string is parameter, it can't be constant -->
<Class name="org.eclipse.smarthome.model.script.actions.LogAction"/>

0 comments on commit b0812c2

Please sign in to comment.
You can’t perform that action at this time.