redhat-developer / redhat-developer/vscode-java

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

オープン
#2,300 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

content-assist
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

package.json の 519-527 行にある java.completion.importOrder のドキュメントから始め、カスタム Checkstyle 設定を使用するプロジェクトで organize-imports の手順を再現します。結果の imports を Checkstyle で指定された順序と比較します。Checkstyle が異なる順序を指定した場合に、organize-imports がデフォルトの順序を無条件に適用しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, typescript
領域
developer-experience, tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。