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

S2384, S2386 should support immutable collection creation from stream

    XMLWordPrintable

    Details

    • Type: False-Positive
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Rules
    • Labels:
      None

      Description

      We added the support for immutable collection creation in SONARJAVA-3706. However, we still have FP when the collection is created from a stream.

        public static final Set<String> s = // FP
          Stream.of(
              "first",
              "second")
            .collect(Collectors.toUnmodifiableSet());
      
        public static final Set<String> s2 =  // FP
          Arrays.asList(
              "first",
              "second")
            .stream()
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: