@Test public void should_ignore_PMD_error() throws PMDException, FileNotFoundException { doThrow(new PMDException("BUG")) .when(processor).processSourceCode(any(InputStream.class), any(RuleSets.class), any(RuleContext.class)); new PmdTemplate(configuration, processor).process(inputFile, rulesets, ruleContext); }
public void process(File file, RuleSets rulesets, RuleContext ruleContext) { ruleContext.setSourceCodeFilename(file.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); processor.processSourceCode(inputStream, rulesets, ruleContext); } catch (Exception e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e); } finally { Closeables.closeQuietly(inputStream); } }
PmdTemplate { public void process(File file, RuleSets rulesets, RuleContext ruleContext) { ruleContext.setSourceCodeFilename(file.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); processor.processSourceCode(inputStream, rulesets, ruleContext); } catch (Exception e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e); } finally { Closeables.closeQuietly(inputStream); } } }
PmdTemplate { public void process(File file, RuleSets rulesets, RuleContext ruleContext) { ruleContext.setSourceCodeFilename(file.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); processor.processSourceCode(inputStream, rulesets, ruleContext); } catch (Exception e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e); } finally { Closeables.closeQuietly(inputStream); } } @VisibleForTesting  PmdTemplate(PMDConfiguration configuration, SourceCodeProcessor processor); }
PmdTemplate { public void process(File file, RuleSets rulesets, RuleContext ruleContext) { ruleContext.setSourceCodeFilename(file.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); processor.processSourceCode(inputStream, rulesets, ruleContext); } catch (Exception e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e); } finally { Closeables.closeQuietly(inputStream); } } @VisibleForTesting  PmdTemplate(PMDConfiguration configuration, SourceCodeProcessor processor); static PmdTemplate create(String javaVersion, ClassLoader classloader, Charset charset); void process(File file, RuleSets rulesets, RuleContext ruleContext); }
PmdTemplate { public void process(File file, RuleSets rulesets, RuleContext ruleContext) { ruleContext.setSourceCodeFilename(file.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); processor.processSourceCode(inputStream, rulesets, ruleContext); } catch (Exception e) { LOG.error("Fail to execute PMD. Following file is ignored: " + file, e); } finally { Closeables.closeQuietly(inputStream); } } @VisibleForTesting  PmdTemplate(PMDConfiguration configuration, SourceCodeProcessor processor); static PmdTemplate create(String javaVersion, ClassLoader classloader, Charset charset); void process(File file, RuleSets rulesets, RuleContext ruleContext);  }