I’m trying to correct all Checkstyle warnings for my project, but I keep stumbling over something very annoying when I need to construct a class that takes a Generics argument. Take the following line, for example:
labels = new HashSet < String >();
Then Checkstyle complains that ‘”>” is not followed by whitespace’. So I write the whitespace:
labels = new HashSet < String > ();
And now it complains that ‘”(” is preceded by whitespace’.
Is this a bug? Is there a way to bypass it without adding a @SupressWarnings annotation?
Make sure you are running at least the 5.0 version of Checkstyle as it fixed the handling of generics. See the release notes http://checkstyle.sf.net/releasenotes.html.