Skip to content

Commit

Permalink
Fix problem when loading custom rules from project and app classpath
Browse files Browse the repository at this point in the history
Fix problem so that the custom rules are firstly checked if they exist and then added, in order to avoid duplicates

Signed-off-by: Enri Ozuni <enriozuni@hotmail.com>
  • Loading branch information
enriozuni committed Jan 23, 2021
1 parent b9a00de commit f561b58
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@ public static List<CrySLRule> getRules(IProject project) {
CrySLParser r = new CrySLParser(project);
for (String path : projectClassPath(JavaCore.create(project))) {
List<CrySLRule> readRuleFromBinaryFiles = r.readRulesOutside(path);
rules.addAll(readRuleFromBinaryFiles);
for(CrySLRule rule : readRuleFromBinaryFiles) {
if(!rules.contains(rule)) {
rules.add(rule);
}
}
}

for (String path : applicationClassPath(JavaCore.create(project))) {
List<CrySLRule> readRuleFromBinaryFiles = r.readRulesOutside(path);
rules.addAll(readRuleFromBinaryFiles);
for(CrySLRule rule : readRuleFromBinaryFiles) {
if(!rules.contains(rule)) {
rules.add(rule);
}
}
}

if (Activator.getDefault().getPreferenceStore().getBoolean(Constants.SELECT_CUSTOM_RULES)) {
Expand Down

0 comments on commit f561b58

Please sign in to comment.