Skip to content

refactor: use record patterns for full-component access (S6878)#204

Merged
dfa1 merged 1 commit into
mainfrom
s6878-record-patterns
Jul 6, 2026
Merged

refactor: use record patterns for full-component access (S6878)#204
dfa1 merged 1 commit into
mainfrom
s6878-record-patterns

Conversation

@dfa1

@dfa1 dfa1 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Clears SonarQube java:S6878 ("Use record pattern instead of explicit field access") — the rule fires when a type-pattern binding's variable is used only to call component accessors, covering every component.

Converts 26 such sites to record deconstruction, e.g.:

case DType.Bool b -> createFbsBool(fbb, b.nullable());
// →
case DType.Bool(var nullable) -> createFbsBool(fbb, nullable);

across PredicateEvaluator, VortexWriter.serializeDType, VariantEncodingEncoder, MaskedEncodingEncoder, CascadingCompressor, VortexGridTui, JdbcImporter. Matches the idiom already used in SchemaCommand.formatDType.

Cases that read only a subset of components are deliberately left as plain bindings so no unused component binding is introduced: DType.Primitive → nullable in isMaskable, DType.Extension (unused nullable), Predicate.Between (passed whole).

Correctness: record patterns bind positionally, so component order was verified against each record declaration by an independent review pass (Struct fieldNames/fieldTypes not transposed, Primitive ptype/nullable correct, NullableData flow-scoping valid). ./mvnw verify green including the Rust interop oracle, which guarantees serializeDType stays byte-identical on the wire.

🤖 Generated with Claude Code

Convert type-pattern bindings whose variable was used only to call every
component accessor into record deconstruction patterns, e.g.
  case DType.Bool b -> ... b.nullable()
  case DType.Bool(var nullable) -> ... nullable
Matches the existing idiom in SchemaCommand.formatDType and clears Sonar
java:S6878. 26 sites across PredicateEvaluator, VortexWriter.serializeDType,
VariantEncodingEncoder, MaskedEncodingEncoder, CascadingCompressor,
VortexGridTui, JdbcImporter.

Cases accessing only a subset (DType.Primitive->nullable in isMaskable,
DType.Extension, Predicate.Between) are left as plain bindings so no unused
component binding is introduced. Behavior-preserving; the Rust interop oracle
confirms serializeDType stays byte-identical.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dfa1 dfa1 merged commit 5e58788 into main Jul 6, 2026
6 checks passed
@dfa1 dfa1 deleted the s6878-record-patterns branch July 6, 2026 18:11
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