Java Code Examples for com.puppycrawl.tools.checkstyle.Checker#process()
The following examples show how to use
com.puppycrawl.tools.checkstyle.Checker#process() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckstyleExecutor.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
private void executeWithClassLoader() { final Checker checker = new Checker(); OutputStream xmlOutput = null; try { checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); checker.addListener(listener); final File xmlReport = configuration.getTargetXmlReport(); if (xmlReport != null) { LOG.info("Checkstyle output report: {}", xmlReport.getAbsolutePath()); xmlOutput = FileUtils.openOutputStream(xmlReport); checker.addListener( new XMLLogger(xmlOutput, AutomaticBean.OutputStreamOptions.CLOSE)); } checker.setCharset(configuration.getCharset().name()); checker.configure(configuration.getCheckstyleConfiguration()); checker.process(configuration .getSourceFiles() .stream() .map(InputFile::file) .collect(Collectors.toList())); } catch (Exception ex) { throw new IllegalStateException("Can not execute Checkstyle", ex); } finally { checker.destroy(); if (Objects.nonNull(xmlOutput)) { close(xmlOutput); } } }
Example 2
Source File: CheckstyleProcessor.java From sputnik with Apache License 2.0 | 5 votes |
private void innerProcess(@NotNull Review review, @NotNull AuditListener auditListener) { List<File> files = review.getFiles(new JavaFilter(), new IOFileTransformer()); Checker checker = createChecker(auditListener); try { checker.process(files); } catch (CheckstyleException e) { throw new ReviewException("Unable to process files with Checkstyle", e); } checker.destroy(); }