I am using Spotless to run ktlint in my project. I...
# ktlint
a
I am using Spotless to run ktlint in my project. I have the setup working and I have it recognising the editorConfig file. There is one really weird thing though which I am unable to figure out, some rules (I mean whole rule sets) are not recognised at all in the editorConfig file. Specifically any ktlint rules such as:
Copy code
ktlint_code_style = ktlint_official
ktlint_ignore_back_ticked_identifier = true       
ktlint_standard = enabled
What I can do is in my spotless.gradle file I can use
editorConfigOverride
to set any of these rules, so I do have a working setup, it's just some rules are set in the editorConfig and some are now in this editorConfigOverride block in my spotless gradle file. I am struggling to find anyone who's has this issue before, wondering if my set up is wrong, or if I need further setup to have these rules available for reference in my project? Any ideas for where I could look next would be appreciated!
Screenshot 2023-04-12 at 15.30.26.png
p
Unfortunately the Ktlint documentation is a bit ahead of the code. Code style ktlint_official will be released in next release
0.49
. For now you should use
official
or
android
.
a
Hey Paul, thanks for the info! I have a few follow up questions. Firstly, if I were to set
ktlint_code_style
to
offical
or
android
this would still not work, the issue is actually that the property
ktlint_code_style
is not recognised at all, so I cannot set it. Do you know why this may be? Note, this is the same for all properties you can see highlighted yellow in my screenshot. Nothing is being picked up as "supported". Are these unsupported properties part of
0.49
release? If so, do you know where I can find a list of supported properties for now? To be clear, it seems the keys are a problem, not just the values (maybe both are though). Secondly, perhaps a hard one to answer, do you have any knowledge of when 0.49 will be released? Are we talking days/weeks/months? I'll set myself a reminder to check back on releases and would be good to know when to do that. Thanks
Screenshot 2023-04-13 at 11.09.16.png
p
Please check which version of ktlint is used by the spotless version that you’re using. Secondly, you can try to run Ktlint CLI to check whether your
.editorconfig
is correct. The syntax highlighter of IntelliJ does not recognize any of the ktlint properties. If Ktlint CLI works correct for your use case, you have to contact the maintainers of Spotless for more help.
a
Thanks Paul, appreciate all the pointers!
For anyone else that ends up here my ktlint version is passed into Spotless on line 10 on the left of the first screenshot I added. So my understanding is Spotless should us this version. I'll be playing this that line of code and the CLI oday to try and figure out the cause of the issue. In the meantime everything works well if I just have my normal rules in editorConfig and use the
editorConfigOverride
for ktlint specific rules in my spotless.gradle Not ideal to split rules applied over differing files, by not the end of the world
352 Views