-
Notifications
You must be signed in to change notification settings - Fork 782
Add Static code analysis tool to ESH build #3995
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
<jdt-annotations.version>2.1.0</jdt-annotations.version> | ||
<build.helper.maven.plugin.version>1.8</build.helper.maven.plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<sat.version>0.3.0</sat.version> | ||
</properties> | ||
|
||
<packaging>pom</packaging> | ||
|
@@ -469,6 +470,81 @@ | |
</plugins> | ||
</build> | ||
</profile> | ||
<!-- static code analysis profiles --> | ||
<profile> | ||
<id>check</id> | ||
<activation> | ||
<property> | ||
<name>!skipChecks</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.openhab.tools</groupId> | ||
<artifactId>static-code-analysis</artifactId> | ||
<version>${sat.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>checkstyle</goal> | ||
<goal>pmd</goal> | ||
<goal>findbugs</goal> | ||
<goal>report</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<checkstyleProperties>tools/static-code-analysis/checkstyle/ruleset.properties</checkstyleProperties> | ||
<checkstyleFilter>tools/static-code-analysis/checkstyle/suppressions.xml</checkstyleFilter> | ||
<findbugsExclude>tools/static-code-analysis/findbugs/suppressions.xml</findbugsExclude> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>check-bundles</id> | ||
<activation> | ||
<file> | ||
<exists>META-INF/MANIFEST.MF</exists> | ||
</file> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.openhab.tools</groupId> | ||
<artifactId>static-code-analysis</artifactId> | ||
<version>${sat.version}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>jcenter</id> | ||
<url>https://jcenter.bintray.com</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<repositories> | ||
<repository> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the pluginRepository enough? Why do we need it as a dependency repository as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, I haven't taught about that much until you asked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you test if it also works without it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I tested it, it is not working without this repository. |
||
<id>jcenter</id> | ||
<name>JCenter Repository</name> | ||
<url>https://jcenter.bintray.com</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>false</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
checkstyle.aboutHtmlCheck.url=https://eclipse.org/legal/epl/about.html | ||
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^ \\* http://www.eclipse.org/legal/epl\\-v10\\.html$ | ||
checkstyle.bundleVendorCheck.allowedValues=Eclipse.org/SmartHome |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE suppressions PUBLIC | ||
"-//Puppy Crawl//DTD Suppressions 1.1//EN" | ||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> | ||
|
||
<suppressions> | ||
<!-- 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"/> | ||
</suppressions> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<FindBugsFilter> | ||
<!-- Groovy files produce a lot of warnings and will be ignored --> | ||
<Match> | ||
<Source name="~.*\.groovy" /> | ||
</Match> | ||
<!-- Excludes all bugs with priority higher than 4 --> | ||
<Match> | ||
<Rank value="4"/> | ||
<Not> | ||
<Bug pattern="SLF4J_LOGGER_SHOULD_BE_NON_STATIC"/> | ||
</Not> | ||
</Match> | ||
<!-- This pattern is not wanted as it reports usage of Throwable.getMessage() as argument to SLF4G logger --> | ||
<Match> | ||
<Bug pattern="SLF4J_MANUALLY_PROVIDED_MESSAGE"/> | ||
</Match> | ||
<!-- Allow util classes to have static loggers --> | ||
<Match> | ||
<Class name="~.*Utils"/> | ||
<Bug pattern="SLF4J_LOGGER_SHOULD_BE_NON_STATIC"/> | ||
</Match> | ||
<Match> | ||
<Class name="~.*Util"/> | ||
<Bug pattern="SLF4J_LOGGER_SHOULD_BE_NON_STATIC"/> | ||
</Match> | ||
<!-- The format string is parameter, it can't be constant --> | ||
<Match> | ||
<Class name="org.eclipse.smarthome.model.script.actions.LogAction"/> | ||
<Bug pattern="SLF4J_FORMAT_SHOULD_BE_CONST"/> | ||
</Match> | ||
</FindBugsFilter> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the exact PMD warning that is suppressed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #3888