`removeUnusedImports()` does not parse Markdown Javadoc
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java
- 领域
- build-system, tooling
调研方向
Start by tracing the Java removeUnusedImports() implementation and its formatter integration; the issue identifies Gradle classloading and javac's service loader as the suspected path. Reproduce with the provided Java snippet and default settings, then check whether ArrayList and Collection remain imported when referenced only in Markdown Javadoc. Done means those references are preserved during formatting.
由索引模型根据 Issue 内容生成。
描述
- Java version: 25.0.5.0.3
- Gradle version: 9.7.1
- Gradle plugin version: 8.11.0
When using removeUnusedImports() with the default settings, the formatter does not parse Markdown Javadoc comments, meaning classes only referenced within them will be stripped. For example, with the following config:
spotless {
java {
removeUnusedImports()
}
}
This file:
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Predicate;
/// [ArrayList#add] [Collection#removeIf(Predicate)]
class Test {}
Will be reformatted to:
/// [ArrayList#add] [Collection#removeIf(Predicate)]
class Test {}
Google's formatter uses javac to parse the classes, so this in theory should work. However, Markdown parsing is handled in a separate step — javac uses a service loader to load the class responsible for parsing/transforming markdown.
Due to Gradle's funky classloading, the service loader doesn't find the Markdown parser, and so Markdown doc comments are ignored. I'm not really sure there's a good way to fix this, short of running the formatter in a separate forked process.
- 主要语言
- Java
- 星标
- 5.7k
- 派生
- 565
- 平均合并
- 3 天 7 小时
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
diffplug/spotless 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 70/100
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 43/100
diffplug/spotless#3147 · 1 个 reaction ·
维护者通常 1 天内回复
查看 diffplug/spotless 的全部 Issue
相似的 Issue
-
bug web-ui
难度 2/5 1-3 小时 新手友好度 67/100
jenkinsci/jenkins#27705 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
googleads/googleads-mobile-flutter#1541 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
Julow/Unexpected-Keyboard#1490 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
Vakore/ZappierGames#275 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
unitycatalog/unitycatalog#2148 ·
维护者通常 2 天内回复