use of com.buschmais.jqassistant.core.rule.api.model.RuleSet 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.rule.api.model.RuleSet in project jqa-commandline-tool by jQAssistant.
the class EffectiveRulesTask method executeTask.
@Override
protected void executeTask(Configuration configuration, Store store) throws CliExecutionException {
try {
RuleSet availableRules = getAvailableRules();
ruleHelper.printRuleSet(availableRules, getRuleSelection(availableRules));
} catch (RuleException e) {
throw new CliExecutionException("Cannot print rules.", e);
}
}
use of com.buschmais.jqassistant.core.rule.api.model.RuleSet in project jqa-maven-plugin by jQAssistant.
the class AvailableRulesMojo method aggregate.
@Override
public void aggregate(MavenProject rootModule, List<MavenProject> projects, Store store) throws MojoExecutionException, MojoFailureException {
getLog().info("Available rules for '" + rootModule.getName() + "'.");
RuleSet ruleSet = readRules(rootModule);
RuleHelper ruleHelper = new RuleHelper(LOGGER);
try {
ruleHelper.printRuleSet(ruleSet);
} catch (RuleException e) {
throw new MojoExecutionException("Cannot print available rules.", e);
}
}
use of com.buschmais.jqassistant.core.rule.api.model.RuleSet in project jqa-maven-plugin by jQAssistant.
the class EffectiveRulesMojo method aggregate.
@Override
public void aggregate(MavenProject rootModule, List<MavenProject> projects, Store store) throws MojoExecutionException, MojoFailureException {
getLog().info("Effective rules for '" + rootModule.getName() + "'.");
RuleSet ruleSet = readRules(rootModule);
RuleSelection ruleSelection = RuleSelection.select(ruleSet, groups, constraints, concepts);
RuleHelper ruleHelper = new RuleHelper(LOGGER);
try {
ruleHelper.printRuleSet(ruleSet, ruleSelection);
} catch (RuleException e) {
throw new MojoExecutionException("Cannot print effective rules.", e);
}
}
use of com.buschmais.jqassistant.core.rule.api.model.RuleSet in project jqa-maven-plugin by jQAssistant.
the class ExportRulesMojo method aggregate.
@Override
protected void aggregate(MavenProject rootModule, List<MavenProject> projects, Store store) throws MojoExecutionException {
getLog().info("Exporting rules for '" + rootModule.getName() + "'.");
final RuleSet ruleSet = readRules(rootModule);
RuleSetWriter ruleSetWriter = new XmlRuleSetWriter(getRuleConfiguration());
String exportedRules = rootModule.getBuild().getDirectory() + "/jqassistant/jqassistant-rules.xml";
Writer writer;
try {
writer = new OutputStreamWriter(new FileOutputStream(exportedRules), "UTF-8");
} catch (IOException e) {
throw new MojoExecutionException("Cannot create writer for rule export.", e);
}
try {
ruleSetWriter.write(ruleSet, writer);
} catch (RuleException e) {
throw new MojoExecutionException("Cannot write rules.", e);
}
}
Aggregations