use of org.sonar.plugins.openedge.api.checks.OpenEdgeDumpFileCheck in project sonar-openedge by Riverside-Software.
the class OpenEdgeDBRulesSensor method execute.
@Override
public void execute(SensorContext context) {
Map<String, Long> ruleTime = new HashMap<>();
long parseTime = 0L;
components.init(context);
for (Map.Entry<ActiveRule, OpenEdgeDumpFileCheck> entry : components.getDumpFileRules().entrySet()) {
ruleTime.put(entry.getKey().ruleKey().toString(), 0L);
}
FilePredicates predicates = context.fileSystem().predicates();
for (InputFile file : context.fileSystem().inputFiles(predicates.and(predicates.hasLanguage(Constants.DB_LANGUAGE_KEY), predicates.hasType(Type.MAIN)))) {
try {
LOG.debug("Generating ParseTree for dump file {}", file);
long time = System.currentTimeMillis();
ParseTree tree = DumpFileUtils.getDumpFileParseTree(file.inputStream(), file.charset());
parseTime += (System.currentTimeMillis() - time);
for (Map.Entry<ActiveRule, OpenEdgeDumpFileCheck> entry : components.getDumpFileRules().entrySet()) {
LOG.debug("ActiveRule - Internal key {} - Repository {} - Rule {}", entry.getKey().internalKey(), entry.getKey().ruleKey().repository(), entry.getKey().ruleKey().rule());
long startTime = System.currentTimeMillis();
entry.getValue().execute(file, tree);
ruleTime.put(entry.getKey().ruleKey().toString(), ruleTime.get(entry.getKey().ruleKey().toString()) + System.currentTimeMillis() - startTime);
}
} catch (IOException caught) {
LOG.error("Unable to analyze {}", file, caught);
}
}
LOG.info("AST Generation | time={} ms", parseTime);
for (Entry<String, Long> entry : ruleTime.entrySet()) {
LOG.info("Rule {} | time={} ms", entry.getKey(), entry.getValue());
}
}
Aggregations