Skip to content

Fix flaky InternalApiUsageDetectorTest due to Kotlin reserved keywords in package regex#3522

Merged
kikoveiga merged 1 commit into
developfrom
kikoveiga/fix-flaky-lint-test-keyword-package
Jun 9, 2026
Merged

Fix flaky InternalApiUsageDetectorTest due to Kotlin reserved keywords in package regex#3522
kikoveiga merged 1 commit into
developfrom
kikoveiga/fix-flaky-lint-test-keyword-package

Conversation

@kikoveiga

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a flaky test in InternalApiUsageDetectorTest where Forge-generated package names could contain Kotlin reserved keywords (e.g. org.do, com.datadog.for), causing the lint test runner to fail when parsing the generated Kotlin stubs.

Motivation

The @StringForgery regex patterns (com|org|fr)\\.[a-z]{1,10} and com\\.datadog(|\\.[a-z]{1,13}) could generate segments like do, for, fun, val, etc. — all reserved Kotlin keywords — as package name components. When embedded in package declarations inside lint test stubs, these caused an IllegalStateException in the lint test runner.

Fix: append pkg to each variable-length segment, making it impossible for the generated value to be a reserved word.

Additional Notes

No behaviour change — the tests only care whether the package starts with com.datadog or not; the exact suffix is irrelevant to the detector logic.

@kikoveiga
kikoveiga requested review from a team as code owners June 9, 2026 10:31
@kikoveiga kikoveiga changed the title Fix flaky InternalApiUsageDetectorTest due to Kotlin reserved keywords in package regex Fix flaky InternalApiUsageDetectorTest due to Kotlin reserved keywords in package regex Jun 9, 2026

@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 discovery

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.24%. Comparing base (0b3c64a) to head (3173956).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3522      +/-   ##
===========================================
+ Coverage    72.21%   72.24%   +0.02%     
===========================================
  Files          965      965              
  Lines        35643    35643              
  Branches      5948     5948              
===========================================
+ Hits         25739    25747       +8     
+ Misses        8278     8275       -3     
+ Partials      1626     1621       -5     

see 33 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 merged commit e0d2f78 into develop Jun 9, 2026
28 checks passed
@kikoveiga
kikoveiga deleted the kikoveiga/fix-flaky-lint-test-keyword-package branch June 9, 2026 11:32
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.

3 participants