Skip to content

Commit

Permalink
Refactor getRules() in SootRunner
Browse files Browse the repository at this point in the history
Change the order on how the rules are loaded. This change loads the rulesets first and then the custom rules.

Signed-off-by: Enri Ozuni <enriozuni@hotmail.com>
  • Loading branch information
enriozuni committed Jan 24, 2021
1 parent c63c7fd commit 725e79f
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,6 @@ public static List<CrySLRule> getRules(IProject project) {
}
}
}

if (Activator.getDefault().getPreferenceStore().getBoolean(Constants.SELECT_CUSTOM_RULES)) {
Activator.getDefault().logInfo("Loading custom rules.");
rules.addAll(Files.find(Paths.get(Utils.getResourceFromWithin(Constants.RELATIVE_CUSTOM_RULES_DIR).getPath()), Integer.MAX_VALUE,
(file, attr) -> file.toString().endsWith(RuleFormat.SOURCE.toString())).map(path -> {
readRules.add(path.getFileName().toString());
return r.readRule(path.toFile());
}).collect(Collectors.toList()));
}

Preferences prefs = InstanceScope.INSTANCE.getNode(de.cognicrypt.core.Activator.PLUGIN_ID);
try {
Expand All @@ -148,6 +139,15 @@ public static List<CrySLRule> getRules(IProject project) {
catch (BackingStoreException e) {
Activator.getDefault().logError(e);
}

if (Activator.getDefault().getPreferenceStore().getBoolean(Constants.SELECT_CUSTOM_RULES)) {
Activator.getDefault().logInfo("Loading custom rules.");
rules.addAll(Files.find(Paths.get(Utils.getResourceFromWithin(Constants.RELATIVE_CUSTOM_RULES_DIR).getPath()), Integer.MAX_VALUE,
(file, attr) -> file.toString().endsWith(RuleFormat.SOURCE.toString())).map(path -> {
readRules.add(path.getFileName().toString());
return r.readRule(path.toFile());
}).collect(Collectors.toList()));
}

}
catch (IOException | CoreException e) {
Expand Down

0 comments on commit 725e79f

Please sign in to comment.