Skip to content

Commit a3237e1

Browse files
committed
fix: required property cannot disable the report
1 parent fb536cb commit a3237e1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/main/groovy/com/github/spotbugs/snom/SpotBugsReport.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ public abstract class SpotBugsReport
3636
CustomizableHtmlReport // to expose CustomizableHtmlReport#setStylesheet to build script
3737
{
3838
private final RegularFileProperty destination;
39-
private final Property<Boolean> isEnabled;
4039
private final Property<Boolean> isRequired;
4140
private final SpotBugsTask task;
4241

4342
@Inject
4443
public SpotBugsReport(ObjectFactory objects, SpotBugsTask task) {
4544
this.destination = objects.fileProperty();
46-
this.isEnabled = objects.property(Boolean.class);
47-
this.isRequired = objects.property(Boolean.class).value(Boolean.TRUE);
45+
this.isRequired = objects.property(Boolean.class).convention(Boolean.TRUE);
4846
this.task = task;
4947
}
5048

@@ -79,21 +77,21 @@ public Property<Boolean> getRequired() {
7977
@Deprecated
8078
@Override
8179
public boolean isEnabled() {
82-
return isEnabled.getOrElse(Boolean.TRUE);
80+
return isRequired.get();
8381
}
8482

8583
/** @deprecated use {@code getRequired().set(value)} instead. */
8684
@Deprecated
8785
@Override
8886
public void setEnabled(boolean b) {
89-
isEnabled.set(b);
87+
isRequired.set(b);
9088
}
9189

9290
/** @deprecated use {@code getRequired().set(provider)} instead. */
9391
@Deprecated
9492
@Override
9593
public void setEnabled(Provider<Boolean> provider) {
96-
isEnabled.set(provider);
94+
isRequired.set(provider);
9795
}
9896

9997
/** @deprecated use {@code getOutputLocation().set(file)} instead. */

src/main/groovy/com/github/spotbugs/snom/SpotBugsTask.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,15 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
434434
@Optional
435435
@Nested
436436
SpotBugsReport getFirstEnabledReport() {
437-
java.util.Optional<SpotBugsReport> report = reports.stream().filter({ report -> report.enabled || report.required}).findFirst()
437+
java.util.Optional<SpotBugsReport> report = reports.stream().filter({ report -> report.enabled }).findFirst()
438438
return report.orElse(null)
439439
}
440440

441441
@NonNull
442442
@Optional
443443
@Nested
444444
Set<SpotBugsReport> getEnabledReports() {
445-
return reports.findAll {it.enabled}
445+
return reports.findAll { it.enabled }
446446
}
447447

448448
void setReportLevel(@Nullable String name) {

0 commit comments

Comments
 (0)