use of com.buschmais.jqassistant.core.report.impl.ReportContextImpl in project jqa-commandline-tool by jQAssistant.
the class AnalyzeTask method executeTask.
@Override
protected void executeTask(Configuration configuration, final Store store) throws CliExecutionException {
LOGGER.info("Will warn on violations starting form severity '" + warnOnSeverity + "'");
LOGGER.info("Will fail on violations starting from severity '" + failOnSeverity + "'.");
LOGGER.info("Executing analysis.");
ReportContext reportContext = new ReportContextImpl(store, reportDirectory, reportDirectory);
Map<String, ReportPlugin> reportPlugins = getReportPlugins(reportContext);
InMemoryReportPlugin inMemoryReportPlugin = new InMemoryReportPlugin(new CompositeReportPlugin(reportPlugins));
AnalyzerConfiguration analyzerConfiguration = new AnalyzerConfiguration();
analyzerConfiguration.setExecuteAppliedConcepts(executeAppliedConcepts);
Map<String, String> ruleParameters = getRuleParameters();
try {
Analyzer analyzer = new AnalyzerImpl(analyzerConfiguration, store, pluginRepository.getAnalyzerPluginRepository().getRuleInterpreterPlugins(emptyMap()), inMemoryReportPlugin, LOGGER);
RuleSet availableRules = getAvailableRules();
analyzer.execute(availableRules, getRuleSelection(availableRules), ruleParameters);
} catch (RuleException e) {
throw new CliExecutionException("Analysis failed.", e);
}
if (createReportArchive) {
createReportArchive(reportContext);
}
store.beginTransaction();
LOGGER.info("Verifying results: failOnSeverity=" + failOnSeverity + ", warnOnSeverity=" + warnOnSeverity);
try {
final ReportHelper reportHelper = new ReportHelper(LOGGER);
final int conceptViolations = reportHelper.verifyConceptResults(warnOnSeverity, failOnSeverity, inMemoryReportPlugin);
final int constraintViolations = reportHelper.verifyConstraintResults(warnOnSeverity, failOnSeverity, inMemoryReportPlugin);
if (conceptViolations > 0 || constraintViolations > 0) {
throw new CliRuleViolationException("Failed rules detected: " + conceptViolations + " concepts, " + constraintViolations + " constraints");
}
} finally {
store.commitTransaction();
}
}
use of com.buschmais.jqassistant.core.report.impl.ReportContextImpl in project jqa-core-framework by jQAssistant.
the class AbstractPluginIT method initializeAnalyzer.
private void initializeAnalyzer() {
this.reportContext = new ReportContextImpl(store, outputDirectory);
Map<String, ReportPlugin> reportPlugins = pluginRepository.getAnalyzerPluginRepository().getReportPlugins(reportContext, getReportProperties());
this.reportPlugin = new InMemoryReportPlugin(new CompositeReportPlugin(reportPlugins));
AnalyzerConfiguration configuration = getAnalyzerConfiguration();
analyzer = new AnalyzerImpl(configuration, store, getRuleInterpreterPlugins(), reportPlugin, LOGGER);
}
use of com.buschmais.jqassistant.core.report.impl.ReportContextImpl in project jqa-commandline-tool by jQAssistant.
the class AnalyzeTask method run.
@Override
public void run(CliConfiguration configuration) throws CliExecutionException {
Analyze analyze = configuration.analyze();
Severity warnOnSeverity = analyze.report().warnOnSeverity();
Severity failOnSeverity = analyze.report().failOnSeverity();
LOGGER.info("Will warn on violations starting from severity '" + warnOnSeverity + "'");
LOGGER.info("Will fail on violations starting from severity '" + failOnSeverity + "'.");
LOGGER.info("Executing analysis.");
withStore(configuration, store -> {
ReportContext reportContext = new ReportContextImpl(store, reportDirectory, reportDirectory);
Map<String, ReportPlugin> reportPlugins = getReportPlugins(analyze.report(), reportContext);
InMemoryReportPlugin inMemoryReportPlugin = new InMemoryReportPlugin(new CompositeReportPlugin(reportPlugins));
try {
Analyzer analyzer = new AnalyzerImpl(analyze, store, pluginRepository.getAnalyzerPluginRepository().getRuleInterpreterPlugins(emptyMap()), inMemoryReportPlugin, LOGGER);
RuleSet availableRules = getAvailableRules(analyze.rule());
analyzer.execute(availableRules, getRuleSelection(availableRules, analyze));
} catch (RuleException e) {
throw new CliExecutionException("Analysis failed.", e);
}
if (analyze.report().createArchive()) {
createReportArchive(reportContext);
}
store.beginTransaction();
LOGGER.info("Verifying results: failOnSeverity=" + failOnSeverity + ", warnOnSeverity=" + warnOnSeverity);
try {
final ReportHelper reportHelper = new ReportHelper(configuration.analyze().report(), LOGGER);
final int conceptViolations = reportHelper.verifyConceptResults(inMemoryReportPlugin);
final int constraintViolations = reportHelper.verifyConstraintResults(inMemoryReportPlugin);
if (conceptViolations > 0 || constraintViolations > 0) {
throw new CliRuleViolationException("Failed rules detected: " + conceptViolations + " concepts, " + constraintViolations + " constraints");
}
} finally {
store.commitTransaction();
}
});
}
use of com.buschmais.jqassistant.core.report.impl.ReportContextImpl in project jqa-core-framework by jQAssistant.
the class AbstractPluginIT method initializeAnalyzer.
private void initializeAnalyzer(Configuration configuration) {
this.reportContext = new ReportContextImpl(store, outputDirectory);
this.reportPlugin = getReportPlugin();
this.analyzer = getAnalyzer(configuration);
}
use of com.buschmais.jqassistant.core.report.impl.ReportContextImpl in project jqa-maven-plugin by jQAssistant.
the class AnalyzeMojo method analyze.
private void analyze(MavenConfiguration configuration, MavenProject rootModule, RuleSet ruleSet, RuleSelection ruleSelection, Store store, File outputDirectory) throws MojoExecutionException, MojoFailureException {
Analyze analyze = configuration.analyze();
getLog().info("Executing analysis for '" + rootModule.getName() + "'.");
getLog().info("Will warn on violations starting from severity '" + analyze.report().warnOnSeverity() + "'");
getLog().info("Will fail on violations starting from severity '" + analyze.report().failOnSeverity() + "'.");
ReportContext reportContext = new ReportContextImpl(store, outputDirectory);
AnalyzerPluginRepository analyzerPluginRepository = getPluginRepository(configuration).getAnalyzerPluginRepository();
Map<String, ReportPlugin> reportPlugins = analyzerPluginRepository.getReportPlugins(analyze.report(), reportContext);
InMemoryReportPlugin inMemoryReportPlugin = new InMemoryReportPlugin(new CompositeReportPlugin(reportPlugins, reportTypes.isEmpty() ? null : reportTypes));
try {
Analyzer analyzer = new AnalyzerImpl(analyze, store, analyzerPluginRepository.getRuleInterpreterPlugins(emptyMap()), inMemoryReportPlugin, LOGGER);
analyzer.execute(ruleSet, ruleSelection);
} catch (RuleException e) {
throw new MojoExecutionException("Analysis failed.", e);
}
if (analyze.report().createArchive()) {
attachReportArchive(rootModule, reportContext);
}
ReportHelper reportHelper = new ReportHelper(analyze.report(), LOGGER);
store.beginTransaction();
try {
verifyAnalysisResults(inMemoryReportPlugin, reportHelper);
} finally {
store.commitTransaction();
}
}
Aggregations