[Java] Usage of raw type

java

(Werner Thumann) #1

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
	}
	
}

Note
Also covered by Eclipse JDT.


(Gilbert Rebhan) #2

Hi,
there’s already a Jira ticket, please vote here:
https://jira.sonarsource.com/browse/RSPEC-3740
Regards,
Gilbert


(Werner Thumann) #3

Hi,
thanks, I will vote.


(Alexandre Gigleux) #5

I created https://jira.sonarsource.com/browse/SONARJAVA-2941 to add it to our backlog. I don’t know when we will tackle it but at least this rule is back in our radar.