NoOpImplementation improvements [3/3] RUM-16477 Add NoOp name collision detection and customName support#3470
Conversation
This comment has been minimized.
This comment has been minimized.
NoOpImplementation improvements [3/3] RUM-7390 Add NoOp name collision detection and customName support
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2943d3a56
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b2943d3 to
86ce9a9
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3470 +/- ##
===========================================
+ Coverage 72.18% 72.24% +0.06%
===========================================
Files 964 964
Lines 35583 35583
Branches 5926 5926
===========================================
+ Hits 25684 25705 +21
+ Misses 8280 8269 -11
+ Partials 1619 1609 -10 🚀 New features to boost your workflow:
|
b06a347 to
d98a5c1
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for explicit NoOp implementation names and collision diagnostics in the NoOp KSP processor.
Changes:
- Adds
customNameto@NoOpImplementation. - Detects generated-name collisions and existing generated-file conflicts with clearer errors.
- Adds processor tests and fixtures for custom names, invalid names, and collision scenarios.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tools/noopfactory/src/main/kotlin/com/datadog/tools/annotation/NoOpImplementation.kt |
Extends the annotation API with customName. |
tools/noopfactory/src/main/kotlin/com/datadog/tools/noopfactory/NoOpAnnotationExt.kt |
Adds helper logic for safe annotation argument reads and name resolution. |
tools/noopfactory/src/main/kotlin/com/datadog/tools/noopfactory/NoOpFactorySymbolProcessor.kt |
Implements custom name resolution, collision detection, and file-exists error reporting. |
tools/noopfactory/src/test/kotlin/com/datadog/tools/noopfactory/NoOpFactoryProviderTest.kt |
Adds tests for custom names and collision/error paths. |
tools/noopfactory/src/test/resources/src/CollidingInterfaces.kt |
Fixture for default generated-name collision. |
tools/noopfactory/src/test/resources/src/CustomNameCollidingWithGenerated.kt |
Fixture for custom name colliding with an auto-generated name. |
tools/noopfactory/src/test/resources/src/CustomNameInterface.kt |
Fixture for successful custom name generation. |
tools/noopfactory/src/test/resources/src/InvalidCustomNameInterface.kt |
Fixture for invalid custom name validation. |
tools/noopfactory/src/test/resources/src/PreExistingFileCustomNameInterface.kt |
Fixture for existing-file conflict with custom name. |
tools/noopfactory/src/test/resources/src/PreExistingFileInterface.kt |
Fixture for existing-file conflict with default name. |
tools/noopfactory/src/test/resources/src/SameCustomName.kt |
Fixture for duplicate custom names. |
tools/noopfactory/src/test/resources/gen/MyCustomNoOp.kt |
Expected generated output for custom name generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Detect when two interfaces would generate the same NoOp class name and report a KSP error instead of silently overwriting the file. - Add customName parameter to @NoOpImplementation to let users resolve collisions by overriding the generated class name. - Support NoOp generation for nested interfaces; guard against interfaces with restricted (private/protected) enclosing visibility. - Fix NoSuchElementException caused by KSP2 omitting default annotation args from KSAnnotation.arguments (workaround via safeAnnotationArg; see google/ksp#2356). - Fix return-type and property initializer paths to use the effective NoOp name (respecting customName) when referencing other annotated interfaces, preventing compilation failures. - Extract annotation utilities into NoOpAnnotationExt.kt. Ref: RUM-7390
- Sync customName parameter to dd-sdk-android-internal's NoOpImplementation - Rename generateTypeSpec parameter from customName to className; remove dead ifEmpty fallback - Make collision error assertions order-agnostic (satisfiesAnyOf) in two tests - Remove stale ordering comment from CustomNameCollidingWithGenerated fixture - Update dd-sdk-android-internal apiSurface and .api to include customName parameter added to NoOpImplementation - Add missing KDoc to EndPoint enum entries (pre-existing detekt warnings)
62ae506 to
f59462b
Compare
NoOpImplementation improvements [3/3] RUM-7390 Add NoOp name collision detection and customName supportNoOpImplementation improvements [3/3] RUM-16477 Add NoOp name collision detection and customName support

What does this PR do?
Adds collision detection to the NoOp KSP processor and a new
customNameparameter to@NoOpImplementation. When two interfaces would generate the sameNoOp*class name (e.g.Outer.InnerandOuterInnerboth produceNoOpOuterInner), the processor now emits a clear error and suggests usingcustomNameto resolve the conflict. ThecustomNameparameter lets callers override the generated class name entirely.Motivation
Without collision detection, two distinct interfaces silently clobber each other's generated file, producing broken or incomplete NoOp implementations at build time with no diagnostic. The new guard catches this at KSP processing time with actionable error messages.
Additional Notes
customNameagainst a Kotlin identifier regex and reports a clear error for names like"My.Invalid.Name".generatedNamesmap) and pre-existing file conflicts (viaFileAlreadyExistsException).ThrowingCodeGeneratorProvidertest helper retained because KSP 1.8.0 does not throwFileAlreadyExistsExceptionfor disk files from previous builds; two-pass compilation silently overwrites.generateNoOpImplementationrefactored intoresolveNoOpClassName,reportNameCollision, andwriteNoOpFilehelpers to satisfy detektLongMethod/ReturnCountlimits.Review checklist (to be filled by reviewers)
Ref: RUM-7390