Forbid wildcard imports with Spotless - #12262
Conversation
3fc2c07 to
878d85d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 878d85d8d4
ℹ️ 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".
There was a problem hiding this comment.
The main build expands wildcard imports. Two separate Gradle builds still accept wildcard imports, so the repository-wide rule is incomplete.
🤖 Datadog Autotest · Commit 878d85d · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
This comment has been minimized.
This comment has been minimized.
878d85d to
a73f602
Compare
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Debugger benchmarksParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 5 unstable metrics. See unchanged results
Request duration reports for reportsgantt
title reports - request duration [CI 0.99] : candidate=None, baseline=None
dateFormat X
axisFormat %s
section baseline
noprobe (364.269 µs) : 334, 395
. : milestone, 364,
basic (343.482 µs) : 337, 350
. : milestone, 343,
loop (8.113 ms) : 8050, 8177
. : milestone, 8113,
section candidate
noprobe (367.061 µs) : 332, 402
. : milestone, 367,
basic (343.997 µs) : 337, 351
. : milestone, 344,
loop (8.114 ms) : 8050, 8178
. : milestone, 8114,
|
a73f602 to
c9ec832
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9ec832e8c
ℹ️ 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".
There was a problem hiding this comment.
More details
The formatter rules apply consistently across the main and separate Gradle builds. The source edits contain import changes and adjacent whitespace only.
🤖 Datadog Autotest · Commit c9ec832 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
Kafka / producer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 3 metrics, 0 unstable metrics. See unchanged results
|
c9ec832 to
a576807
Compare
There was a problem hiding this comment.
The new rule does not cover buildSrc/modifiable-config-agent. A wildcard import can enter that Java project without a Spotless error.
🤖 Datadog Autotest · Commit a576807 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
a503e53 to
7bcf2ef
Compare
7bcf2ef to
403c994
Compare
Kafka / consumer-benchmarkParameters
See matching parameters
SummaryFound 0 performance improvements and 1 performance regressions! Performance is the same for 2 metrics, 0 unstable metrics.
See unchanged results
|
What Does This Do
Configures Spotless to remove unused Java imports and reject wildcard imports across the repository. All existing wildcard imports are expanded to explicit imports.
The PR is intentionally split into two commits to simplify review:
Forbid wildcard imports with Spotlesscontains the six build and formatter configuration files. It appliesforbidWildcardImports()to the main build, the standalone dependency-validation build, and both JavabuildSrcprojects. It also preserves the localized Netty 3.8 GrEclipse compatibility override.Expand existing wildcard importscontains the existing source-formatting output: 173 Java, Scala, Groovy, or source-fixture files, including the complete explicit imports required by the Spring Boot JPA smoke application and the JSP source fixture.Motivation
Wildcard imports obscure the dependencies used by a source file and conflict with the repository's import conventions. The lightweight built-in Spotless check prevents new wildcard imports; if one is introduced,
spotlessCheckreports it and the developer can replace it with explicit imports.Automatic
expandWildcardImports()was evaluated first, but it is too memory-greedy for this repository. The step constructs JavaParser symbol solvers from each source-set classpath, and heap analysis showed those solver graphs retained across thousands of Spotless formatter instances until an 8 GiB Gradle heap was exhausted. The final implementation therefore usesforbidWildcardImports()rather than automatic expansion.Additional Notes
Netty 3.8 uses the current GrEclipse formatter locally because the repository-wide GrEclipse 4.27 pin cannot format those tests. The localized override and its generated compatibility formatting can be removed after that pin is lifted. See diffplug/spotless#3013.
The centralized Spotless setup follows the existing formatter configuration introduced and updated in #12208.
Validation:
./gradlew spotlessCheck writeMainVersionFile --rerun-tasks --parallel --max-workers=4./gradlew :dd-java-agent:agent-debugger:debugger-el:test --tests com.datadog.debugger.el.expressions.HasAnyExpressionTest./gradlew :dd-java-agent:agent-tooling:test --tests datadog.trace.agent.tooling.stratum.StratumManagerTest(2 tests)./gradlew :dd-smoke-tests:apm-tracing-disabled:bootJar./gradlew :dd-smoke-tests:springboot-jpa:bootWar./gradlew -p buildSrc :call-site-instrumentation-plugin:spotlessCheck./gradlew -p buildSrc :modifiable-config-agent:spotlessCheck :modifiable-config-agent:build./gradlew -p test-published-dependencies spotlessCheck./gradlew -p test-published-dependencies :agent-logs-on-java-7:compileTestJavaContributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: N/A