Details

    • Type: Wish Wish
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Exclusions
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Hi guys,

      I just discovered the promising javax.annotation.Generated annotation [1]. I think this could be a very good solution to allow easy configuration of all quality tools (findbugs, cobertura, pmd, checkstyle, ...) that have to ignore generated code.

      I understand this is not only Sonar but all these tools that have to be updated to support this annotation. BTW I think it could be great to track here the progress on this area.

      The best would be that code generators themselves automatically add the @Generated(value=SOURCE) to the class/method/attribute with the correct value (ie modello, wsdl2java, ...). This way we could configure Sonar to ignore all code generated by a specific list of source code generators.

      It seems that JPA 2 will use @Generated on the metamodel classes used for the new Criteria API (see JSR 317 spec).

      [1] http://java.sun.com/javase/6/docs/api/javax/annotation/Generated.html

        Issue Links

          Activity

          Hide
          Daniel Holmes added a comment -

          Someone on my team noted that this annotation is defined for only SOURCE retention, so tools that work on
          class files (Findbugs, Cobertura, etc) would not have this information available. I submitted to Oracle on this issue, but who knows if that would change. http://bugs.sun.com/bugdatabase/addVote.do?bug_id=7056857

          Show
          Daniel Holmes added a comment - Someone on my team noted that this annotation is defined for only SOURCE retention, so tools that work on class files (Findbugs, Cobertura, etc) would not have this information available. I submitted to Oracle on this issue, but who knows if that would change. http://bugs.sun.com/bugdatabase/addVote.do?bug_id=7056857
          Hide
          Evgeny Mandrikov added a comment -

          Hi Daniel,

          Your teammate is right : this annotation has retention policy source, which makes sense, because there is shouldn't be difference in runtime between generated and not generated code, so I don't think that Oracle will implement your request.

          Moreover I don't see compelling reasons why this annotation should be handled by underlaying tool, but not directly by Sonar - indeed Sonar works with source code and can completely ignore resource (violations, coverage, ...) when this annotation exists.

          Show
          Evgeny Mandrikov added a comment - Hi Daniel, Your teammate is right : this annotation has retention policy source , which makes sense, because there is shouldn't be difference in runtime between generated and not generated code, so I don't think that Oracle will implement your request. Moreover I don't see compelling reasons why this annotation should be handled by underlaying tool, but not directly by Sonar - indeed Sonar works with source code and can completely ignore resource (violations, coverage, ...) when this annotation exists.
          Hide
          Myster Mask added a comment - - edited

          This plugin:
          http://docs.codehaus.org/display/SONAR/Switch+Off+Violations+Plugin
          seems to support @Generated at file level (through regular expression matching). I have not used it so I can't tell how good this works.

          Show
          Myster Mask added a comment - - edited This plugin: http://docs.codehaus.org/display/SONAR/Switch+Off+Violations+Plugin seems to support @Generated at file level (through regular expression matching). I have not used it so I can't tell how good this works.
          Hide
          Daniel Cruver added a comment -

          That plugin page notes it is merged into Sonar. I haven't personally tested it but if it works this ticket is essentially fulfilled correct?

          Show
          Daniel Cruver added a comment - That plugin page notes it is merged into Sonar. I haven't personally tested it but if it works this ticket is essentially fulfilled correct?
          Hide
          Freddy Mallet added a comment -

          Hi Guys, here is the documentation page to define some exclusions : http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus and more specifically to exclude some issues in blocks delimited by regular expressions : http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus#NarrowingtheFocus-IgnoreIssues.

          But here that's not what we want as we don't have a "@Generated" and "@EndGenerated" tags/annotations to delimit blocks to be excluded. So this feature must be provided by the Java plugin itself.

          Show
          Freddy Mallet added a comment - Hi Guys, here is the documentation page to define some exclusions : http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus and more specifically to exclude some issues in blocks delimited by regular expressions : http://docs.codehaus.org/display/SONAR/Narrowing+the+Focus#NarrowingtheFocus-IgnoreIssues . But here that's not what we want as we don't have a "@Generated" and "@EndGenerated" tags/annotations to delimit blocks to be excluded. So this feature must be provided by the Java plugin itself.

            People

            • Assignee:
              Unassigned
              Reporter:
              Julien HENRY
            • Votes:
              39 Vote for this issue
              Watchers:
              22 Start watching this issue

              Dates

              • Created:
                Updated: