`removeUnusedImports()` does not parse Markdown Javadoc

Aberta
#3,161 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@1AbdullahButt já está trabalhando nisso.

Desde 6/11/2026.

  • #3163 de @1AbdullahButt — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
build-system, tooling

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
Java
Estrelas
5.7k
Forks
565
Merge médio
3d 7h
PRs com merge (30d)
13

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de diffplug/spotless

Todas as issues de diffplug/spotless

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.