Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:Provide the parametrised type for this generic.
-
Highlighting:
-
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
- is implemented by
-
SONARJAVA-2941 Rule S3740: Generic types shouldn't be used raw
-
- Closed
-
- is related to
-
SONARJAVA-2410 Issue filter should also filter rules depending of the java warning suppressed
-
- Closed
-
-
SONARJAVA-3521 SuppressWarnings Filter should remove issue of S3740 when "rawTypes" is used
-
- Closed
-
-
SUPPORT-3866 Loading...
- links to