Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3740

Raw types should not be used

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Provide the parametrised type for this generic.
    • Highlighting:
      Hide

      type name

      Show
      type name
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Covered Languages:
      Java
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      Generic types shouldn't be used raw (without type parameters) in variable declarations or return values. Doing so bypasses generic type checking, and defers the catch of unsafe code to runtime.

      Noncompliant Code Example

      List myList; // Noncompliant 
      Set mySet; // Noncompliant
      

      Compliant Solution

      List<String> myList;
      Set<? extends Number> mySet;
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jeanchristophe.collet Jean-Christophe Collet (Inactive)
              Votes:
              5 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated: