Skip to content

NoOpImplementation improvements [3/3] RUM-16477 Add NoOp name collision detection and customName support#3470

Merged
satween merged 2 commits into
developfrom
tvaleev/feature/add-noop-name-collision-detection
May 29, 2026
Merged

NoOpImplementation improvements [3/3] RUM-16477 Add NoOp name collision detection and customName support#3470
satween merged 2 commits into
developfrom
tvaleev/feature/add-noop-name-collision-detection

Conversation

@satween

@satween satween commented May 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds collision detection to the NoOp KSP processor and a new customName parameter to @NoOpImplementation. When two interfaces would generate the same NoOp* class name (e.g. Outer.Inner and OuterInner both produce NoOpOuterInner), the processor now emits a clear error and suggests using customName to resolve the conflict. The customName parameter 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

  • Validates customName against a Kotlin identifier regex and reports a clear error for names like "My.Invalid.Name".
  • Detects both same-round name collisions (via an in-process generatedNames map) and pre-existing file conflicts (via FileAlreadyExistsException).
  • ThrowingCodeGeneratorProvider test helper retained because KSP 1.8.0 does not throw FileAlreadyExistsException for disk files from previous builds; two-pass compilation silently overwrites.
  • All 8 new test cases pass; no existing tests regressed.
  • generateNoOpImplementation refactored into resolveNoOpClassName, reportNameCollision, and writeNoOpFile helpers to satisfy detekt LongMethod / ReturnCount limits.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

Ref: RUM-7390

satween commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

@datadog-official

This comment has been minimized.

@satween satween changed the title RUM-7390 Add NoOp name collision detection and customName support NoOpImplementation improvements [3/3] RUM-7390 Add NoOp name collision detection and customName support May 25, 2026
@satween satween marked this pull request as ready for review May 25, 2026 15:47
@satween satween requested review from a team as code owners May 25, 2026 15:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Base automatically changed from tvaleev/feature/guard-noop-generation-against-restricted to develop May 26, 2026 09:56
@satween satween marked this pull request as draft May 26, 2026 10:03
@satween satween force-pushed the tvaleev/feature/add-noop-name-collision-detection branch from b2943d3 to 86ce9a9 Compare May 26, 2026 12:55
@codecov-commenter

codecov-commenter commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.24%. Comparing base (d8f145f) to head (f59462b).

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     

see 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@satween satween force-pushed the tvaleev/feature/add-noop-name-collision-detection branch from b06a347 to d98a5c1 Compare May 26, 2026 14:42
@satween satween marked this pull request as ready for review May 26, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for explicit NoOp implementation names and collision diagnostics in the NoOp KSP processor.

Changes:

  • Adds customName to @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.

satween added 2 commits May 28, 2026 17:07
- 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)
@satween satween force-pushed the tvaleev/feature/add-noop-name-collision-detection branch from 62ae506 to f59462b Compare May 28, 2026 16:34
@satween satween merged commit e86e98d into develop May 29, 2026
27 checks passed
@satween satween deleted the tvaleev/feature/add-noop-name-collision-detection branch May 29, 2026 11:02
@satween satween changed the title NoOpImplementation improvements [3/3] RUM-7390 Add NoOp name collision detection and customName support NoOpImplementation improvements [3/3] RUM-16477 Add NoOp name collision detection and customName support May 29, 2026
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.

4 participants