https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
ktlint
  • j

    Jakub Gwóźdź

    08/08/2019, 9:07 AM
    morning. two questions: - does ktlint check for .* imports vs explicit classes list - does ktlint check for number of spaces before chained methods calls like
    val x = listOf(1, 2, 3)
                    .map { it + 1 }
                .sum()
    (on this example, the
    .map...
    can be set to 16 spaces, but when I add one more space, suddenly it's
    Unexpected indentation (17) (it should be 12) (cannot be auto-corrected)
    I'm running default config
    id("org.jlleitschuh.gradle.ktlint") version "8.2.0"
    plugin during ./gradlew build
    i
    • 2
    • 3
  • s

    sanogueralorenzo

    08/23/2019, 2:58 PM
    Hello people! What is the best way to share the codestyle across IDEs? We currently have to follow https://github.com/pinterest/ktlint#installation but I noticed that after updating it is cumbersome to make everyone update their AS formatting. Any links for making this possible? So people just have to pull from git and that is it 😄
    t
    • 2
    • 1
  • g

    GurpreetSK

    08/26/2019, 4:46 AM
    Hi! We have an existing project which uses kotlin and we’re looking to use ktlint for it. However, the existing files are not properly formatted and lint checks fail for them on running
    ktlint
    task. Is there any way to: 1. whitelist a few files so that checks aren’t run for them? 2. un-whitelist the file once some changes have been made to it? Thanks
    s
    t
    • 3
    • 9
  • s

    sanogueralorenzo

    09/03/2019, 3:20 PM
    Hello everyone! Are any of you having trouble with one of the latest rules introduced? The alphabetical imports one. It can only be fixed by doing
    ktlintFormat
    and that takes too much time compared to just formatting. I tried updating idea codestyle through ktlint again but it doesn't seem to be included.
    s
    i
    t
    • 4
    • 9
  • a

    adam-mcneilly

    09/12/2019, 7:55 PM
    Hi! I have a question about a discrepency I'm seeing between KtLint and the IDE when I reformat code. I have a file that has a few lines that are over 100 characters. If I use Android Studio to reformat the file, it will correct all of those - either chunking down parameters or putting assignments on a new line, whatever I need. It appears KtLint doesn't do the same. This came up because we ran KtLint against the entire project hoping to get a "clean slate" more or less with formatting, but now we're finding sometimes that when we use the IDE to reformat entire files are changing again. I was expecting that both formatting tools would give me the same output. I just want to confirm that KtLint doesn't do anything to wrap those long lines? If that's correct, does anyone have recommendations for how I can get more consistency between the two?
    s
    • 2
    • 4
  • s

    Suraj Bokey

    09/13/2019, 10:09 AM
    Does anyone tries to change the indentation to 2. Please help me here to do the same. I have already change the configuration in .editorconfig but still it’s not working
    t
    • 2
    • 10
  • a

    adam-mcneilly

    09/13/2019, 8:43 PM
    Hey idk if y'all are familiar with this static analysis plugin but I'm using it as a wrapper to run KtLint and detekt: https://github.com/novoda/gradle-static-analysis-plugin I noticed that when I use this Detekt outputs with a specific color for the error making it is easy to find in our logs but KtLint does not. Is there any flag or configuration I can set to do this? I mentioned that plugin because it might not be easy if I'm not calling KtLint directly.
    t
    • 2
    • 33
  • g

    GurpreetSK

    09/17/2019, 3:52 PM
    Hey! Is it possible to run ktlint only on a given set of files? Eg: Something like
    ./gradlew ktlint {list of files}
    ?
    a
    • 2
    • 4
  • m

    myanmarking

    10/03/2019, 2:33 PM
    i need to exclude that rule, but don't know the key
    t
    s
    • 3
    • 2
  • s

    Sha Sha Chu

    10/13/2019, 7:00 AM
    ktlint 0.35.0 released https://github.com/pinterest/ktlint/releases/tag/0.35.0
    🎉 4
    • 1
    • 1
  • b

    bbaldino

    10/23/2019, 6:34 PM
    is there a way to configure intellij to organize imports in lexographic order? i've started getting this warning with ktlint (
    Imports must be ordered in lexicographic order without any empty lines in-between
    ) but don't see how to fix it in intellij
    s
    • 2
    • 7
  • t

    tapchicoma

    11/01/2019, 8:22 PM
    new
    ktlint-gradle
    release: https://github.com/JLLeitschuh/ktlint-gradle/blob/master/CHANGELOG.md#910---2019-11-01 Most notable - support for incremental checks
    🎉 4
    s
    • 2
    • 1
  • v

    Vinicius Araujo

    11/04/2019, 2:11 PM
    Hi! My project files are all
    ISO-8859-1
    enconding. ktlintFormat task converts files with special characters (only) to UTF-8, resulting in
    �
    . Setting
    charset=latin1
    in root`s
    .editorconfig
    made no difference. Does anyone knows how to solve this?
    t
    • 2
    • 1
  • j

    Josh Feinberg

    11/21/2019, 10:38 PM
    i'm trying to enforce using named parameters in certain scenarios but you can't use those if the function is defined in java so it ends up producing a false positive sometimes. i currently just have a whitelist (for mostly android library code) but wasn't sure if there was a better way
    a
    • 2
    • 6
  • g

    GurpreetSK

    12/02/2019, 10:53 AM
    Hey all. I forked the project and made some changes related to continuation indent sizes. After uploading to jitpack and using the binary, I’m getting
    Could not find or load main class com.pinterest.ktlint.Main
    error. I updated ktlint dependency also. Do I have to update anything else too? Link to forked project: https://github.com/GurpreetSK95/ktlint/tree/gs/continuation-indent
    s
    • 2
    • 1
  • p

    petermonteer

    12/12/2019, 12:25 PM
    Hey guys having a problem with ktlint in my android project, I posted it on SO, any help is appreciated 👐 https://stackoverflow.com/questions/59304531/ktlint-error-in-android-build-with-multiple-flavors
    t
    • 2
    • 13
  • h

    Hexa

    12/29/2019, 11:52 AM
    Imports must be ordered in lexicographic order without any empty lines in-between
    how do I get Ktlint to automatically fix this error?
    t
    • 2
    • 1
  • b

    bbaldino

    01/06/2020, 5:23 PM
    Does a rule exist for warning on an unused return value?
    t
    • 2
    • 6
  • m

    mbonnin

    02/10/2020, 5:53 PM
    Is there a ktlint equivalent of the Android
    @IntRange
    ,
    @FloatRange
    and
    @Size
    annotation to validate input parameters ? (https://developer.android.com/studio/write/annotations#value-constraint)
    t
    s
    • 3
    • 4
  • r

    Reuben Jacobs

    02/24/2020, 8:24 PM
    Does anyone know how to use this properly in a docker-compose file to scan an existing project
    t
    • 2
    • 9
  • j

    Josh Feinberg

    02/27/2020, 3:23 AM
    would anyone be interested in baseline functionality in ktlint? happy to put up a PR but just gauging interest
    👍 1
    s
    a
    • 3
    • 13
  • c

    cristiangm

    03/02/2020, 2:57 PM
    Is there any intention to fix the issue with
    import-ordering
    ? it feels terrible to go to all the projects of the company adding the exclude to the
    .editorconfig
    when it's an issue with the rule itself that doesn't work as the IDE
    👍 2
    t
    • 2
    • 5
  • d

    Dariusz Kuc

    03/02/2020, 10:19 PM
    hello! I'm writing a custom Gradle plugin that generates source files and was wondering if there is a way I could automatically exclude them from ktlint check?, e.g. I'm using
    org.jlleitschuh.gradle.ktlint
    which automatically applies the linter against all source sets. Currently I'm manually configuring
    ktlint
    task to filter out
    generated
    sources but was wondering whether there is some better way?
    tasks {
        ktlint {
            filter {
                exclude("**/generated/**")
            }
        }
    }
    e.g. above approach is not ideal as anyone using the plugin will have to add that configuration as well
    t
    m
    • 3
    • 7
  • s

    Sha Sha Chu

    03/06/2020, 11:06 PM
    If I had to guess it's that it's just a bug and not desired behavior. Can you file an issue in GitHub with some examples and we can take a look?
    r
    • 2
    • 6
  • c

    Colton Idle

    03/19/2020, 3:28 AM
    Trying to use ktlint in my Android app. Just found out about it recently and I read through the github.io page. It says "ktlint is a single binary with both linter & formatter included", but what I'm finding hard to understand is how to add it to my android project? I see that in getting started it has command line or gradle. I'm assuming since I have a default android project, I can just use gradle, but I'm still confused on why there are 3 plugins shown, and then a no plugin option. I'm not really sure what I'm looking for here, but maybe because I'm new it's going over my head. In my head, all I want is to run a linter during CI that gives me a report of all the broken rules + I want the IDE to tell me when I broke one of these (like android lint) or at least auto reformat code to these rules (cmd + shift + L in IntelliJ)
    s
    b
    t
    • 4
    • 22
  • s

    Sinan Kozak

    03/30/2020, 7:21 PM
    Will ktlint indention support different continuation indent size? We have indent 2 continuation 4 and we had to disable indent check for ktlint.
    d
    s
    • 3
    • 10
  • m

    Mathieu Caron45

    04/08/2020, 8:54 AM
    Hi everyone, I’m experimenting an issue with the klint tool and maybe someone could help me. Some rules erase entire contents of some files of my project and I don’t undestand why. ex :
    no-blank-line-before-rbrace
    no-consecutive-blank-lines
    no-trailing-spaces
    no-multi-spaces
    comment-spacing
    ...
    I’ve configurated the tool with both gradle plugins (https://github.com/jeremymailen/kotlinter-gradle & https://github.com/JLLeitschuh/ktlint-gradle) and the result is the same. Environment : klint : 0.36.0 kotlin version : 1.3.61 gradle : 3.6.1 OS : MacOS 10.15.4 Android Studio : 3.6.1 Thank you in advance for your help.
    t
    • 2
    • 2
  • c

    Colton Idle

    04/09/2020, 7:37 PM
    Anyway to get editorconfig and ktlint to be the same? Or maybe that's a dumb question. Sorry. and pardon my ignorance here. I still don't understand the dis-jointement between ktlint style and my style intellij. I thought using ktlint would unify the style for me and my team, but all it's caused is headaches.
    c
    • 2
    • 2
  • s

    Sinan Kozak

    04/09/2020, 8:17 PM
    Is there a ktlint rule for minimum empty space after class header? If not would it be easy to write one?
    • 1
    • 2
  • v

    vanshg

    04/22/2020, 5:21 AM
    I submitted a bug report in the GitHub repo (https://github.com/pinterest/ktlint/issues/729), but in a more general context, is there any timeline for at the very least Kotlin 1.4 syntax support?
    v
    s
    • 3
    • 7
Powered by Linen
Title
v

vanshg

04/22/2020, 5:21 AM
I submitted a bug report in the GitHub repo (https://github.com/pinterest/ktlint/issues/729), but in a more general context, is there any timeline for at the very least Kotlin 1.4 syntax support?
v

Vova Buberenko

04/22/2020, 6:26 AM
Why do you consider it a bug if 1.4 is still in review? It would be bug in case of 1.4 reaching stable, but now - it is just good to have and redundant pressure on maintainers from your side.
v

vanshg

04/22/2020, 6:43 AM
I did so to bring attention to it and because I don't see any alphas or anything similar that lets me know it's being worked on. And it's better to get the support in for it now while in EAP before it's GA
Also why I didn't mention anything about timeframe in the GitHub issue itself and why I came here to inquire about it instead
v

Vova Buberenko

04/22/2020, 6:48 AM
It might be just an impression, but when someone writes 'any timeline to support at the very least 1.4. support' it feels like a pressure, especially knowing the fact that ktlint is an opensource project, not a commercial one 😉
v

vanshg

04/22/2020, 7:12 AM
Didn't mean for it to come off like that, just general curiosity so I can plan for my own project 🙂
👌 1
s

Sha Sha Chu

04/22/2020, 3:33 PM
generally there’s not too much of a lag after releasing new kotlin versions, but with major versions it could take a bit longer. i don’t have a specific timeline for you, though
v

vanshg

04/23/2020, 1:45 AM
Sure, sounds good, thank you @Sha Sha Chu
View count: 19