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

ktlint-idea unsupport: Not Usable After Version 11.6.1 #774

Open
thxwelchs opened this issue Sep 5, 2024 · 6 comments
Open

ktlint-idea unsupport: Not Usable After Version 11.6.1 #774

thxwelchs opened this issue Sep 5, 2024 · 6 comments

Comments

@thxwelchs
Copy link

thxwelchs commented Sep 5, 2024

It seems that the ktlint-idea plugin is no longer supported after version 11.6.1. Attempts to use the plugin in later versions result in failure. Clarification on this issue and possible resolutions would be appreciated.

org.jlleitschuh.gradle.ktlint-idea

@ievgen-kapinos
Copy link

Seems READMe.md is outdated and to be updated
#775

@ievgen-kapinos
Copy link

ievgen-kapinos commented Oct 1, 2024

Anyway, this request makes sence. We have no instruction on how to configure IDE to re-format files in a same way as we have after running gradle clean ktlintFormat. I have .editorconfig file with recommended content
https://pinterest.github.io/ktlint/latest/rules/configuration-intellij-idea/

...
[*.{kt,kts}]
...
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset

Anyway, when I'm clicking in Idea Code > Reformat Code only basic formatting from .editorconfig file is applied. Command gradle clean ktlintCheck fails after such re-formatting. IDE does not know which ruleset version to apply, e.g. in my case version 1.3.0 is hardcoded in Gradle build script.

@zyberzebra
Copy link

zyberzebra commented Dec 11, 2024

[*.{kt,kts}]
ktlint_code_style=intellij_idea

@ievgen-kapinos Have you tried that?

@ievgen-kapinos
Copy link

Hi @zyberzebra
That will apply code style of IDE. Devs may use different versions of IDE. Each version formats code slightly different. Moreover even latest IDE formatting differs from Ktlint formatting with fixed version. In my team we adopted KtLint with fixed version over 30 repositories.

We need to make sure that all devs are capable to apply same formatting. Ability to make consistent re-formatting via IDE is nice feature which we would to have.

@wakingrufus
Copy link
Collaborator

ktlint_code_style=intellij_idea in combination with an .editorconfig file is the way forward. The idea gradle plugin is deprecated because Gradle has better IDE support APIs which IDEs now use to integrate with the build tool rather than relying on a plugin. Also, ktlint has also gone all-in on .editorconfig as the way to configure formatting rules, and has deprecated or removed most of programmatic ways to influence these rules

@ievgen-kapinos
Copy link

Hi @wakingrufus

Thank you for your input.

You cannot freeze formatting rules with ktlint_code_style=intellij_idea. Different versions of IDE have slightly different rules. List of ij_ properties in .editorconfig file also changes time to time. You can compare list of available properties by exporting them from different versions of IDE (Settings > Editor > Code Style > Kotlin > (gear) > Export > EditorConfig file) .

One day I've upgraded IDE and reformatted all my source code via IDE from "root folder" as I used to do. Surprise, surprise New IDE changed most of files. If you work in a team, then it is even worse, because you always have variety of IDEs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants