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

    Joel Hess

    09/11/2021, 8:13 PM
    Good afternoon. Question on an indentation rule: I have some code that looks like this:
    val contactRequest = contactRequestPersistence.getContactRequest<SendMailContactAttemptCmd>(command.mailerEventId)
                ?: """
                    Error processing ${...}
                    ${...} does not exist
                    """.trimIndent()
                    .run {
                        logger.error { this }
                        throw IllegalStateException(this)
                    }
    And it’s complaining about the line “”".trimIndent() needing to be indented less indented:
    val contactRequest = contactRequestPersistence.getContactRequest<SendMailContactAttemptCmd>(command.mailerEventId)
                ?: """
                    Error processing ${...}
                    ${...} does not exist
                """.trimIndent()
                    .run {
                        logger.error { this }
                        throw IllegalStateException(this)
                    }
    This looks like new behavior in 0.42.1? I’d want those to be be aligned (like the first example). How could I configure ktlint accordingly?
    s
    1 reply · 2 participants
  • h

    Henning B

    09/16/2021, 12:11 PM
    How do I deactivate rules? I get a lot of false positives and therefore want to exlude some rules. I created a file named
    .editorconfig
    in the top level of my project with the contents
    # Don't autoformat this file, IntelliJ adds forbidden spaces
    root=true
    
    [*.{kt,kts}]
    disabled_rules=indent,max-line-length
    insert_final_newline=true
    But indent and max line length is still checked.
    t
    4 replies · 2 participants
  • j

    jean pokou

    10/04/2021, 2:16 PM
    Hello, how can I enforce a line after a class definition and no horizontal line between properties in class. Thanks
    r
    1 reply · 2 participants
  • f

    Filip Lastic

    10/12/2021, 7:06 AM
    Hello! I created custom Ktlint rule which works perfectly, but sometimes I want to suppress it. I tried
    // ktlint-disable my-custom-rule
    and also
    /* ktlint-disable my-custom-rule */
    ...this should not fail
    /* ktlint-enable my-custom-rule */
    But it does not work. Please, is there any way how to suppress my custom rule? Thank you!
    r
    s
    6 replies · 3 participants
  • h

    henrik

    10/14/2021, 7:05 AM
    Is it possible to have a rule that disallows all use of
    !!
    ?
    r
    g
    19 replies · 3 participants
  • o

    Olek Brzozowski

    10/15/2021, 10:05 AM
    Hello! Can we add
    hacktoberfest
    label to ktlint repository? 🙂
    👍 1
    s
    1 reply · 2 participants
  • v

    Vince

    10/19/2021, 11:39 PM
    Hi! I'm noticing different behavior around the
    import-ordering
    rule between ktlint and ktlint-gradle (gradle wrapper). Specifically around the ordering of java/javax/kotlin and aliases: ktlint 0.42.1
    Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end
    JLLeitschuh/ktlint-gradle wrapper 10.2.0 using ktlint 0.42.1
    Imports must be ordered in lexicographic order without any empty lines in-between (import-ordering)
    Any idea what could be causing this discrepancy? The gradle wrapper `ktlintCheck`/`ktlintFormat` tasks aren't respecting the latter part of the rule around java/javax/kotlin + alias imports going at the end. Seems to have been added into ktlint around 0.42 based on some closed issues in the repo.
    s
    r
    5 replies · 3 participants
  • s

    Steffen Haase

    10/20/2021, 11:01 AM
    Hi.
    ij_kotlin_imports_layout = *,^
    and
    ij_kotlin_imports_layout = *, ^
    the config with the space after the comma I’ve got the erorr message
    Imports must be ordered according to the pattern specified in .editorconfig
    for aliases at the end of the import section. Are spaces between the comma separated list not allowed? thx.
    ✔️ 1
    r
    2 replies · 2 participants
  • b

    bobby

    10/30/2021, 8:48 AM
    Hi everyone, when I integrate Ktlint to my project and testing it. I found that this coding convention from Kotlin (here) not detect by the Ktlint. What I had try is to add the
    companion object
    at the beginning of the class, which should be at the end of the class, and it pass. I don’t know if I miss understand about the Ktlint, from what I understand is that Ktlint out of the box check the Kotlin convention too. If it’s not, do you have any suggestion about any tools I can use to follow Kotlin convention like I mentioned before? Thanks I’m using the Ktlint gradle plugin here
    r
    5 replies · 2 participants
  • o

    Oscar Nylander

    11/19/2021, 10:16 AM
    Hi everyone! We're looking into adopting
    ktlint 0.43.0
    for the nice new rules, but this version has not been published yet on
    brew
    😞 Could I help out in getting it published on
    brew
    in any way? 🙂 Thanks in advance!
    r
    3 replies · 2 participants
  • b

    Bruno Pérez Motter

    11/19/2021, 1:20 PM
    Hi Everyone, does anyone know how to make android studio recognize ktlint errors and reformat according to ktlint? I’ve tried running
    ktlint --apply-to-idea-project
    but i’ve not seen any difference I want the behavihour I get from the unnoficial ktlint android studio plugin but without installing it. Is this posible? How do you integrate ktlint in your workflow? I feel that running
    ktlint
    manually and seeing the errors and warnings in the console is cumbersome. I would much prefer to see it in the android studio warnings as shown in the screenshot.
    r
    3 replies · 2 participants
  • m

    Minsoo Cheong

    12/06/2021, 10:26 AM
    Hi everyone, does anyone know the convention for declaring typealiases in this case? I declared a single typealias in a file named TypeAliasUtils.kt but ktlint demands that the file should be named identical to the typealias I declared. Does this mean that I have to create different files for every typealias I declare? that seems a bit inefficient Any sort of advice or reading material is welcome thanks!!
    m
    r
    2 replies · 3 participants
  • p

    Paul Dingemans

    12/19/2021, 5:33 PM
    I have updated all my outstanding PR's. Conflicts have been resolved and questions and remarks have been addressed. It would be wonderful, if they would get merged.
    j
    s
    5 replies · 3 participants
  • p

    Paul Dingemans

    12/20/2021, 8:12 PM
    I now have access rights to add existing labels to issues. I am not able to create new labels though. Can I be honoured with that right as well. Or is somebody willing to create labels at request. First one would be "java16+".
    s
    4 replies · 2 participants
  • m

    Milan Vadhel

    12/23/2021, 9:09 AM
    p
    6 replies · 2 participants
  • p

    Paul Dingemans

    12/23/2021, 8:20 PM
    @Sha Sha Chu Can you please add labels below? Tnx • parameter-list-wrapping rule • import-ordering rules
    s
    2 replies · 2 participants
  • p

    Paul Dingemans

    12/28/2021, 5:30 PM
    We have a kind of policy that the output that is generated by ktlint should be accepted without any further changes by the default IntelliJ code formatter. Although I do understand this policy, I do not always like it. Sometimes, the IntelliJ code formatter just formats code in a way which is clearly wrong or not consistent with what a user is expecting. Even though we would be able to produce nicer and consistent code, we avoid doing so as IntelliJ would reformat that code once more. This could end up in an endless cycle in which IntellIiJ and KtLint are reformatting the code over and over again. But is it really a valid assumption that both ktlint and IntelliJ code formatting are used within the same code base? Can't we expect that if project chooses KtLint to format its code, that IntelliJ code formatting no longer should be applied? @Sha Sha Chu @romtsn @tapchicoma
    b
    s
    9 replies · 3 participants
  • d

    Dmytro (Dima) Karataiev

    01/10/2022, 2:18 PM
    Hi everyone, do you know if there's a way to set indent for the custom getter and setter functions so that ktlint would stop complaining about the incorrect Android Studio indentation? That's how Android Studio formats the code:
    private var savedAdapterState: PerformanceSpinnerSelections? =
            savedStateHandle.get<PerformanceSpinnerSelections>(SAVED_ADAPTER_STATE)
            set(value) {
                field = value
                savedStateHandle.set(SAVED_ADAPTER_STATE, value)
            }
    That's how ktlint thinks it should be:
    private var savedAdapterState: PerformanceSpinnerSelections? =
            savedStateHandle.get<PerformanceSpinnerSelections>(SAVED_ADAPTER_STATE)
            set(value) {
                    field = value
                    savedStateHandle.set(SAVED_ADAPTER_STATE, value)
                }
    That's how I think it should be:
    private var savedAdapterState: PerformanceSpinnerSelections? =
            savedStateHandle.get<PerformanceSpinnerSelections>(SAVED_ADAPTER_STATE)
                set(value) {
                    field = value
                    savedStateHandle.set(SAVED_ADAPTER_STATE, value)
                }
    The problem happens when a property is too long and wraps to a second line.
    1 reply · 1 participant
  • p

    Paul Dingemans

    01/10/2022, 6:05 PM
    Please create an issue at https://github.com/pinterest/ktlint/issues
    👍 1
    d
    1 reply · 2 participants
  • n

    nuhkoca

    01/20/2022, 11:57 AM
    Hey team, what is your roadmap regarding open PRs?
    p
    r
    5 replies · 3 participants
  • p

    Paul Dingemans

    01/21/2022, 7:58 PM
    Can you please create an issue for it in the github project?
    e
    2 replies · 2 participants
  • j

    jlleitschuh

    01/25/2022, 9:52 PM
    Hi All, 👋 @tapchicoma and I have been the primary maintainers of the ktlint-gradle plugin. Actually, honestly, @tapchicoma has been doing most of the work on the plugin for the past few years. Unfortunately, over the past few years, my personal ability to maintain the plugin has gone from actively writing to simply reviewing external contributions. @tapchicoma also has limited time of-late. However, I'm finding that I have limited time for even that these days. I'm not completely stepping away from the ktlint-gradle project, but what I am seeking is others to step in and help maintain the plugin. I'm looking for individuals who are interested in potentially taking on a larger role in the plugin's maintenance. I'd greatly appreciate assistance reviewing pull-requests and eventually passing along the tasks of cutting a release to others. I'm a security software engineer, so I understand the risks of just handing off a project to a stranger (eg. the event-stream), so I'm looking for someone to develop a rapport with. Please feel free to reach out if you're interested in getting involved with the project. Or simply start reviewing PRs or providing support on issues. Any support at this point would be greatly appreciated.
    g
    r
    +2
    6 replies · 5 participants
  • p

    Piotr Krzemiński

    03/10/2022, 8:56 AM
    is there a way to check line endings with ktlint? specifically, I'd like to ensure within the checking process that all files end with LF. I'm aware of some behavior during formatting that .editorconfig is respected (https://github.com/pinterest/ktlint/issues/225), but I'd like to have it verified during checking
    s
    p
    6 replies · 3 participants
  • s

    Sha Sha Chu

    03/22/2022, 3:58 PM
    hi @mateusz.kwiecinski - would you be able to file some issues on the github? just so it's tracked. thanks for the feedback
    👍 1
    m
    p
    +1
    11 replies · 4 participants
  • t

    Tyler Turnbull

    03/31/2022, 12:20 PM
    Anyone else having issues running kt lint? Have been seeing this occur for about a day now
    > Could not resolve all files for configuration ':udisc:ktlint'.
       > Could not resolve org.ec4j.core:ec4j-core:0.3.0.
         Required by:
             project :udisc > com.pinterest:ktlint:0.42.1 > com.pinterest.ktlint:ktlint-core:0.42.1
          > Could not resolve org.ec4j.core:ec4j-core:0.3.0.
             > Could not get resource '<https://www.jitpack.io/org/ec4j/core/ec4j-core/0.3.0/ec4j-core-0.3.0.pom>'.
                > Could not GET '<https://www.jitpack.io/org/ec4j/core/ec4j-core/0.3.0/ec4j-core-0.3.0.pom>'.
                   > Read timed out
    t
    e
    5 replies · 3 participants
  • p

    Paul Dingemans

    04/03/2022, 11:48 AM
    I have created a PR which allows to write the unit tests of a KtLint rule in a more fluent style based on the AssertJ library we already use for that. This PR is likely to be exposed as part of the ktlint-test public API. Any early feedback is appreciated.
    s
    1 reply · 2 participants
  • m

    Masayuki Suda

    04/08/2022, 9:03 AM
    How to disable ktlint rule for Missing newline after ":" and Missing newline after "," Please help. I am also having the same problem.
    a
    2 replies · 2 participants
  • d

    dazza5000

    04/08/2022, 8:41 PM
    I did some searching, but does anyone have a quick link/suggestion on how to configure
    ktlint
    to use the formatting rules that are default to Android Studio and used by the Android Studio formatter?
    r
    2 replies · 2 participants
  • p

    Paul Woitaschek

    04/11/2022, 8:52 PM
    Have you thought about moving the gradle plugin to the main repo? https://github.com/JLLeitschuh/ktlint-gradle In the readme it’s explicitly stated that the recommended integration is that gradle plugin and as that one seems to struggle: https://github.com/JLLeitschuh/ktlint-gradle/issues/569 it might make sense to add that functionality directly to ktlint
    e
    j
    2 replies · 3 participants
  • d

    dazza5000

    04/19/2022, 6:22 PM
    I'm having a ktlint issue where ktlint is fighting with the AS formatter - the following is how AS formats and I think this looks correct (aesthetically)
    @Composable
    private fun Buttons() {
        Row {
            FooButton(onClick = { }) {
                Text("Primary")
            }
            BarOutlineButton(onClick = { }) {
                Text("PrimaryOutline")
            }
            FooTextButton(onClick = { }) {
                Text("PrimaryText")
            }
        }
        Row {
            FooButton(onClick = { }, enabled = false) {
                Text("Primary")
            }
            BarOutlineButton(onClick = { }, enabled = false) {
                Text("PrimaryOutline")
            }
            FooTextButton(onClick = { }, enabled = false) {
                Text("PrimaryText")
            }
        }
    }
    ktlint will fail with:
    > Task :app:ktlintDebugSourceSetCheck FAILED
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:3:1 Imports must be ordered in lexicographic order without any empty lines in-between
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:291:1 Unexpected indentation (12) (should be 8)
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:292:1 Unexpected indentation (8) (should be 4)
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:294:1 Unexpected indentation (12) (should be 8)
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:295:1 Unexpected indentation (8) (should be 4)
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:297:1 Unexpected indentation (12) (should be 8)
    /Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:298:1 Unexpected indentation (8) (should be 4)
    e
    p
    41 replies · 3 participants
Powered by Linen
Title
d

dazza5000

04/19/2022, 6:22 PM
I'm having a ktlint issue where ktlint is fighting with the AS formatter - the following is how AS formats and I think this looks correct (aesthetically)
@Composable
private fun Buttons() {
    Row {
        FooButton(onClick = { }) {
            Text("Primary")
        }
        BarOutlineButton(onClick = { }) {
            Text("PrimaryOutline")
        }
        FooTextButton(onClick = { }) {
            Text("PrimaryText")
        }
    }
    Row {
        FooButton(onClick = { }, enabled = false) {
            Text("Primary")
        }
        BarOutlineButton(onClick = { }, enabled = false) {
            Text("PrimaryOutline")
        }
        FooTextButton(onClick = { }, enabled = false) {
            Text("PrimaryText")
        }
    }
}
ktlint will fail with:
> Task :app:ktlintDebugSourceSetCheck FAILED
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:3:1 Imports must be ordered in lexicographic order without any empty lines in-between
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:291:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:292:1 Unexpected indentation (8) (should be 4)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:294:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:295:1 Unexpected indentation (8) (should be 4)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:297:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:298:1 Unexpected indentation (8) (should be 4)
and this is how ktlint formats it
@Composable
private fun Buttons() {
    Row {
        FooButton(onClick = { }) {
            Text("Primary")
        }
        BarOutlineButton(onClick = { }) {
            Text("PrimaryOutline")
        }
        FooTextButton(onClick = { }) {
            Text("PrimaryText")
        }
    }
    Row {
        FooButton(onClick = { }, enabled = false) {
        Text("Primary")
    }
        BarOutlineButton(onClick = { }, enabled = false) {
        Text("PrimaryOutline")
    }
        FooTextButton(onClick = { }, enabled = false) {
        Text("PrimaryText")
    }
    }
}
It looks like ktlint is formatting the functions inconsistently and in a way that doesn't really render as it should be read (in a compose kind of mindset)
now the checks will pass with ktlint formatting
darrankelinske@W2DWT39JN9 consumer-android-ui % ./gradlew ktlintDebugSourceSetCheck 
Configuration on demand is an incubating feature.

BUILD SUCCESSFUL in 550ms
16 actionable tasks: 3 executed, 13 up-to-date
@David Corrado fyi
e

ephemient

04/19/2022, 6:25 PM
looks like https://github.com/pinterest/ktlint/issues/1200?
d

dazza5000

04/19/2022, 6:32 PM
thank you - it looks like it is coming out in .46
p

Paul Dingemans

04/19/2022, 6:42 PM
Code snippet does not throw lint errors for me with latest ktlint (0.45.2). Can you please create an issue and specify details about ktlint version and editorconfig. Also please run ktlint with option “-v”.
d

dazza5000

04/19/2022, 6:45 PM
i dont have any .editorconfig defined
darrankelinske@W2DWT39JN9 consumer-android-ui % ./gradlew ktlint -v

------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------

Build time:   2021-08-17 09:59:03 UTC
Revision:     a773786b58bb28710e3dc96c4d1a7063628952ad

Kotlin:       1.5.21
Groovy:       3.0.8
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.12 (Homebrew 11.0.12+0)
OS:           Mac OS X 12.3.1 aarch64
I am using ktlint from
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlint
const val ktlint = "10.2.1"
p

Paul Dingemans

04/19/2022, 6:53 PM
That is using ktlint version 0.42.1 (https://github.com/JLLeitschuh/ktlint-gradle/blob/master/plugin/gradle/libs.versions.toml)
d

dazza5000

04/19/2022, 6:55 PM
hmm - it looks like the PR to update the version is still in progress and the maintainer is looking for help...
e

ephemient

04/19/2022, 6:56 PM
as discussed in a thread just earlier, https://kotlinlang.slack.com/archives/CKS3XG0LS/p1649710333891889
d

dazza5000

04/19/2022, 6:58 PM
yep - might try kotlinter - have you tried it @ephemient
e

ephemient

04/19/2022, 6:58 PM
I currently use kotlinter and detekt in various projects
d

dazza5000

04/19/2022, 7:27 PM
it looks like you can set a particular version on both of the plugins through different means
going to try that
ktlint {
    version.set("0.45.2")
    android.set(true)
    reporters {
        reporter(ReporterType.HTML)
    }
    outputColorName.set("RED")
    disabledRules.set(setOf("no-wildcard-imports"))
}
I am hitting another difference between intellij formatting and ktlint (even after I have run applyToIDEAProject) https://github.com/pinterest/ktlint/issues/1237#issuecomment-1103135680
if I install the ktlint intellij plugin everything works as expected - does anyone know why the ktlint intellij plugin solves all the problems?
p

Paul Dingemans

04/20/2022, 2:47 PM
Probably it is the difference in the ktlint version. It would be best if you first verify whether your problem also occur with latest ktlint version (0.45.2) when running from the command line.
d

dazza5000

04/20/2022, 2:49 PM
How do I tell which version is running from the command line? It looks like -v doesn't dump the ktlint version
just the system stats
p

Paul Dingemans

04/20/2022, 2:54 PM
`ktlint --help`will tell it all 😉
e

ephemient

04/20/2022, 2:54 PM
you are being recommended to run ktlint directly, not via a Gradle plugin or IDE plugin
p

Paul Dingemans

04/20/2022, 2:55 PM
But seriously,
ktlint --version
is the command you are looking for,
d

dazza5000

04/20/2022, 2:55 PM
I know and that is what I prefer, but my teammates like to use the Android studio UI to format
darrankelinske@W2DWT39JN9 consumer-android-ui-2 % ./gradlew ktlint --version

------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------

Build time:   2021-08-17 09:59:03 UTC
Revision:     a773786b58bb28710e3dc96c4d1a7063628952ad

Kotlin:       1.5.21
Groovy:       3.0.8
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.12 (Homebrew 11.0.12+0)
OS:           Mac OS X 12.3.1 aarch64
so I need to determine the version by the hash?
p

Paul Dingemans

04/20/2022, 2:56 PM
No, you should install ktlint as CLI tool and run it from the command line.
https://github.com/pinterest/ktlint#installation
d

dazza5000

04/20/2022, 2:57 PM
i have that installed too
I am primarily trying to find solutions to make it easier for my teammates to use "Reformat Code" in Android Studio UI in a way that jives with ktlint
i am a terminal / command line person, but not everyone is
darrankelinske@W2DWT39JN9 consumer-android-ui-2 % ktlint --version
0.45.2
p

Paul Dingemans

04/20/2022, 2:58 PM
I want you to use the CLI tool, to verify whether it is a Ktlint or a gradle pf a plugin problem,
I can only help with ktlint problem itself. I do not maintain the other repo’s / projects/
e

ephemient

04/20/2022, 2:59 PM
if ktlint works and gradle ktlint doesn't, it's narrowed down to a plugin issue
d

dazza5000

04/20/2022, 3:03 PM
got it - now I'm following
View count: 56