Skip to content

RUM-10363: Add PreferTimeProvider.kt detekt rule#3096

Merged
kikoveiga merged 3 commits into
developfrom
kikoveiga/RUM-10363/add-detekt-rule
Jan 6, 2026
Merged

RUM-10363: Add PreferTimeProvider.kt detekt rule#3096
kikoveiga merged 3 commits into
developfrom
kikoveiga/RUM-10363/add-detekt-rule

Conversation

@kikoveiga

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a detekt rule to enforce the usage of the TimeProvider interface rather than System time calls in production code.

Motivation

Guarantee code is coherent and testable.

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)

@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/add-detekt-rule branch from b6e315b to d5f1117 Compare January 2, 2026 17:11
@kikoveiga kikoveiga self-assigned this Jan 2, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jan 2, 2026

Copy link
Copy Markdown

🎯 Code Coverage
Patch Coverage: 90.00%
Overall Coverage: 66.48% (-4.76%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9e34f78 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter

codecov-commenter commented Jan 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.43%. Comparing base (17c117e) to head (9e34f78).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
.../com/datadog/android/internal/time/TimeProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3096      +/-   ##
===========================================
+ Coverage    71.40%   71.43%   +0.03%     
===========================================
  Files          881      880       -1     
  Lines        32460    32480      +20     
  Branches      5466     5473       +7     
===========================================
+ Hits         23178    23201      +23     
- Misses        7729     7739      +10     
+ Partials      1553     1540      -13     
Files with missing lines Coverage Δ
.../core/internal/time/DefaultAppStartTimeProvider.kt 100.00% <100.00%> (ø)
...lin/com/datadog/android/rum/internal/RumFeature.kt 90.05% <100.00%> (+0.31%) ⬆️
...ernal/domain/battery/DefaultBatteryInfoProvider.kt 83.33% <100.00%> (+4.26%) ⬆️
.../com/datadog/android/internal/time/TimeProvider.kt 0.00% <0.00%> (ø)

... and 42 files with indirect coverage changes

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

@kikoveiga
kikoveiga marked this pull request as ready for review January 2, 2026 17:53
@kikoveiga
kikoveiga requested a review from a team as a code owner January 2, 2026 17:53
0xnm
0xnm previously approved these changes Jan 5, 2026
ambushwork
ambushwork previously approved these changes Jan 5, 2026
@kikoveiga
kikoveiga dismissed stale reviews from ambushwork and 0xnm via 6f811ab January 5, 2026 16:40
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/add-detekt-rule branch from 6f811ab to 7223a54 Compare January 5, 2026 16:41
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/add-detekt-rule branch from 7223a54 to 0f09026 Compare January 5, 2026 17:24
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/add-detekt-rule branch from 0f09026 to 368c257 Compare January 5, 2026 17:45
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-10363/add-detekt-rule branch from 52b869a to 9e34f78 Compare January 5, 2026 21:53
@kikoveiga
kikoveiga requested a review from 0xnm January 6, 2026 09:17
""".trimIndent()

val findings = PreferTimeProvider(config).lint(code)
assertThat(findings).hasSize(0)

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.

very nit, no need to change: for the empty case there is also isEmpty assertion

@kikoveiga
kikoveiga merged commit 70ecc68 into develop Jan 6, 2026
26 checks passed
@kikoveiga
kikoveiga deleted the kikoveiga/RUM-10363/add-detekt-rule branch January 6, 2026 10:02
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