Skip to content

spotbugs: suppress 6 design-intentional cast/CT findings#7639

Open
Vest wants to merge 1 commit into
PCGen:masterfrom
Vest:spotbugs-cast-ct-suppress
Open

spotbugs: suppress 6 design-intentional cast/CT findings#7639
Vest wants to merge 1 commit into
PCGen:masterfrom
Vest:spotbugs-cast-ct-suppress

Conversation

@Vest

@Vest Vest commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Add method/constructor-level @SuppressFBWarnings with one-line justifications for casts and constructor-throws that are intentional by design.

Suppressions

# Finding Location Justification
1 BC_UNCONFIRMED_CAST ConcretePersistentTransitionChoice.setChoiceActor API contract documents @throws ClassCastException for non-PersistentChoiceActor; the cast is the contract
2 BC_UNCONFIRMED_CAST FactGrouping.process Only CDOMObject can have facts (per in-code comment); type system can't express this constraint as PCGenScoped is the wider interface
3 BC_UNCONFIRMED_CAST_OF_RETURN_VALUE LevelInfoFacet.get Facet's own cache; getComponentSet() always returns ArrayList<PCLevelInfo>
4 BC_UNCONFIRMED_CAST_OF_RETURN_VALUE UnencumberedArmorFacet.getBestLoad Facet's own cache; getComponentMap() always returns TreeMap<Load, Set<Object>>
5 BC_UNCONFIRMED_CAST_OF_RETURN_VALUE UnencumberedLoadFacet.getBestLoad Facet's own cache; getComponentMap() always returns TreeMap<Load, Set<Object>>
6 CT_CONSTRUCTOR_THROW AbstractReferenceManufacturer constructor Abstract class; ManufacturableFactory is required and Objects.requireNonNull is the lightest defense against an unusable instance

SpotBugs delta (XML-verified)

  • BC_UNCONFIRMED_CAST: 3 -> 1 (-2; the third occurrence in VariableUtilities is handled in a separate PR)
  • BC_UNCONFIRMED_CAST_OF_RETURN_VALUE: 3 -> 0 (-3)
  • CT_CONSTRUCTOR_THROW: 29 -> 28 (-1)
  • Total: -6, no new findings

Validation

  • ./gradlew compileJava -> BUILD SUCCESSFUL
  • ./gradlew :test --tests "pcgen.cdom.*" -> 2355 tests, 0 failures

Add method/constructor-level @SuppressFBWarnings with one-line
justifications for casts and constructor-throws that are intentional
by design.

- BC_UNCONFIRMED_CAST @ ConcretePersistentTransitionChoice.setChoiceActor:
  API contract documents @throws ClassCastException for non-PersistentChoiceActor;
  the cast is the contract.
- BC_UNCONFIRMED_CAST @ FactGrouping.process:
  Only CDOMObject can have facts (per in-code comment); type system can't
  express this constraint as PCGenScoped is the wider interface.
- BC_UNCONFIRMED_CAST_OF_RETURN_VALUE @ LevelInfoFacet.get:
  Facet's own cache; getComponentSet() always returns ArrayList<PCLevelInfo>.
- BC_UNCONFIRMED_CAST_OF_RETURN_VALUE @ UnencumberedArmorFacet.getBestLoad:
  Facet's own cache; getComponentMap() always returns TreeMap<Load, Set<Object>>.
- BC_UNCONFIRMED_CAST_OF_RETURN_VALUE @ UnencumberedLoadFacet.getBestLoad:
  Facet's own cache; getComponentMap() always returns TreeMap<Load, Set<Object>>.
- CT_CONSTRUCTOR_THROW @ AbstractReferenceManufacturer:
  Abstract class; ManufacturableFactory is required and Objects.requireNonNull
  is the lightest defense against an unusable instance.
@Vest Vest marked this pull request as ready for review June 25, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant