Skip to content

Commit

Permalink
Merge pull request #720 from hazendaz/master
Browse files Browse the repository at this point in the history
[cleanup] Do not check both isEmpty and isDirectory as the second alr…
  • Loading branch information
hazendaz authored Dec 25, 2023
2 parents ee5019a + 0e2aff3 commit 216bcfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ abstract class BaseViolationCheckMojo extends AbstractMojo {
private boolean doSourceFilesExist() {
List sourceFiles = new ArrayList()

if (this.classFilesDirectory.exists() && this.classFilesDirectory.isDirectory()) {
if (this.classFilesDirectory.isDirectory()) {
sourceFiles.addAll(FileUtils.getFiles(classFilesDirectory, SpotBugsInfo.JAVA_REGEX_PATTERN, null))
}

if (this.includeTests && this.testClassFilesDirectory.exists() && this.testClassFilesDirectory.isDirectory()) {
if (this.includeTests && this.testClassFilesDirectory.isDirectory()) {
sourceFiles.addAll(FileUtils.getFiles(testClassFilesDirectory, SpotBugsInfo.JAVA_REGEX_PATTERN, null))
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/groovy/org/codehaus/mojo/spotbugs/SpotBugsMojo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,12 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
args << maxRank
}

if (classFilesDirectory.exists() && classFilesDirectory.isDirectory()) {
if (classFilesDirectory.isDirectory()) {
log.debug(" Adding to Source Directory ->" + classFilesDirectory.absolutePath)
args << classFilesDirectory.absolutePath
}

if (testClassFilesDirectory.exists() && testClassFilesDirectory.isDirectory() && includeTests) {
if (testClassFilesDirectory.isDirectory() && includeTests) {
log.debug(" Adding to Source Directory ->" + testClassFilesDirectory.absolutePath)
args << testClassFilesDirectory.absolutePath
}
Expand All @@ -1041,9 +1041,9 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
private File createSpotbugsAuxClasspathFile() {
List<String> auxClasspathElements

if (testClassFilesDirectory.exists() && testClassFilesDirectory.isDirectory() && includeTests) {
if (testClassFilesDirectory.isDirectory() && includeTests) {
auxClasspathElements = project.testClasspathElements
} else if (classFilesDirectory.exists() && classFilesDirectory.isDirectory()) {
} else if (classFilesDirectory.isDirectory()) {
auxClasspathElements = project.compileClasspathElements
}

Expand Down Expand Up @@ -1221,7 +1221,7 @@ class SpotBugsMojo extends AbstractMavenReport implements SpotBugsPluginsTrait {
xmlProject.appendNode { SrcDir(compileSourceRoot) }
}

if (testClassFilesDirectory.exists() && testClassFilesDirectory.isDirectory() && includeTests) {
if (testClassFilesDirectory.isDirectory() && includeTests) {
testSourceRoots.each() { testSourceRoot ->
xmlProject.appendNode { SrcDir(testSourceRoot) }
}
Expand Down

0 comments on commit 216bcfb

Please sign in to comment.