Description
Generic classes should be used as such to enhance type safety. Mark usages of raw types.
Type
Code Smell
Snippet
public class UsageOfRawType {
public static void main(String[] args) {
Map raw = new HashMap(); //Noncompliant
Map<String,String> typed = new HashMap<>(); //Compliant
}
}
“A raw type is the name of a generic class or interface without any type arguments.”
“[…] a non-generic class or interface type is not a raw type”
“[…] you should avoid using raw types”.
You may want to consider adding these references to the SONARJAVA-2941 or RSPEC-3740 ticket.
Also, the name of the rule could be changed to “Raw types should be avoided” or simply “Do not use raw types”, since by the definition (see 1.) “raw type” is more concise than “a generic type used raw”.