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

          Michael Düsterhus created issue -

          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.
          Ulli Hafner made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]

          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 made changes -
          Labels New: help-wanted newbie-friendly
          Ulli Hafner made changes -
          Assignee Original: Ulli Hafner [ 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.

          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.
          Andreas Pabst made changes -
          Assignee New: Andreas Pabst [ andipabst ]
          Ulli Hafner made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Fixed but Unreleased [ 10203 ]
          Ulli Hafner made changes -
          Released As New: 7.0.0
          Status Original: Fixed but Unreleased [ 10203 ] New: Resolved [ 5 ]

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

              Created:
              Updated:
              Resolved: