redhat-developer / redhat-developer/vscode-java

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

Ouverte
#2,300 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

content-assist
Langage dominant
TypeScript
Étoiles
2.3k
Forks
546
Merge moyen
20 h 1 min
PR mergées (30 j)
11

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la documentation de java.completion.importOrder dans package.json aux lignes 519-527 et reproduisez les étapes de organize-imports à l’aide d’un projet avec une configuration Checkstyle personnalisée. Comparez les imports obtenus avec l’ordre spécifié par Checkstyle. Le travail est terminé lorsque organize-imports n’applique plus systématiquement l’ordre par défaut lorsque Checkstyle en spécifie un autre.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java, typescript
Domaine
developer-experience, tooling
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.