Improve refactoring mining hint quality#1178
Conversation
JUnit Test Overview ReportGenerated on: 28488091203 Overall Statistics
Test Summary by Plugin
Disabled Tests Detailssandbox_common_test (2 disabled)
sandbox_functional_converter_test (26 disabled)
sandbox_int_to_enum_test (1 disabled)
sandbox_jface_cleanup_test (1 disabled)
sandbox_junit_cleanup_test (36 disabled)
sandbox_platform_helper_test (1 disabled)
This report is automatically generated by the Test Report workflow |
Test Results 235 files 235 suites 4m 29s ⏱️ Results for commit 38bda1d. ♻️ This comment has been updated with latest results. |
✅ All Tests PassedNo test failures detected. This comment is automatically updated with test failure details for each commit. |
There was a problem hiding this comment.
Pull request overview
This PR improves the signal-to-noise ratio of refactoring mining by curating bundled hint sets, making behavior-changing modernizations hint-only, stabilizing rule IDs, and ensuring guard evaluation is deterministic by forwarding the configured Java source level into mining.
Changes:
- Refines bundled hint libraries (collections/modernize/deprecations/performance/etc.) to reduce noisy rewrites, avoid duplicate findings, and add stable
@idrule identifiers. - Updates the mining CLI/scanner pipeline to forward compiler source options into guard evaluation and prefer rule IDs in reports.
- Adds targeted tests to validate source-version parsing/forwarding and bundled-hint behavior expectations.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sandbox_mining_cli/src/test/java/org/sandbox/mining/scanner/SourceScannerTest.java | Adds regression test ensuring compiler source options affect sourceVersionGE(...) guard evaluation. |
| sandbox_mining_cli/src/test/java/org/sandbox/mining/config/MiningConfigTest.java | Adds tests for parsing/defaulting the configured mining source version. |
| sandbox_mining_cli/src/main/java/org/sandbox/mining/scanner/SourceScanner.java | Adds scan overload that forwards compiler options into hint processing and prefers rule IDs for reporting. |
| sandbox_mining_cli/src/main/java/org/sandbox/mining/MiningCli.java | Loads curated bundled hints, forwards source level into scanning, and adjusts CLI messaging/cleanup behavior. |
| sandbox_mining_cli/src/main/java/org/sandbox/mining/config/MiningConfig.java | Introduces sourceVersion configuration with defaults and YAML parsing. |
| sandbox_common_core/src/test/java/org/sandbox/jdt/triggerpattern/test/HintRuleTestSupport.java | Extends rule-test harness to pass source version/compiler options and improves replacement application correctness. |
| sandbox_common_core/src/test/java/org/sandbox/jdt/triggerpattern/test/BundledHintRuleBehaviorTest.java | Adds behavior tests for stable IDs, conservative rewrites, hint-only migrations, and de-duplication across bundles. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/string-equals.sandbox-hint | Removes reflexive-equals duplicates and adds stable IDs/severity metadata for remaining rules. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/stream-performance.sandbox-hint | Adds stable IDs/severity and clarifies hint-only messaging for review-only findings. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/probable-bugs.sandbox-hint | Adds stable IDs/severity and removes binding-unsafe active rules to avoid false positives in mining. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/modernize-java9.sandbox-hint | Makes risky migrations hint-only and adds guards/IDs to keep modernization conservative. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/io-performance.sandbox-hint | Adds stable IDs/severity and improves rule descriptions for mining output clarity. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/deprecations.sandbox-hint | Updates deprecated wrapper-constructor replacements to use valueOf(...) and adds stable IDs. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/collections.sandbox-hint | Removes broad diamond-only constructor rewrite noise and keeps only guarded empty-factory rewrites with stable IDs. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/collection-performance.sandbox-hint | Adds stable IDs and documents why keySet().remove(...) rewrite is intentionally excluded. |
| sandbox_common_core/src/main/resources/org/sandbox/jdt/triggerpattern/internal/arrays.sandbox-hint | Adds stable IDs and documents binding-safety constraints for array-related rules. |
| .github/refactoring-mining/repos.yml | Switches nightly mining to curated hints and sets source-version: "21" for deterministic guard behavior. |
| Files.walk(dir) | ||
| .sorted((a, b) -> b.compareTo(a)) // delete children first | ||
| .forEach(p -> { |
| } | ||
| } | ||
|
|
||
| private static void printUsage() { |
| private static final String FORMAT_MARKDOWN = "markdown"; //$NON-NLS-1$ | ||
| private static final String FORMAT_JSON = "json"; //$NON-NLS-1$ | ||
| private static final String FORMAT_BOTH = "both"; //$NON-NLS-1$ | ||
| private static final String COMPILER_SOURCE_OPTION = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$ |
| Object source = settings.get("source-version"); //$NON-NLS-1$ | ||
| if (source != null && !source.toString().isBlank()) { | ||
| config.sourceVersion = source.toString(); | ||
| } |
| } | ||
|
|
||
| public void setSourceVersion(String sourceVersion) { | ||
| this.sourceVersion = sourceVersion != null && !sourceVersion.isBlank() ? sourceVersion : "1.8"; //$NON-NLS-1$ |
|
@copilot Consider Review comments and fix build |
Summary
This PR addresses the quality issues exposed by mining report PR #1177.
Hint quality changes
ArrayList/HashSet/Hashtableconstructor rewrites from the activecollectionshint bundle.collections.valueOf(...)instead of changing object-producing constructors into primitive parsers.collections7.string-equals; those belong toprobable-bugs.Mining pipeline changes
.github/refactoring-mining/repos.yml.sourceVersionGE(...)behaves deterministically during mining.collectionsfrom the nightly mining configuration.Context
PR #1177 showed that the previous setup rewarded high match count over actionable findings. Most results came from repeated collection modernization patterns such as
new ArrayList(...) -> new java.util.ArrayList<>(...), including overlapping no-arg and variadic constructor rules. This PR reduces that noise and makes future reports better suited for triage into DSL-based quickfix work.