@Test public void testRunAnalysis() { QAvalidatorConfig config = new QAvalidatorConfig(); config.setAnalysisFilename("classpath:/default_analysis.groovy"); config.setInputDirs(Lists.newArrayList("./build/classes/java/main")); config.setOutputDir("./build/result-default-architecture"); QAvalidatorResult result = new QAvalidator().runAnalysis(config); assertThat(result, notNullValue()); assertThat(result.getFailedSteps(), hasSize(0)); assertThat(result.isFailedWithException(), is(false)); assertThat(result.getExceptionMessage(), nullValue()); }
@SuppressWarnings({"squid:S2221","squid:S1166"}) public QAvalidatorResult runAnalysis(QAvalidatorConfig config) { QAvalidatorResult result = new QAvalidatorResult(); try { String analysisFilename = selectAnalysisFilename(config); QavAnalysisReader qavAnalysisReader = new QavAnalysisReader(analysisFilename); qavAnalysisReader.setInputDirs(config.getInputDirs()); qavAnalysisReader.setOutputDir(config.getOutputDir()); qavAnalysisReader.read(); @SuppressWarnings("unchecked") List<String> failedSteps = (List<String>) qavAnalysisReader.getContext().getProperty("failedSteps"); result.setFailedSteps(failedSteps); } catch (Exception e) { result.setFailedWithException(true); result.setExceptionMessage(e.getMessage()); } return result; }
QAvalidator { @SuppressWarnings({"squid:S2221","squid:S1166"}) public QAvalidatorResult runAnalysis(QAvalidatorConfig config) { QAvalidatorResult result = new QAvalidatorResult(); try { String analysisFilename = selectAnalysisFilename(config); QavAnalysisReader qavAnalysisReader = new QavAnalysisReader(analysisFilename); qavAnalysisReader.setInputDirs(config.getInputDirs()); qavAnalysisReader.setOutputDir(config.getOutputDir()); qavAnalysisReader.read(); @SuppressWarnings("unchecked") List<String> failedSteps = (List<String>) qavAnalysisReader.getContext().getProperty("failedSteps"); result.setFailedSteps(failedSteps); } catch (Exception e) { result.setFailedWithException(true); result.setExceptionMessage(e.getMessage()); } return result; } }
QAvalidator { @SuppressWarnings({"squid:S2221","squid:S1166"}) public QAvalidatorResult runAnalysis(QAvalidatorConfig config) { QAvalidatorResult result = new QAvalidatorResult(); try { String analysisFilename = selectAnalysisFilename(config); QavAnalysisReader qavAnalysisReader = new QavAnalysisReader(analysisFilename); qavAnalysisReader.setInputDirs(config.getInputDirs()); qavAnalysisReader.setOutputDir(config.getOutputDir()); qavAnalysisReader.read(); @SuppressWarnings("unchecked") List<String> failedSteps = (List<String>) qavAnalysisReader.getContext().getProperty("failedSteps"); result.setFailedSteps(failedSteps); } catch (Exception e) { result.setFailedWithException(true); result.setExceptionMessage(e.getMessage()); } return result; }  }
QAvalidator { @SuppressWarnings({"squid:S2221","squid:S1166"}) public QAvalidatorResult runAnalysis(QAvalidatorConfig config) { QAvalidatorResult result = new QAvalidatorResult(); try { String analysisFilename = selectAnalysisFilename(config); QavAnalysisReader qavAnalysisReader = new QavAnalysisReader(analysisFilename); qavAnalysisReader.setInputDirs(config.getInputDirs()); qavAnalysisReader.setOutputDir(config.getOutputDir()); qavAnalysisReader.read(); @SuppressWarnings("unchecked") List<String> failedSteps = (List<String>) qavAnalysisReader.getContext().getProperty("failedSteps"); result.setFailedSteps(failedSteps); } catch (Exception e) { result.setFailedWithException(true); result.setExceptionMessage(e.getMessage()); } return result; }  @SuppressWarnings({"squid:S2221","squid:S1166"}) // catching Exception (instead of specific subtypes) because there could also be runtime exceptions. // Their messages will all be properly logged. QAvalidatorResult runAnalysis(QAvalidatorConfig config); }
QAvalidator { @SuppressWarnings({"squid:S2221","squid:S1166"}) public QAvalidatorResult runAnalysis(QAvalidatorConfig config) { QAvalidatorResult result = new QAvalidatorResult(); try { String analysisFilename = selectAnalysisFilename(config); QavAnalysisReader qavAnalysisReader = new QavAnalysisReader(analysisFilename); qavAnalysisReader.setInputDirs(config.getInputDirs()); qavAnalysisReader.setOutputDir(config.getOutputDir()); qavAnalysisReader.read(); @SuppressWarnings("unchecked") List<String> failedSteps = (List<String>) qavAnalysisReader.getContext().getProperty("failedSteps"); result.setFailedSteps(failedSteps); } catch (Exception e) { result.setFailedWithException(true); result.setExceptionMessage(e.getMessage()); } return result; }  @SuppressWarnings({"squid:S2221","squid:S1166"}) // catching Exception (instead of specific subtypes) because there could also be runtime exceptions. // Their messages will all be properly logged. QAvalidatorResult runAnalysis(QAvalidatorConfig config);  }