Skip to content

Commit

Permalink
fix: required property cannot disable the report
Browse files Browse the repository at this point in the history
  • Loading branch information
KengoTODA committed Dec 8, 2021
1 parent fb536cb commit a3237e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ public abstract class SpotBugsReport
CustomizableHtmlReport // to expose CustomizableHtmlReport#setStylesheet to build script
{
private final RegularFileProperty destination;
private final Property<Boolean> isEnabled;
private final Property<Boolean> isRequired;
private final SpotBugsTask task;

@Inject
public SpotBugsReport(ObjectFactory objects, SpotBugsTask task) {
this.destination = objects.fileProperty();
this.isEnabled = objects.property(Boolean.class);
this.isRequired = objects.property(Boolean.class).value(Boolean.TRUE);
this.isRequired = objects.property(Boolean.class).convention(Boolean.TRUE);
this.task = task;
}

Expand Down Expand Up @@ -79,21 +77,21 @@ public Property<Boolean> getRequired() {
@Deprecated
@Override
public boolean isEnabled() {
return isEnabled.getOrElse(Boolean.TRUE);
return isRequired.get();
}

/** @deprecated use {@code getRequired().set(value)} instead. */
@Deprecated
@Override
public void setEnabled(boolean b) {
isEnabled.set(b);
isRequired.set(b);
}

/** @deprecated use {@code getRequired().set(provider)} instead. */
@Deprecated
@Override
public void setEnabled(Provider<Boolean> provider) {
isEnabled.set(provider);
isRequired.set(provider);
}

/** @deprecated use {@code getOutputLocation().set(file)} instead. */
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,15 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
@Optional
@Nested
SpotBugsReport getFirstEnabledReport() {
java.util.Optional<SpotBugsReport> report = reports.stream().filter({ report -> report.enabled || report.required}).findFirst()
java.util.Optional<SpotBugsReport> report = reports.stream().filter({ report -> report.enabled }).findFirst()
return report.orElse(null)
}

@NonNull
@Optional
@Nested
Set<SpotBugsReport> getEnabledReports() {
return reports.findAll {it.enabled}
return reports.findAll { it.enabled }
}

void setReportLevel(@Nullable String name) {
Expand Down

0 comments on commit a3237e1

Please sign in to comment.