-
Notifications
You must be signed in to change notification settings - Fork 782
Add Static code analysis tool to ESH build #3995
Add Static code analysis tool to ESH build #3995
Conversation
@@ -16,4 +16,6 @@ | |||
<!-- Eclipse SmartHome specific suppressions--> | |||
<!-- These bundles are generated trough XText --> | |||
<suppress files=".+org.eclipse.smarthome.model.+" checks="RequireBundleCheck|ExportInternalPackageCheck|ManifestPackageVersionCheck|ImportExportedPackagesCheck"/> | |||
<!-- Some source files have different headers --> | |||
<suppress files=".+org.eclipse.smarthome.automation.+" checks="HeaderCheck"/> |
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.
Do we really want to suppress checks or rather update the automation bundles to adhere to our guidelines?
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.
Yes, because we currently have a different arrangement for the license header of the automation component.
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.
okay, tnx.
@@ -218,7 +218,7 @@ class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTest { | |||
} | |||
|
|||
@Test | |||
void 'assert that a status configuration message for missing bridge IP is properly returned (IP is an empty string)'() { | |||
void 'assert that a status configuration message for missing bridge IP is properly returned - IP is an empty string'() { |
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.
Can you create a separate PR for that change?
I expect that it will be okay to change the long groovy names.
@@ -197,7 +197,7 @@ class HueBridgeHandlerOSGiTest extends AbstractHueOSGiTest { | |||
} | |||
|
|||
@Test | |||
void 'assert that a status configuration message for missing bridge IP is properly returned (IP is null)'() { | |||
void 'assert that a status configuration message for missing bridge IP is properly returned - IP is null'() { |
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.
Can you create a separate PR for that change?
I expect that it will be okay to change the long groovy names.
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.
Yes, of course.
@@ -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 |
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
Created CQ 13980 for the tool dependency. |
Woah, that was quick: The CQ is already approved! |
See eclipse-archived#3995 Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
See eclipse-archived#3995 Fix typos eclipse-archived#3969 (review) Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
See #3995 Fix typos #3969 (review) Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
See #3995 Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
See eclipse-archived#3995 Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
See #3995 Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
The plugin exports annotations for FindBugs(SpotBugs). See eclipse-archived#4016 (comment) See eclipse-archived#3995 Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
The plugin exports annotations for FindBugs(SpotBugs). See eclipse-archived#4016 (comment) See eclipse-archived#3995 Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
73a4db1
to
3d27290
Compare
The latest build fails with the hue binding. After the update of the XML things schema, the build should be green :-). |
Friday the only remaining errors were caused from the .xsd file that is not up to date - #3963. Should I ignore these errors or wait for the update of the schema file ? |
Wait for the schema file - it should be up to date now! I retrigger Travis... |
Retrigger Travis. |
The build failed after 49 mins :
@kaikreuzer I guess the build is too slow with the static-analysis-tool added. |
I restarted it once again, just to make sure it was not caused by a slow repository, but the result was the same. That's indeed not so good news... |
When we talk about speed/performance, FindBugs is always the main suspected :-) .
Checkstyle checks are taking 06:32 min and PMD 02:41 min (and this includes the resolving of different repositories, actually the time is less). I guess we can speed it up a bit if we tweak the configuration of FindBugs a little bit, but I am not sure if it will be enough. I would appreciate help here. |
@kaikreuzer, I guess it is up to you.
What we are going to do in this situation ? |
No, you are only always underestimating my pragmatism. While I agree that it would be nice to have it in a separate repo and also to version it separately from the core, I have learned from having openHAB split into several repos what overhead this means in terms of build & release management. After all, we duplicate the number of build jobs, the repos to update for new tools like the static code analysis or other upgrades, the efforts on doing releases and the number of issue trackers (while people today already never know where to post something).
I don't think that genereally disabling valuable checks is an option. We should rather think about how to reduce the situations, where we execute them. I would claim that the build time of the nightly job on our hudson is not an issue, so I would prefer to have it executing the full test/check suite. Wrt Travis, I am not sure what our options are. If you could add a parameter which deactivates the FindBugs checks and we set that in the Travis configuration only, it might be an acceptable compromise. |
Great, I have deactivated the FindBugs checks only in Travis. This has caused some errors in the report generation goal, but they are already fixed with this commit. I have also managed to generate a combined report for the whole repository, so maybe it is better to release new version first and then add it to the ESH build. |
New version 0.3.0 has been released - do you want to update the PR accordingly? I think we would be good to merge then! |
cbbf304
to
3676fc0
Compare
@kaikreuzer, I have rebased and updated the PR. Do you think we should add a few sentences for the tool in the ESH documentation like we have done this in the openHAB docs - http://docs.openhab.org/developers/development/bindings.html#static-code-analysis ? Where would be the best place for that - maybe in the Coding Guidelines ? |
Yes, I guess the coding guidelines are the best place for it. |
Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
0603f43
to
f2a7179
Compare
@kaikreuzer, I am ready with the updates on this PR. |
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.
I wounder about the repositories and plugin repositories that has been added. Do you really need all of them?
|
||
The Eclipse SmartHome Maven build includes [tooling for static code analysis](https://github.com/openhab/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](https://github.com/openhab/static-code-analysis/blob/master/docs/included-checks.md). | ||
|
||
The tool will generate an idividual report for each binding that you can find in `../your_binding_directory/target/code-analysis/report.html` file and a report for the whole build that contains links to the individual reports in the `../smarthome/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 Prioriry 1 on the console. |
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.
It is not only about bindings but every bundle that is build (for each binding => for each bundle). And to be fair it would be not only be used for bundles, but for every artifact in the reactor, so "for each artifact" would be correct.
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.
At the moment it will be used only on bundles - there are two profiles in this PR that activate the tool for bundles and bindings (the one is obsolete now, I will remove it). Initially the idea was to have separate rulesets included in each profile, but this changed over time.
Activating the checks for each artifact is not tested well enough, some of the OSGi specific checks might have problems with that.
|
||
The Eclipse SmartHome Maven build includes [tooling for static code analysis](https://github.com/openhab/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](https://github.com/openhab/static-code-analysis/blob/master/docs/included-checks.md). | ||
|
||
The tool will generate an idividual report for each binding that you can find in `../your_binding_directory/target/code-analysis/report.html` file and a report for the whole build that contains links to the individual reports in the `../smarthome/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 Prioriry 1 on the console. |
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.
Why do you add a ../
in front of the path.
Normally you call mvn ...
in the root of the reactor and IMHO the relative paths should be relative to the root.
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.
Thanks, I was wondering how to be more precise here, but without much success. I will change it to relative to the root of the reactor.
pom.xml
Outdated
</pluginRepository> | ||
<pluginRepository> | ||
<id>buchen-maven-repo</id> | ||
<url>http://buchen.github.io/maven-repo</url> |
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.
Hasen't this one been removed previously by intention?
Why do you add it again?
pom.xml
Outdated
<id>eclipse</id> | ||
<name>Eclipse Snapshot Repository</name> | ||
<layout>default</layout> | ||
<url>https://repo.eclipse.org/content/repositories/snapshots/</url> |
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.
This has been removed some days ago, why do you need the Eclipse Snapshot Repository?
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.
As I see I only need both JFrog repositories (one for the plugin and one for its dependencies) , I will remove the others.
Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
I hope I have answered all questions. Do you have any other concerns ? |
pom.xml
Outdated
</profiles> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>openhab-artifactory-release</id> |
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.
Actually, the official repo for the releases is "jcenter" at https://jcenter.bintray.com/.
It probably makes sense that I also request to have it published to Maven central, then we would not at all need a specific repo here.
</pluginRepositories> | ||
|
||
<repositories> | ||
<repository> |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I haven't taught about that much until you asked.
The tool(as a Maven plugin) internally starts the Maven plugins for Checkstyle, PMD and FindBugs and adds itself as a dependency to these plugins, so the included custom checks that are contained there are available in the classpath.
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.
Did you test if it also works without it?
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.
Yes, I tested it, it is not working without this repository.
pom.xml
Outdated
</profiles> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>JCenter Repository</id> |
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.
id should imho rather be "jcenter"
pom.xml
Outdated
|
||
<repositories> | ||
<repository> | ||
<id>openhab-artifactory-release</id> |
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.
id should be "jcenter"
9e8cff6
to
01ee70d
Compare
Signed-off-by: Svilen Valkanov <svilen.valkanov@musala.com>
01ee70d
to
12c5234
Compare
Thanks! |
Closes #2437
Before merging:
CQ should be approved;the version of the tool has to be updated with the latest that is released;the high priority issues should be fixed;Hue binding: XML thing types in error on tag representation-property #3963 is resolved. See XML validation check openhab/static-code-analysis#136