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

S1905 should also raise issues in method invocation and constructor call arguments

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.14
    • Fix Version/s: 6.0
    • Component/s: Rules
    • Labels:
      None

      Description

      Implementation of RSPEC-1905 does not cover correctly cast when done inside method invocation arguments, and constructor call. The following case is not raising any issue, while it should:

      import java.util.Collection;
      import java.util.List;
      
      import static java.util.Collections.emptyList;
      
      class C {
        void foo(List<String> p) {
          Collection<String> v1 = emptyList();
          List<String> v2 = emptyList();
          foo((List<String>) v1); // Compliant - cast needed
          foo((List<String>) v2); // Compliant - FN case not properly handled - would be the same with NEW_CLASS_TREE
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                michael.gumowski Michael Gumowski
                Reporter:
                michael.gumowski Michael Gumowski
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: