https://kotlinlang.org logo
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
  • r

    ralf

    11/17/2020, 2:30 AM
    Hi 👋 We’re struggling with the Kotlin upgrade since version 0.36.0. KtLint is the only blocker that’s left for us to upgrade Kotlin to 1.4. We used to have an indent of 2 spaces with a continuation indent of 4 spaces. KtLint doesn’t support the continuation indent anymore, so we changed it to 2 spaces as well to make our life easier. Nonetheless, we still run into quite a few indent issues. I’ve tested the latest snapshot
    0.40.0
    and filed three tickets: https://github.com/pinterest/ktlint/issues/963 https://github.com/pinterest/ktlint/issues/964 https://github.com/pinterest/ktlint/issues/965 There are quite a few open indentation issues and they might be duplicates. I also saw some fixes in
    0.40.0
    . Is there a timeline when to expect a new release? Thanks!
    💯 2
    j
    s
    r
    • 4
    • 9
  • c

    Colton Idle

    12/06/2020, 9:57 AM
    I know I've still had a good amount of issues using editorconfig and ktlint. The editorconfig rules just don't seem to match up or work. According to this

    https://youtu.be/KffXqIZ0tYg?t=531▾

    editorconfig is fixed? "The last kotlin specific feature is that Intellij idea now has full support for kotlin in editforconfig files" 👀
    r
    s
    • 3
    • 11
  • r

    Rob Elliot

    12/15/2020, 8:35 PM
    ktlint doesn’t object to private or internal classes (or functions, or properties…) that aren’t used anywhere; is anyone aware of a linter that can be configured to fail the check for unused code?
    s
    t
    • 3
    • 3
  • d

    Dmitry

    12/17/2020, 2:07 PM
    I have run into a weird situation. I have a file that i 100% know is violating
    filename
    rule. But ktlint is not reporting this to me. However my colleague just ran into this violation. I am on macOS, he is on Linux (not sure if this matters). Version: 0.40.0 Any ideas what I could try to debug/fix this issue?
    e
    r
    • 3
    • 7
  • n

    nhaarman

    12/17/2020, 7:53 PM
    The README suggests installing ktlint in
    /usr/local/bin
    , meaning that all your projects need to be on the same ktlint version. Now you probably don't want to include the
    ktlint
    binary in every repo, but what about a Gradle-wrapper like script that downloads the ktlint binary? Would that be something the repository might want to provide?
    r
    t
    • 3
    • 5
  • n

    neugartf

    12/21/2020, 4:11 PM
    Hey! Anyone running in the same issue when trying to run
    :ktlint
    with SNAPSHOT-0.41.0? (gradle-6.7.1)
    Execution failed for task ':ktlint'.
    > Could not resolve all files for configuration ':ktlint'.
       > Could not resolve com.pinterest:ktlint:0.41.0-SNAPSHOT.
         Required by:
             project :
          > Cannot choose between the following variants of com.pinterest:ktlint:0.41.0-SNAPSHOT:20201220.202723-13:
              - runtimeElements
              - shadowRuntimeElements
            All of them match the consumer attributes:
              - Variant 'runtimeElements' capability com.pinterest:ktlint:0.41.0-SNAPSHOT:
                  - Unmatched attributes:
                      - Provides org.gradle.category 'library' but the consumer didn't ask for it
                      - Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
                      - Provides org.gradle.jvm.version '8' but the consumer didn't ask for it
                      - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                      - Provides org.gradle.status 'integration' but the consumer didn't ask for it
                      - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
                      - Provides org.jetbrains.kotlin.localToProject 'public' but the consumer didn't ask for it
                      - Provides org.jetbrains.kotlin.platform.type 'jvm' but the consumer didn't ask for it
              - Variant 'shadowRuntimeElements' capability com.pinterest:ktlint:0.41.0-SNAPSHOT:
                  - Unmatched attributes:
                      - Provides org.gradle.category 'library' but the consumer didn't ask for it
                      - Provides org.gradle.dependency.bundling 'shadowed' but the consumer didn't ask for it
                      - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                      - Provides org.gradle.status 'integration' but the consumer didn't ask for it
                      - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
    j
    t
    • 3
    • 10
  • a

    Alex Johnson

    12/23/2020, 4:00 PM
    Hi, is there an idiomatic way to wrap/format an extension function with a long name and no arguments? For example:
    fun Validated<Nel<Violation>, Field<List<MyReallyLongObjectTypeName>>>.validate(): Validated<Nel<Violation>, Field<List<MyOtherReallyLongObjectTypeName>>> {
    Most places cause a violation with ktlint, I'm wondering if a suppression for it is the best option for readability.
    j
    t
    • 3
    • 4
  • c

    chao

    12/24/2020, 5:09 PM
    Hello folks, I am wondering if the maintainers could shed some light on https://github.com/detekt/detekt/pull/3317#issuecomment-750928816 for the strategy to impose ordering on specific rules. The ordering complicates ordering and reporting in my understanding.
    s
    • 2
    • 2
  • e

    emrisb

    01/26/2021, 11:47 AM
    Hi, I implemented ktlint in old multi module project with baseline, but it generates a baseline file for each module. Is there any way to generate only one baseline file for all modules?
    t
    j
    • 3
    • 2
  • s

    Saidu E. Kamara

    01/28/2021, 11:37 AM
    Hi, I am implementing ktlint in our kmm app and works to some degree. But seeing some weird behaviour. Strangely, this is allowed
    data class DeviceMeasurementStatus(
        val sensorType: DeviceSensorType,
        val measurementMessage:
            String,
        val measurementState: MeasurementState
    )
    but not this:
    data class DeviceMeasurementStatus(
        val sensorType: DeviceSensorType,
        val measurementMessage:
        String,
        val measurementState: MeasurementState
    )
    Shouldn’t both these formatting be flagged as an error?
    s
    t
    • 3
    • 2
  • n

    neugartf

    02/02/2021, 11:45 PM
    Hey! I’m curious what the fastest way would be to run ktlint (as pre-push/commit script) in order to keep the “dev flow” interruption as short as possible. Am I right assuming that running it as a standalone tool would be the fastest approach? I feel like running this as a gradle task takes too much time due to gradle’s `configuration`tasks etc.
    s
    t
    • 3
    • 6
  • t

    tapchicoma

    02/10/2021, 9:55 PM
    New ktlint-gradle
    10.0.0
    release (slightly delayed due to non-working Github action): https://github.com/JLLeitschuh/ktlint-gradle/blob/master/CHANGELOG.md#1000---20210209 Under-the-hood contains a lot of changes that opens a door to future improvements, but update should be easy. You should see runtime improvements in multimodule project from a clean state on running
    ktlintCheck
    (
    ktlintFormat
    ) tasks, but slightly higher runtime in single module project (this should be addressed in the next release).
    🎉 6
    j
    c
    • 3
    • 4
  • g

    gmarques

    02/11/2021, 3:54 PM
    Hi 👋 , I’m having some issues with the ktlint and gradle remote build cache. The build cache key for the
    ktlintCheck
    task is always different between our CI (Linux) and my machine (MacOS) for the exact same code. What could be causing this?
    j
    t
    • 3
    • 31
  • o

    orafaaraujo

    02/12/2021, 11:17 AM
    Hello, 👋 Does anyone knows if is possible to run the auto-correct (
    ./gradlew ktlintFormat
    ) only in a selected file or package? Thank you 🙂
    n
    t
    • 3
    • 4
  • f

    FareesHussain

    02/16/2021, 6:10 AM
    Hello :android-wave:, I'm looking to contribute to ktlint, Can anyone let me know how to get started and setup project and please let me know any first issues to get onboarded.
    s
    • 2
    • 5
  • p

    Pedro Alberto

    02/28/2021, 3:38 PM
    I’m trying to install ktlint but I guess openjdk is having some problem
    brew install ktlint
    ==> Downloading <https://homebrew.bintray.com/bottles/openjdk-15.0.1.arm64_big_sur.bottle.1.tar.gz>
    #=#=#
    curl: (35) error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number
    Error: Failed to download resource "openjdk"
    Download failed: <https://homebrew.bintray.com/bottles/openjdk-15.0.1.arm64_big_sur.bottle.1.tar.gz>
    t
    • 2
    • 1
  • m

    Mervyn McCreight

    03/17/2021, 2:37 PM
    Hi folks 🙂 I have a question about how to define the import layout since 0.41.0. Previously I had
    kotlin_imports_layout = idea
    in my
    .editorconfig
    , which is deprecated now. If I change that to
    ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
    like suggested in the deprecation message, the linting with KTLint fails because of wrong import ordering. If I let ktlint format my source files it formats the imports alphabetically. I'm using one of the gradle plugins (https://github.com/jlleitschuh/ktlint-gradle) mentioned in the README to integrate ktlint into my project. Does anyone have any ideas? 🤔
    t
    r
    • 3
    • 9
  • h

    Henning B

    04/01/2021, 3:08 PM
    Hi! Just testing ktlint for the first time. I am getting some weird encoding errors when I open the report with VSCode. A lot of
    [90m
    and similar characters:
    [90m/Users/henning.bunk/repos/work/wetter-app/[0mbuild.gradle.kts[90m:[0m38[90m:9:[0m Missing space after //
    Any idea how to get rid of them? I am on Mac and execute ktlint via gradle
    s
    r
    t
    • 4
    • 10
  • k

    kenkyee

    04/01/2021, 5:04 PM
    updated to the latest version of ktlint and it seems to be formatting class definitions differently now. e.g. class something : some1( param1, param2 ), some2 { now has to be: class something : some1( param1, param2 ), some2 { which one is really correct?
    r
    • 2
    • 1
  • c

    chao

    04/03/2021, 4:59 PM
    > Dependency verification failed for configuration ':buildSrc:compileClasspath'
      2 artifacts failed verification:
        - dokka-gradle-plugin-0.10.1.jar (org.jetbrains.dokka:dokka-gradle-plugin:0.10.1) from repository MavenRepo
        - dokka-gradle-plugin-0.10.1.pom (org.jetbrains.dokka:dokka-gradle-plugin:0.10.1) from repository MavenRepo
      If the artifacts are trustworthy, you will need to update the gradle/verification-metadata.xml file by following the instructions at <https://docs.gradle.org/6.8.3/userguide/dependency_verification.html#sec:troubleshooting-verification>
    This verification error is failing all PR checks now. Is this something we should be aware of? (I assume dokka jar was changed after created)
    j
    s
    • 3
    • 4
  • o

    orafaaraujo

    04/23/2021, 7:34 AM
    Hello 👋 I’m getting a message of no java heap space
    * What went wrong:
    Execution failed for task ':app:runKtlintCheckOverMainSourceSet'.
    > A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
       > Java heap space
    I found this issue with a possible solution but I still can’t make it work… where should I add it? Thanks in advance
    r
    t
    • 3
    • 9
  • j

    jmarkstar

    05/19/2021, 12:38 AM
    Hi guys, do you know if there is any rule to check if the new classes and methods have comments?.
    s
    • 2
    • 1
  • a

    Alex

    05/19/2021, 8:35 AM
    Hey guys, we recently updated from ktlint
    0.39.0
    to
    0.41.0
    and it seems like the rules for string indentation have changed (code in thread). Can we get the old behavior back somehow and does someone know the reasoning behind this change?
    ➕ 6
    s
    c
    r
    • 4
    • 6
  • h

    Henning B

    05/19/2021, 10:17 AM
    I am relativly new to ktlint, currently ktlint blocks an upgrade to kotlin 1.5 because of value classes. is there a prospect when this kind of bugs usually gets fixed? Not wanting to make pressure, just for planning my next steps.
    s
    r
    • 3
    • 13
  • e

    eygraber

    06/11/2021, 8:10 AM
    I'm writing a detekt rule, and I'm trying to get autocorrect working with it, but
    indentSize
    always ends up being 2. Is there an easy way to get the correct
    indentSize
    or does it have to be calculated each time based on the
    PsiElement/ASTNode
    and where it's positioned in the file?
    r
    • 2
    • 5
  • b

    Ben Dodson

    06/13/2021, 8:57 PM
    Hello, we’re attempting to upgrade to ktlint 0.41, and are seeing extremely slow performance compared to 0.39 or 0.40-- earlier versions would run through a file in a second or so, but 0.41 is taking closer to a minute. Any ideas what might be going wrong? This is running directly over 1 small file
    s
    • 2
    • 11
  • a

    Alex

    06/15/2021, 3:02 PM
    Is there a way to deactivate the max-line-length check for a specific line (via annotation perhaps)?
    s
    • 2
    • 4
  • s

    Sha Sha Chu

    07/29/2021, 4:10 PM
    ktlint 0.42.0 released https://github.com/pinterest/ktlint/releases/tag/0.42.0
    🎉 5
    • 1
    • 1
  • b

    Bacho Kurtanidze

    08/16/2021, 2:21 PM
    Hey Guys, I'm working on a intelij's plugin project which uses KotlinPoet and generates files. Problem is that generated files are unformatted and really ugly to look at. Can I use ktlint to apply formatting to newly generated files?
    e
    r
    • 3
    • 3
  • m

    MisileLab

    08/21/2021, 3:31 PM
    I use unoffical intellij plugin. how can i fix this warn (or error)? Unexpected newline before "else" (keyword-spacing) my code
    Code
            else if (position2 == 7 && keys.pressing(<http://Key.SPACE|Key.SPACE>)) {
                a = true
            }
    Another Code
    r
    • 2
    • 1
Powered by Linen
Title
m

MisileLab

08/21/2021, 3:31 PM
I use unoffical intellij plugin. how can i fix this warn (or error)? Unexpected newline before "else" (keyword-spacing) my code
Code
        else if (position2 == 7 && keys.pressing(<http://Key.SPACE|Key.SPACE>)) {
            a = true
        }
Another Code
r

romtsn

08/21/2021, 7:49 PM
as the error says, your
else
keyword has a newline in front, which is not what the rule expects
View count: 12