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

S6212 should not suggest using "var" when the initializer is an array initializers

    XMLWordPrintable

    Details

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

      Description

      S6212 should not suggest using "var" when the initializer is an array initializer.

      String[] array = {"A", "B", "C"}; // FP
      var array = {"A", "B", "C"}; // does not compile
      

      According to JEP 286:

      Poly expressions that require such a type, like lambdas, method references, and array initializers, will trigger an error.

        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

                Created:
                Updated:
                Resolved: