redhat-developer / redhat-developer/vscode-java

java.completion.importOrder (even the default) takes precedence over checkstyle specs

Abierto
#2,300 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

content-assist
Lenguaje dominante
TypeScript
Estrellas
2.3k
Forks
546
Merge medio
20 h 1 min
PR fusionados (30 d)
11

Descripción

The java.completion.importOrder property, documented here
https://github.com/redhat-developer/vscode-java/blob/562afa80c0f705613c6ed3148b4d9eac82093b26/package.json#L519-L527
does not play well with checkstyle. If checkstyle specifies a different sort order for imports, the default importOrder setting will always be used instead. An unsatisfactory workaround is to attempt to specify a matching importOrder via this property. However, it's simply not as expressive as what is possible via Checkstyle, so finding an exact match is impossible.

This situation creates the highly likely event of imports being automatically sorted via the editor, and then the resulting code is in violation of checkstyle constraints, so a CI or regular build process will fail.

Here's an example of just such a sad situation: https://github.com/DSpace/DSpace/pull/8088/commits/23e93ff2857b7099ba8005d0b5b6c3b65f052f1c

Environment
  • Operating System: OSX
  • JDK version: openjdk version "11.0.2" 2019-01-15
  • Visual Studio Code version: 1.63.2
  • Java extension version: v1.3.0
Steps To Reproduce
  1. work on a Java project with a checkstyle configuration (one example: DSpace/DSspace)
  2. install a checkstyle plugin
  3. configure the checkstyle plugin to use the project configuration
  4. open a Java file
  5. click the yellow light bulb that appears over the Java file's imports, select 'organize imports'
  6. save the file
  7. validate the project against the custom checkstyle, it will fail, if the checkstyle specification for import order differs from the default value of the java.completion.importOrder property
Current Result

imports are always sorted to match the order specified by java.completion.importOrder

Expected Result

imports are sorted to match the order specified by checkstyle

Additional Informations

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con la documentación de java.completion.importOrder en package.json, en las líneas 519-527, y reproduce los pasos de organize-imports usando un proyecto con una configuración personalizada de Checkstyle. Compara los imports resultantes con el orden especificado por Checkstyle. Se considera terminado cuando organize-imports deja de aplicar incondicionalmente el orden predeterminado cuando Checkstyle especifica uno diferente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java, typescript
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.