versionCatalog() silently deletes standalone comments at section boundaries and EOF
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- java
- Área
- build-system
Línea de trabajo
Empieza en lib/src/main/java/com/diffplug/spotless/toml/VersionCatalogStep.java, especialmente en parseSections() y el manejo de pendingComments. Reproduce los casos de límites de sección y EOF con las pruebas locales de JUnit que llaman a VersionCatalogStep.create() mediante StepHarness. Se considera terminado cuando los comentarios independientes en ambas posiciones sobreviven al formateo sin errores ni pérdida de datos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
versionCatalog() silently deletes standalone comments when they are either:
- between the final entry of one table and the next table header, or
- after the final entry at end of file.
The formatting task succeeds, so these comments are removed without an error or lint. This reproduces with the released Spotless Gradle plugin 8.10.2 and at commit cd8b6e2b4532f6533bd78c0d0ffec8ee37cae0e6 (the merge commit for #3042).
Environment
- Gradle: 9.7.1
- Spotless Gradle plugin: 8.10.2
- Also reproduced at commit:
cd8b6e2b4532f6533bd78c0d0ffec8ee37cae0e6(the merge commit for #3042) - OS: Windows 11 10.0 amd64
- JVM: 21.0.8
Spotless configuration
plugins {
id 'com.diffplug.spotless' version '8.10.2'
}
spotless {
toml {
target 'gradle/libs.versions.toml'
versionCatalog()
}
}
Input
gradle/libs.versions.toml:
[versions]
zoo = "1.0"
# keep this trailing comment
[libraries]
foo = { module = "g:a", version.ref = "zoo" }
# keep this final comment
Steps to reproduce
./gradlew spotlessApply --stacktrace
Actual output file
[versions]
zoo = "1.0"
[libraries]
foo = { module = "g:a", version.ref = "zoo" }
Both comments are removed.
Expected output
Both comments should be preserved. Their exact attachment to the preceding table or following header is less important than avoiding data loss.
Console output
There is no error or lint. The task reports success:
> Task :spotlessToml
> Task :spotlessTomlApply
> Task :spotlessApply
BUILD SUCCESSFUL in 20s
2 actionable tasks: 2 executed
The released-plugin reproduction above was run as a minimal Gradle project using version 8.10.2. The commit-level reproduction was verified separately with local JUnit tests which call VersionCatalogStep.create() through StepHarness using the same section-boundary and EOF inputs; it was not run through a source-built Gradle plugin.
Suspected cause
VersionCatalogStep.parseSections() stores standalone comments in pendingComments, but only attaches them when a later entry is parsed. A new table header clears pendingComments, and pending comments are not flushed at EOF:
#3042 fixed other comment/quote-related data-loss cases, but these section-boundary and EOF cases remain reproducible at commit cd8b6e2b4532f6533bd78c0d0ffec8ee37cae0e6 after that change.
- Lenguaje dominante
- Java
- Estrellas
- 5.7k
- Forks
- 560
- Merge medio
- 1 d 13 h
- PR fusionados (30 d)
- 43
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de diffplug/spotless
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
Todos los issues de diffplug/spotless
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
elastic/gradle-plugins#157 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
cryptomator/hub#497 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
johanhaleby/occurrent#1120 ·