Skip to content

Commit

Permalink
fix: remove deprecated methods SpotBugsTask.getEnabledReports() and…
Browse files Browse the repository at this point in the history
… `SpotBugsTask.getFirstEnabledReport`

Signed-off-by: Kengo TODA <skypencil@gmail.com>
  • Loading branch information
KengoTODA committed Aug 14, 2023
1 parent 4b0f800 commit 2ab3c45
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 24 deletions.
21 changes: 4 additions & 17 deletions src/main/kotlin/com/github/spotbugs/snom/SpotBugsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import com.github.spotbugs.snom.internal.SpotBugsRunnerForWorker
import com.github.spotbugs.snom.internal.SpotBugsSarifReport
import com.github.spotbugs.snom.internal.SpotBugsTextReport
import com.github.spotbugs.snom.internal.SpotBugsXmlReport
import edu.umd.cs.findbugs.annotations.NonNull
import edu.umd.cs.findbugs.annotations.Nullable
import groovy.lang.Closure
import org.gradle.api.Action
import org.gradle.api.DefaultTask
Expand Down Expand Up @@ -417,21 +415,6 @@ abstract class SpotBugsTask : DefaultTask(), VerificationTask {
return reports
}

@Nullable
@Optional
@Nested
fun getFirstEnabledReport(): SpotBugsReport? {
val report = reports.stream().filter { report -> report.isEnabled }.findFirst()
return report.orElse(null)
}

@NonNull
@Optional
@Nested
fun getEnabledReports(): Set<SpotBugsReport> {
return reports.matching { report -> report.isEnabled }
}

@Internal
fun getBaseName(): String {
var prunedName = name.replaceFirst("spotbugs", "")
Expand All @@ -444,4 +427,8 @@ abstract class SpotBugsTask : DefaultTask(), VerificationTask {
append(prunedName.substring(1))
}
}

@Internal
internal fun getRequiredReports() =
reports.matching { it.required.get() }.asMap.values
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package com.github.spotbugs.snom.internal

import com.github.spotbugs.snom.SpotBugsReport
import com.github.spotbugs.snom.SpotBugsTask
import org.gradle.api.GradleException
import org.gradle.api.file.FileCollection
Expand Down Expand Up @@ -58,7 +57,7 @@ abstract class SpotBugsRunner {
if (task.showProgress.getOrElse(Boolean.FALSE)) {
args.add("-progress")
}
for (report: SpotBugsReport in task.getEnabledReports()) {
task.getRequiredReports().forEach { report ->
val reportFile = report.outputLocation.asFile.get()
val dir = reportFile.parentFile
dir.mkdirs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SpotBugsRunnerForHybrid(
}
params.getIgnoreFailures().set(task.ignoreFailures)
params.getShowStackTraces().set(task.showStackTraces)
task.getEnabledReports().stream()
task.getRequiredReports()
.map(SpotBugsReport::getOutputLocation)
.forEach(params.getReports()::add)
if (javaLauncher.isPresent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory
import java.io.File
import java.net.URI
import java.nio.file.Path
import java.util.stream.Collectors
import javax.inject.Inject

class SpotBugsRunnerForJavaExec @Inject constructor(
Expand Down Expand Up @@ -56,7 +55,8 @@ class SpotBugsRunnerForJavaExec @Inject constructor(
val errorMessage = buildString {
append("Verification failed: SpotBugs execution thrown exception.")
val reportPaths =
task.getEnabledReports().stream()
task.getRequiredReports()
.asSequence()
.map(SpotBugsReport::getOutputLocation)
.map(RegularFileProperty::getAsFile)
.map {
Expand All @@ -65,7 +65,7 @@ class SpotBugsRunnerForJavaExec @Inject constructor(
.map(File::toPath)
.map(Path::toUri)
.map(URI::toString)
.collect(Collectors.toList())
.toList()
if (reportPaths.isNotEmpty()) {
append("See the report at: ")
append(reportPaths.joinToString(","))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SpotBugsRunnerForWorker @Inject constructor(
params.getArguments().addAll(buildArguments(task))
params.getIgnoreFailures().set(task.getIgnoreFailures())
params.getShowStackTraces().set(task.showStackTraces)
task.getEnabledReports().stream()
task.getRequiredReports()
.map(SpotBugsReport::getOutputLocation)
.forEach(params.getReports()::add)
}
Expand Down

0 comments on commit 2ab3c45

Please sign in to comment.