Skip to content

RUM-4120: Add Detekt rule to enforce copyright headers on Kotlin source files#3291

Merged
hamorillo merged 3 commits into
developfrom
hector.morilloprieto/RUM-4120
Mar 25, 2026
Merged

RUM-4120: Add Detekt rule to enforce copyright headers on Kotlin source files#3291
hamorillo merged 3 commits into
developfrom
hector.morilloprieto/RUM-4120

Conversation

@hamorillo

@hamorillo hamorillo commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Introduces a Detekt AbsentOrWrongFileLicense rule that verifies every .kt source file in the repository starts with the standard DataDog header.
  • Fixes all pre-existing violations found across the codebase.

Motivation

Copyright headers were only enforced via the IDE's IDEA copyright profile, which relies on developers remembering to apply it. Several files had missing, incorrectly indented, or typoed headers with no automated safety net. This rule makes violations a CI failure.

Additional Notes

  • A license.template file is added at the repo root — this is the single source of truth for the expected header, read by Detekt at analysis time.
  • Exclusions are narrowly scoped: build outputs, auto-generated buildSrc model fixtures, NoOpFactory test resource fixtures, and vendored dd-trace-java test files.
  • .kts files were already excluded from the Detekt Gradle task (-ex "**/*.kts"). The copyright headers on .kts files have been added and are correct. We can dive deeper into this if needed.

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)

@datadog-prod-us1-5

This comment has been minimized.

@hamorillo
hamorillo force-pushed the hector.morilloprieto/RUM-4120 branch from 5c34ab1 to 5b2e3e6 Compare March 25, 2026 10:59
@codecov-commenter

codecov-commenter commented Mar 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.40%. Comparing base (d16c503) to head (5b2e3e6).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3291      +/-   ##
===========================================
- Coverage    71.44%   71.40%   -0.04%     
===========================================
  Files          943      943              
  Lines        34821    34821              
  Branches      5899     5899              
===========================================
- Hits         24875    24862      -13     
- Misses        8281     8292      +11     
- Partials      1665     1667       +2     
Files with missing lines Coverage Δ
...l/mappers/semantics/CheckboxSemanticsNodeMapper.kt 93.80% <ø> (ø)
...compat/widget/DatadogActionBarContainerAccessor.kt 100.00% <ø> (ø)
...al/domain/event/CoreTracerSpanToSpanEventMapper.kt 90.22% <ø> (+1.09%) ⬆️

... and 44 files with indirect coverage changes

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

@hamorillo

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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".

@hamorillo
hamorillo marked this pull request as ready for review March 25, 2026 13:01
@hamorillo
hamorillo requested review from a team as code owners March 25, 2026 13:01

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

Comment thread license.template
@@ -0,0 +1,5 @@
/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have it in https://github.com/DataDog/dd-sdk-android/blob/develop/.idea/copyright/Datadog.xml, maybe we can parse from there to have a single source of truth?

Upd: ah, I see, it is built-in rule which requires copyright in this format.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it is built-in rule which requires copyright in this format.

Yeah, 😞

What I was unsure about is where to place the licence.template file. I don’t really like putting it in the root, but we already have other Detekt files there. If you have a strong opinion on this, let me know.

@hamorillo
hamorillo merged commit d6fa6af into develop Mar 25, 2026
26 checks passed
@hamorillo
hamorillo deleted the hector.morilloprieto/RUM-4120 branch March 25, 2026 15:57
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