ktlint is the most used linter for kotlin code. It is currently maintained by pinterest. it has integration with both maven and gradle.
Questions tagged [ktlint]
37 questions
14
votes
3 answers
Ktlint doesn't allow wildcard import? (Using IntelliJ auto import feature)
I am running a Kotlin project with ktlint maven plugin (first time user). but whenever I do a maven build. I often see the failure along the lines of
src/main/kotlin/com/myproject/model/User.kt:7:1: Wildcard import (cannot be auto-corrected)
Since…

夢のの夢
- 5,054
- 7
- 33
- 63
9
votes
1 answer
How do you tell ktlint in android to exclude specific paths in the project?
Currently when I want to format my code, I run this in the terminal in my android studio directory
https://github.com/pinterest/ktlint
./gradlew ktlintFormat
This command works great, but recently I added some folders into my project and the code…

Belphegor
- 1,683
- 4
- 23
- 44
7
votes
1 answer
Difference Ktlint vs. lint?
According to this article, ktlint is an automatic linter with a built-in code style checker.
When I decide to use ktlint, what is the difference between lint and ktlint?
lint is optimized for Android
ktlint is optimized for Kotlin?
How is ktlint…

Pavel Pipovic
- 339
- 1
- 3
- 12
5
votes
2 answers
Ktlint fails with Wildcard import (cannot be auto-corrected)
When I run gradlew ktlintCheck it fails with a lot of
Wildcard import (cannot be auto-corrected)
errors.

Ralf Wickum
- 2,850
- 9
- 55
- 103
4
votes
0 answers
Task 'ktlintCheck' not found in project
I have a sample project.
The build.gradle (project) is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id…

LiTTle
- 1,811
- 1
- 20
- 37
4
votes
1 answer
An API incompatibility was encountered while executing com.github.gantsign.maven:ktlint-maven-plugin:1.13.1:format
I added a ktlint plugin to my project, but getting this error when running mvn clean install
com.github.gantsign.maven
ktlint-maven-plugin
…

Diana
- 935
- 10
- 31
4
votes
2 answers
Gradle Ktlint plugin fails on Java 16
After upgrading to Java 16 I am not able to make ktlint gradle plugin to work. It's throwing
Execution failed for task ':runKtlintCheckOverMainSourceSet'.
A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
…

Lukas
- 13,606
- 9
- 31
- 40
4
votes
0 answers
KtLint check doesn't work locally anymore - it works tho in my docker image build
For no reason I am able to understand my gradle ktlintCheck command does not yield any issues anymore and :ktlintFormat is not fixing anything. As soon as I push my changes and my CI pipelines starts to build my Docker Image build process ktlint…

xetra11
- 7,671
- 14
- 84
- 159
4
votes
1 answer
Kotlin Gradle Spotless ktlint configuration
I currently use the following way to apply ktlint to my projects:
plugins{
id("com.diffplug.spotless") version "6.7.2"
}
allprojects {
apply(plugin = "com.diffplug.gradle.spotless")
spotless {
kotlin {
…

MozenRath
- 9,652
- 13
- 61
- 104
3
votes
0 answers
What does .userData([android:"true"]) convey in ktlint('0.43.2').userData([android: "true"])
ktlint('0.43.2').userData([android: "true"])
is a statement in spotless.gralde on using spotless with ktlint. I would like to know what is being conveyed when we give android:"true" in userData.
kotlin {
target '**/*.kt'
…

Fathimath Aashina
- 33
- 4
3
votes
2 answers
How to install Ktlint in windows
What I am trying to do: I am trying to install ktlint on windows locally
What I tried:
Used below command in command prompt
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.38.1/ktlint && chmod a+x ktlint
Also tried above command…

Devrath
- 42,072
- 54
- 195
- 297
3
votes
1 answer
How do I add KtLint style to Android Studio using Gradle?
I want to add the style ktlint uses to Android Studio so that when I apply formatting myself it uses the ktlint style.
Based on the documentation, I installed the ktlint CLI
brew install ktlint
I then navigated to the root of my project and…

Ersen Osman
- 7,067
- 8
- 47
- 80
2
votes
1 answer
possible lint error: Error: When targeting Android 13 or higher, posting a permission requires holding the POST_NOTIFICATIONS permission
I've set up github actions on my project, which include ktlint, however I've been getting strange errors (that do not happen locally) e.g.:
Error: When targeting Android 13 or higher, posting a permission requires holding the POST_NOTIFICATIONS…

JustSightseeing
- 1,460
- 3
- 17
- 37
2
votes
0 answers
How can I access local.properties in Github Action yml file for ci?
I get data from local.properties in build.gradle like this.
android {
signingConfigs {
debug {
Properties properties = new Properties()
…

c-an
- 3,543
- 5
- 35
- 82
2
votes
1 answer
How to disable ktlint rule for Missing newline after ":" and Missing newline after ","
Having trouble where to find a specific solution to disable Missing newline after ":" and Missing newline after "," of ktlint rules, when running ktlintCheck in my kotlin codes in Android
This is my code that encounters error:
class MainActivity :…

I Am Arien
- 79
- 2
- 7