Skip to content

Extract framework-agnostic builder/DTO model into its own project (resolves Sonar duplication gate) #233

Description

@AndreasIgel

Summary

The SonarCloud new-code Duplication density on main is ~7.6% (limit 3%), failing the quality gate. The duplication is by design: the processor carries two parallel model families — a generation-side model (BuilderDefinitionDto, BuilderMethodDto, FieldDto, ...) and a rendering-side model (GenerationTargetClassDto, MethodDto, ...), bridged by BuilderToGenerationTypeMapper. They are ~90% structurally identical, which Sonar counts as duplication.

Rather than force a base-class refactor, we will resolve this by extracting the fundamental, framework-agnostic model into its own project.

Goal

Provide a standalone, reusable foundation that any annotation processor could build on:

  • A clean set of DTOs describing the class/builder/field/method model that users work with.
  • Hide the concrete framework tooling used to actually emit source (currently Roaster) behind that model, so consumers depend on the DTOs, not on the code-generation library.
  • Easy setup: define the DTOs, hand them to the generator, get generated classes — without wiring up framework internals.

Proposed direction (to refine during design)

  • New module/project (e.g. codegen-model / codegen-core) containing the neutral DTOs + a generator SPI.
  • Move/merge the currently-duplicated generation & rendering models into that single model, eliminating the parallel duplication.
  • simple-builders processor depends on it and maps @SimpleBuilder analysis results onto the shared model.
  • Keep the Roaster-based emitter behind an interface so it can be swapped.

Acceptance criteria

  • Shared model extracted to its own project/module; the parallel generation/rendering duplication is removed at the source.
  • SonarCloud new-code Duplication condition no longer flags the parallel DTOs.
  • simple-builders behavior and generated output unchanged (generated example builders byte-identical).
  • Documented, minimal setup for defining DTOs and generating classes without exposing the framework tooling.

Notes

Until this lands, the duplication gate condition is accepted (agreed with maintainer). Related quality-gate items are tracked separately: NPE reliability fixes and the fork-sonar.yml security analysis task.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions