Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-57428

Duplicate warnings when using error-prone and java scan

    Details

    • Similar Issues:
    • Released As:
      7.0.0

      Description

      We use the following setup to scan for java and error-prone warnings:

       def javaIssues = scanForIssues(
                              blameDisabled: !blame,
                              sourceCodeEncoding: 'UTF-8',
                              tool: java(reportEncoding: 'UTF-8'))
                      def errorproneIssues = scanForIssues(
                              blameDisabled: !blame,
                              sourceCodeEncoding: 'UTF-8',
                              tool: errorProne(reportEncoding: 'UTF-8'))
                      publishIssues(
                              id: 'java-compiler',
                              name: 'Compiler',
                              ignoreFailedBuilds: false,
                              sourceCodeEncoding: 'UTF-8',
                              issues: [javaIssues, errorproneIssues],
                              qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]])
      

      For a build output like this it results in duplicate warnings count:

      00:03:20.475  [WARNING] /home/jenkins/agent/workspace/xxx/src/test/java/foo/SettingsControllerIT.java:[139,57] [StringSplitter] String.split(String) has surprising behavior
      00:03:20.475      (see https://errorprone.info/bugpattern/StringSplitter)
      00:03:20.475    Did you mean 'for (String productFamStr : Splitter.on(',').split(productFamiliesStr)) {'?
      

      See screenshot

        Attachments

          Activity

          Hide
          drulli Ulli Hafner added a comment -

          Yes, both parsers match the same warning line. Just error prone has some additional entries. I'm not sure what a good approach would be to eliminate these duplicates.

          Show
          drulli Ulli Hafner added a comment - Yes, both parsers match the same warning line. Just error prone has some additional entries. I'm not sure what a good approach would be to eliminate these duplicates.
          Hide
          reitzmichnicht Michael Düsterhus added a comment -

          I would recommend to define priority for parsers and put all warnings with unique identifier like (File + Line) in a global HashMap. Then if a parser has already created a warnings entry for this location all subsequent parsers will ignore it.

          Show
          reitzmichnicht Michael Düsterhus added a comment - I would recommend to define priority for parsers and put all warnings with unique identifier like (File + Line) in a global HashMap. Then if a parser has already created a warnings entry for this location all subsequent parsers will ignore it.
          Hide
          drulli Ulli Hafner added a comment - - edited

          A simpler solution would be to use the LookaheadStream in the Java Parser as well and skip all warnings that are using multiple lines.

          Show
          drulli Ulli Hafner added a comment - - edited A simpler solution would be to use the LookaheadStream in the Java Parser as well and skip all warnings that are using multiple lines.
          Hide
          christianciach Christian Ciach added a comment -

          Why is this issue marked as "Fixed"? We are using the current Warnings-NG 8.4.0 and the "java"-tool still records all errorprone-warnings.

          Show
          christianciach Christian Ciach added a comment - Why is this issue marked as "Fixed"? We are using the current Warnings-NG 8.4.0 and the "java"-tool still records all errorprone-warnings.
          Hide
          christianciach Christian Ciach added a comment -

          I've found this PR: https://github.com/jenkinsci/analysis-model/pull/233

          It supposedly fixes this issue, but well, the issue is still present for me. I need to dig deeper...

          Show
          christianciach Christian Ciach added a comment - I've found this PR: https://github.com/jenkinsci/analysis-model/pull/233 It supposedly fixes this issue, but well, the issue is still present for me. I need to dig deeper...

            People

            • Assignee:
              andipabst Andreas Pabst
              Reporter:
              reitzmichnicht Michael Düsterhus
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: