Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Checkstyle 5.5 validates generics

I am using Checkstyle Eclipse plugin 5.5 to validate my Java project using standard coding style. I was wondering if Checkstyle generates any error/warning if I have not referenced generic types using parameters?

Now this warning is already shown as a type of Java problem. Just curious if Checkstyle also catches this (apart from manual configuration/tweak).

like image 788
Saikat Avatar asked Dec 07 '25 04:12

Saikat


1 Answers

You mean, can Checkstyle detect something like List list = new ArrayList(); as missing generic type arguments.

No, Checkstyle can't do that because it works only on the Java source files, so it would not know if the List you are referencing has type parameters or not. Checkstyle would have to determine the binary class name of List, and locate its source, which may not even be available in many cases.

FindBugs may be able to do that, as it works on the compiled .class files. I don't know of a FindBugs rule which covers exactly your case, but there are other FindBugs rules related to generics.

like image 51
barfuin Avatar answered Dec 08 '25 17:12

barfuin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!