`removeUnusedImports()` does not parse Markdown Javadoc

Aperta
#3,161 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@1AbdullahButt ci sta già lavorando.

Dal 6/11/2026.

  • #3163 di @1AbdullahButt — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

  • 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.

Lingua principale
Java
Stelle
5.7k
Fork
565
Merge medio
3g 7h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di diffplug/spotless

Tutte le issue di diffplug/spotless

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.