Skip to content

SONARJAVA-6624 Fix S5738: Replace deprecated @EnableRuleMigrationSupport with JUnit 5 native APIs#5795

Open
daniel-teuchert-sonarsource wants to merge 1 commit into
masterfrom
fix/sonarqube-s5738-remove-deprecated-enable-rule-migration-support
Open

SONARJAVA-6624 Fix S5738: Replace deprecated @EnableRuleMigrationSupport with JUnit 5 native APIs#5795
daniel-teuchert-sonarsource wants to merge 1 commit into
masterfrom
fix/sonarqube-s5738-remove-deprecated-enable-rule-migration-support

Conversation

@daniel-teuchert-sonarsource

Copy link
Copy Markdown
Contributor

Summary

  • Removes @EnableRuleMigrationSupport (java:S5738 — deprecated class marked for removal) from 12 test files
  • Migrates JUnit 4 @Rule TemporaryFolder to JUnit 5 @TempDir Path across all affected tests
  • Updates InputFileUtils.addFile() and ExternalReportTestUtils.generateReport() helper signatures from TemporaryFolder to Path
  • Removes unused @Rule LogTester from two doc example tests (was only present for debug viewing, never asserted on)

Test plan

  • All 12 previously-flagged test files compile without @EnableRuleMigrationSupport
  • CI passes (SonarQube scan on next should no longer report S5738 issues in new code)

🤖 Generated with Claude Code

…5 native APIs

Migrate 12 test files from JUnit 4 @Rule/TemporaryFolder to JUnit 5 @tempdir Path,
and drop @EnableRuleMigrationSupport (marked for removal). Helper methods in
InputFileUtils and ExternalReportTestUtils updated to accept Path instead of
TemporaryFolder. LogTester @rule removed from doc example tests where it was
unused in assertions.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Fix S5738: Replace deprecated @EnableRuleMigrationSupport with JUnit 5 native APIs SONARJAVA-6624 Fix S5738: Replace deprecated @EnableRuleMigrationSupport with JUnit 5 native APIs Jul 15, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

SONARJAVA-6624

@gitar-bot

gitar-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
CI failed: The PR causes test failures in the `JavaSensorTest` class because the expected telemetry `type_error_count` has dropped from 205 to 199 following the JUnit 5 migration.

Overview

Two build jobs failed consistently in the sonar-java-plugin module. The failures are caused by assertion mismatches in the JavaSensorTest class, where updated code logic reports a different number of type errors than previously expected in the telemetry data.

Failures

JavaSensorTest Telemetry Mismatch (confidence: high)

  • Type: test
  • Affected jobs: 87392867998, 87393353090
  • Related to change: yes
  • Root cause: The refactoring to remove @EnableRuleMigrationSupport has resulted in a change in the reported java.analysis.test.success.type_error_count (and main.success variant). The test expects 205 errors, but the new implementation is reporting 199.
  • Suggested fix: Investigate if the reduction of 6 in type_error_count is an expected side effect of the migration to JUnit 5 native APIs. If the behavior is correct, update the test assertions in JavaSensorTest.java (lines 135 and 157) to match the new value of 199. If this count reduction indicates a loss of rule coverage or improper initialization, investigate why those 6 errors are no longer being captured.

Summary

  • Change-related failures: 1 (Test failure in JavaSensorTest due to assertion mismatch in telemetry data).
  • Infrastructure/flaky failures: 0
  • Recommended action: Review the impact of the @EnableRuleMigrationSupport removal on rule registration and analysis reporting. Update test assertions to reflect the new expected telemetry counts if the change in behavior is verified to be intentional.
Code Review ✅ Approved

Replaces deprecated @EnableRuleMigrationSupport with JUnit 5 native APIs and migrates @Rule TemporaryFolder to @TempDir Path. No issues found.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

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.

1 participant