Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-3357

S1452: java Collectors second parameter should be excluded

    Details

    • Type: False-Positive
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4
    • Component/s: Rules
    • Labels:

      Description

      From the documentation, the accumulator type (second type) of java.util.stream.Collector is often hidden as an implementation detail, we should not report an issue for it.

       

      class Scratch {
          public static Collector<Integer, ?, Integer> summing() {
              return Collector.of(
                      () -> new int[1],
                      (a, t) -> a[0] += t,
                      (a, b) -> {
                          a[0] += b[0];
                          return a;
                      },
                      a -> a[0]
              );
          }
      }
      

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.jaquier Quentin Jaquier
                Reporter:
                quentin.jaquier Quentin Jaquier
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: