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

Duplicate warnings when using error-prone and java scan

    • 7.0.0

      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

          [JENKINS-57428] Duplicate warnings when using error-prone and java scan

          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.

          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.

          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.

          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.

          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.

          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.

          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.

          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.

          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...

          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...

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

              Created:
              Updated:
              Resolved: