[MDSAL-244] @SuppressWarnings("all") on all generated code Created: 13/Apr/17 Updated: 08/Jun/18 Resolved: 08/Jun/18 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Fluorine |
| Type: | Improvement | ||
| Reporter: | Michael Vorburger | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Issue Links: |
|
||||||||
| Description |
|
All bindings code generated should have @SuppressWarnings("all"). This would make it much easier / viable to enable more stringent automated code quality checks e.g. in Eclipse without getting a lot of warnings on /target/generated-sources/mdsal-binding & Co. Today for example you get a lot of warnings like:
etc. etc. While it would be theoretically possible to fix up each of these one by one, this would likely be a fair amount of work, but with little benefit - none of those are "bugs" - the code generators knows what its known; hopefully, contrary to much of our hand written code. Adding @SuppressWarnings("all") on all generated code probably also doesn't hurt (i.e. can only help) with build performance, if tools like javac, Eclipse' compiler and perhaps Find Bugs and Checkstyle honour and skip so annotated types in their analysis (I don't know if they do). An alternative approach to putting @SuppressWarnings everywhere, specific to Eclipse only (and thus inferior already), would have been to mark target/generated-sources/mdsal-binding & Co. as "Ignore optional compile problems" in menu Project > Properties > Java Build Path > Source. I've explored this, but found that it is difficult to get M2E to do this automatically. (If you are brave enough to click around hundreds of projects yourself, then at least since https://bugs.eclipse.org/bugs/show_bug.cgi?id=388541 M2E no longer resets them; but we should not have to manually fiddle with such options in the first place - this should "just work" out of the box.) I'll raise a Gerrit with a starting point proposal for this. As I'm not familiar with the finer points of the code generation in mdsal, I expect that initial proposed change will likely require some tuning by someone experienced in the mdsal team - my hope is that by kicking this off, someone will be motivated to help me finish it? |
| Comments |
| Comment by Michael Vorburger [ 13/Apr/17 ] |
| Comment by Michael Vorburger [ 18/Apr/17 ] |
|
> * "The expression of type int is boxed into Integer" forget about this, that warning should not have been enabled |
| Comment by Martin Ciglan [ 19/Apr/17 ] |
|
https://git.opendaylight.org/gerrit/#/c/54982/ - this one too |
| Comment by Michael Vorburger [ 09/May/17 ] |
|
Re-assigning issue to Robert based on discussion in Kernel projects call today: Robert is de-facto -2'ing https://git.opendaylight.org/gerrit/#/c/54965/, because he prefers to instead fix all code generators to not have warnings. Here's what's left as of today: This can be seen using https://github.com/vorburger/opendaylight-eclipse-setup e.g. on daexim/model/target-ide/generated-sources/mdsal-binding; but like wise in other projects too.
a) Field declaration hides another field or variable
/**
|
| Comment by Robert Varga [ 09/May/17 ] |
|
So we are down to
|
| Comment by Robert Varga [ 11/May/17 ] |
|
https://git.opendaylight.org/gerrit/56833 After which we are down to two issues:
|
| Comment by Robert Varga [ 11/May/17 ] |
|
https://git.opendaylight.org/gerrit/56840 fixes the import |
| Comment by Michael Vorburger [ 16/May/17 ] |
|
> While it would be theoretically possible to fix up each of I've re-tested for this issue today, by running "mvn -Pide clean generate-sources" and seen the number of warnings on generated code e.g. in project genius drop drastically from ca. 2100 to now TBD. Here are the ones left (in genius; it's possible of course other projects have more still), all fall into 2 cases: 1. The method getKey() of type InterfaceMonitorEntry should be tagged with @Override since it actually overrides a superinterface method InterfaceMonitorEntry.java in e.g. org.opendaylight.genius.alivenessmonitor-api/target-ide/generated-sources/mdsal-binding/org/opendaylight/yang/gen/v1/urn/opendaylight/genius/alivenessmonitor/rev160411/_interface/monitor/map, line 59 ... indeed getKey() is on org.opendaylight.yangtools.yang.binding.Identifiable, but there is no @Override. 2. The field Mpls.QNAME is hiding a field from type InterfaceType Mpls.java in org.opendaylight.genius.interfacemanager-api/target-ide/generated-sources/mdsal-binding/org/opendaylight/yang/gen/v1/urn/opendaylight/genius/interfacemanager/rev160406, line 21 ... this is the public static final QName QNAME on a type (e.g. org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.Mpls) which extends another (e.g. org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType) |
| Comment by Robert Varga [ 24/Apr/18 ] |
|
|
| Comment by Robert Varga [ 08/Jun/18 ] |
|
Warnings which have been identified are fixed. |