Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILE_UNORDERED_IMPORTS error message doesn't match the style guide #1933

Open
polarene opened this issue Jun 19, 2024 · 1 comment
Open

FILE_UNORDERED_IMPORTS error message doesn't match the style guide #1933

polarene opened this issue Jun 19, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@polarene
Copy link

Describe the bug

When there is a violation on imports, the error message doesn't match Diktat style guide.
The message says:

[FILE_UNORDERED_IMPORTS] imports should be ordered alphabetically and shouldn't be separated by newlines: import [...] (diktat-ruleset:file-structure)

while the corresponding style rule says:

From top to bottom, the order is the following:

  1. Android
  2. Imports of packages used internally in your organization
  3. Imports from other non-core dependencies
  4. Java core packages
  5. kotlin stdlib

Each category should be alphabetically arranged. Each group should be separated by a blank line.

In fact, running gradle diktatFix formats the code according to the convention above.

Expected behavior

The error message should match the style guide

Steps to Reproduce

  1. shuffle import declarations or remove blank lines between groups
  2. run gradle diktatCheck

Environment information

  • diktat version: 2.0.0
  • build tool (maven/gradle): gradle
  • how is diktat run (CLI, plugin, etc.): plugin
  • kotlin version: 1.9.24
  • operating system: MacOS
@polarene polarene added the bug Something isn't working label Jun 19, 2024
@polarene
Copy link
Author

There's also an additional weird behavior: if I format the imports (manually or by Intellij) to match the desired order, diktatCheck passes even if there are no blank lines between the groups; then diktatFix doesn't make any change, I assume because it depends on the check task passing to avoid running.

But if the check task fails and you run the fix task it will format your imports adding the blank lines between groups, in addition to sorting them.

@0x6675636b796f75676974687562 0x6675636b796f75676974687562 changed the title FILE_UNORDERED_IMPORTS error message doesn't match the style guide FILE_UNORDERED_IMPORTS error message doesn't match the style guide Jun 19, 2024
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 added this to the 2.1.0 milestone Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants