Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-244

@SuppressWarnings("all") on all generated code

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Fluorine
    • None
    • None
    • None
    • Operating System: All
      Platform: All

      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:

      • "The method getModuleInfo() of type $YangModelBindingProvider should be tagged with @Override since it actually overrides a superinterface method"; and others related to @Override, like:
        • "The method getKey() of type NodeStatus should be tagged with @Override since it actually overrides a superinterface method"
        • "The method build() of type NodeStatusBuilder should be tagged with @Override since it actually overrides a superinterface method"
        • The method getImplementedInterface() of type NodeStatusBuilder.NodeStatusImpl should be tagged with @Override since it actually overrides a superinterface method
      • "The parameter augmentation is hiding a field from type {Some}

        Builder"

      • "The expression of type int is boxed into Integer"
      • "The import org.opendaylight.yang.gen.v1.urn.opendaylight.daexim.rev160921.DataStore.Enumeration is never used"
      • The parameter augmentation is hiding a field from type NodeStatusBuilder

      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?

            rovarga Robert Varga
            vorburger Michael Vorburger
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: