CheckstyleValidator implements ResourceValidator { @Override @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") public Collection<Violation> validate(final Collection<File> files) { try { this.checker.process(Lists.newArrayList(files)); } catch (final CheckstyleException ex) { throw new IllegalStateException("Failed to process files", ex); } final List<AuditEvent> events = this.listener.events(); final Collection<Violation> results = new LinkedList<>(); for (final AuditEvent event : events) { final String check = event.getSourceName(); results.add( new Violation.Default( this.name(), check.substring(check.lastIndexOf('.') + 1), event.getFileName(), String.valueOf(event.getLine()), event.getMessage() ) ); } return results; } @SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")  CheckstyleValidator(final Environment env); @Override @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") Collection<Violation> validate(final Collection<File> files); @Override String name();  }
@Test public void reportsErrorWhenParameterObjectIsNotDocumented() throws Exception { this.validate( "ParametrizedClass.java", false, "Type Javadoc comment is missing @param <T> tag." ); }
@Test public void reportsErrorWhenLineWrap() throws Exception { this.validate( "LineWrapPackage.java", false, "should not be line-wrapped" ); }
@Test public void reportsErrorWhenIndentationIsIncorrect() throws Exception { this.validate( "InvalidIndentation.java", false, "Indentation (14) must be same or less than" ); }
@Test public void reportsErrorOnMoreThanOneReturnStatement() throws Exception { this.validate( "ReturnCount.java", false, "Return count is 2 (max allowed for non-void methods/lambdas is 1)" ); }
@Test @Disabled public void passesWindowsEndsOfLineWithoutException() throws Exception { this.validate("WindowsEol.java", false, "LICENSE found:"); }
@Test public void testExtraSemicolonInTryWithResources() throws Exception { this.validate( "ExtraSemicolon.java", false, "Extra semicolon in the end of try-with-resources head." ); }