Skip to content

Commit fd964ae

Browse files
author
Polina Volkhontseva
committedApr 25, 2022
Non-excluded files collection moved into a separate method
1 parent 00375a0 commit fd964ae

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed
 

‎qulice-pmd/src/main/java/com/qulice/pmd/PmdValidator.java

+18-9
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,7 @@ public PmdValidator(final Environment env) {
6363
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
6464
public Collection<Violation> validate(final Collection<File> files) {
6565
final SourceValidator validator = new SourceValidator(this.env);
66-
final Collection<DataSource> sources = new LinkedList<>();
67-
for (final File file : files) {
68-
final String name = file.getPath().substring(
69-
this.env.basedir().toString().length()
70-
);
71-
if (!this.env.exclude("pmd", name)) {
72-
sources.add(new FileDataSource(file));
73-
}
74-
}
66+
final Collection<DataSource> sources = this.getNonExcludedFiles(files);
7567
final Collection<RuleViolation> breaches = validator.validate(
7668
sources, this.env.basedir().getPath()
7769
);
@@ -98,4 +90,21 @@ public String name() {
9890
return "PMD";
9991
}
10092

93+
/**
94+
* Filters out excluded files from further validation.
95+
* @param files Files to validate
96+
* @return Relevant source files
97+
*/
98+
public Collection<DataSource> getNonExcludedFiles(final Collection<File> files) {
99+
final Collection<DataSource> sources = new LinkedList<>();
100+
for (final File file : files) {
101+
final String name = file.getPath().substring(
102+
this.env.basedir().toString().length()
103+
);
104+
if (!this.env.exclude("pmd", name)) {
105+
sources.add(new FileDataSource(file));
106+
}
107+
}
108+
return sources;
109+
}
101110
}

0 commit comments

Comments
 (0)
Please sign in to comment.