SonarQube
  1. SonarQube
  2. SONAR-1333

skipAnnotations ignored by PMD's "Avoid Duplicate Literals" rule

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.12
    • Fix Version/s: 1.12
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      PMD's "Avoid Duplicate Literals" has a boolean configuration option, skipAnnotations, to prevent literals like "unchecked" in the annotation @SuppressWarnings("unchecked") to be counted as duplicates.

      The default value is false. I set it to true, but alas, literals in annotations are still counted as violations, and so it seems this configuration item is ignored by PMD.

        Activity

        Hide
        Freddy Mallet added a comment -

        I can't manage to reproduce this error on my side. When I set the property "skipAnnotations" to "true" through the Sonar web interface and relaunch a quality analysis, "Avoid Duplicate Literals" violations are no more reported by Sonar on annotations. Moreover, the pmd.xml file generated by Sonar in the target/sonar/ directory contains the following lines :

          <rule ref="rulesets/strings.xml/AvoidDuplicateLiterals">
            <priority>3</priority>
            <properties>
              <property name="skipAnnotations" value="true"/>
            </properties>
          </rule>
        

        Looks like you didn't relaunch a quality analysis ?

        Show
        Freddy Mallet added a comment - I can't manage to reproduce this error on my side. When I set the property "skipAnnotations" to "true" through the Sonar web interface and relaunch a quality analysis, "Avoid Duplicate Literals" violations are no more reported by Sonar on annotations. Moreover, the pmd.xml file generated by Sonar in the target/sonar/ directory contains the following lines : <rule ref= "rulesets/strings.xml/AvoidDuplicateLiterals" > <priority>3</priority> <properties> <property name= "skipAnnotations" value= " true " /> </properties> </rule> Looks like you didn't relaunch a quality analysis ?
        Hide
        Joris Portegies Zwart added a comment -

        That is odd, because we have this option set to true ever since I reported this issue, and I am pretty sure it has been reporting duplicate literals in annotations as violations ever since. Pretty sure, but not 100%, I'll recheck tomorrow!

        Show
        Joris Portegies Zwart added a comment - That is odd, because we have this option set to true ever since I reported this issue, and I am pretty sure it has been reporting duplicate literals in annotations as violations ever since. Pretty sure, but not 100%, I'll recheck tomorrow!
        Hide
        Joris Portegies Zwart added a comment -

        I checked again, and it turns out that the project exhibiting this behavior had its own PMD configuration in its POM, which overruled (or at least interfered with) the Sonar settings.

        My apologies for submitting a non-issue!

        Show
        Joris Portegies Zwart added a comment - I checked again, and it turns out that the project exhibiting this behavior had its own PMD configuration in its POM, which overruled (or at least interfered with) the Sonar settings. My apologies for submitting a non-issue!
        Hide
        Freddy Mallet added a comment -

        No problem Joris, thanks for your feedback.

        Show
        Freddy Mallet added a comment - No problem Joris, thanks for your feedback.

          People

          • Assignee:
            Unassigned
            Reporter:
            Joris Portegies Zwart
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: