Skip to content

Commit

Permalink
Merge pull request SonarOpenCommunity#2082 from guwirth/optimize-squi…
Browse files Browse the repository at this point in the history
…d-visitors

optimize squid sensor
  • Loading branch information
guwirth authored Mar 31, 2021
2 parents 42dc7f8 + b6952ff commit 4d3d333
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,26 @@ public void describe(SensorDescriptor descriptor) {
public void execute(SensorContext context) {
this.context = context;

CxxSquidConfiguration squidConfig = createConfiguration();
var visitors = new ArrayList<SquidAstVisitor<Grammar>>(checks.all());
AstScanner<Grammar> scanner = CxxAstScanner.create(squidConfig, visitors.toArray(
new SquidAstVisitor[visitors.size()]));
// add visitor only if corresponding rule is active
var visitors = new ArrayList<SquidAstVisitor<Grammar>>();
for (var check : checks.all()) {
RuleKey key = checks.ruleKey(check);
if (key != null) {
if (context.activeRules().find(key) != null) {
visitors.add(check);
}
}
}

AstScanner<Grammar> scanner = CxxAstScanner.create(
createConfiguration(),
visitors.toArray(new SquidAstVisitor[visitors.size()])
);

Iterable<InputFile> inputFiles = context.fileSystem().inputFiles(
context.fileSystem().predicates().and(context.fileSystem().predicates().hasLanguage("cxx"),
context.fileSystem().predicates().hasType(InputFile.Type.MAIN)));
context.fileSystem().predicates().hasType(InputFile.Type.MAIN))
);

var files = new ArrayList<File>();
for (var file : inputFiles) {
Expand Down

0 comments on commit 4d3d333

Please sign in to comment.