use of com.buschmais.jqassistant.core.analysis.api.configuration.Analyze 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.analysis.api.configuration.Analyze in project jqa-maven-plugin by jQAssistant.
the class AnalyzeMojo method aggregate.
@Override
public void aggregate(MojoExecutionContext mojoExecutionContext) throws MojoExecutionException, MojoFailureException {
MavenConfiguration configuration = mojoExecutionContext.getConfiguration();
MavenProject rootModule = mojoExecutionContext.getRootModule();
RuleSet ruleSet = readRules(mojoExecutionContext);
Analyze analyze = configuration.analyze();
RuleSelection ruleSelection = RuleSelection.select(ruleSet, analyze.groups(), analyze.constraints(), analyze.concepts());
File outputDirectory = mojoExecutionContext.getOutputDirectory();
withStore(store -> analyze(configuration, rootModule, ruleSet, ruleSelection, store, outputDirectory), mojoExecutionContext);
}
use of com.buschmais.jqassistant.core.analysis.api.configuration.Analyze in project jqa-maven-plugin by jQAssistant.
the class EffectiveRulesMojo method aggregate.
@Override
public void aggregate(MojoExecutionContext mojoExecutionContext) throws MojoExecutionException, MojoFailureException {
getLog().info("Effective rules for '" + mojoExecutionContext.getRootModule().getName() + "'.");
Analyze analyze = mojoExecutionContext.getConfiguration().analyze();
RuleSet ruleSet = readRules(mojoExecutionContext);
RuleSelection ruleSelection = RuleSelection.select(ruleSet, analyze.groups(), analyze.constraints(), analyze.concepts());
RuleHelper ruleHelper = new RuleHelper(LOGGER);
try {
ruleHelper.printRuleSet(ruleSet, ruleSelection, analyze.rule());
} catch (RuleException e) {
throw new MojoExecutionException("Cannot print effective rules.", e);
}
}
use of com.buschmais.jqassistant.core.analysis.api.configuration.Analyze in project jqa-commandline-tool by jQAssistant.
the class EffectiveRulesTask method run.
@Override
public void run(CliConfiguration configuration) throws CliExecutionException {
try {
Analyze analyze = configuration.analyze();
Rule rule = analyze.rule();
RuleSet availableRules = getAvailableRules(rule);
ruleHelper.printRuleSet(availableRules, getRuleSelection(availableRules, analyze), rule);
} catch (RuleException e) {
throw new CliExecutionException("Cannot print rules.", e);
}
}
use of com.buschmais.jqassistant.core.analysis.api.configuration.Analyze 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