Slide 1

Slide 1 text

What I talk about when I talk about Ktlint kaelaela

Slide 2

Slide 2 text

Problems in a large team ● Spawn untold coding rule ● Reviewer spend fluitless time for similer mistake ● Yesterday’s nice doc could be today’s trash

Slide 3

Slide 3 text

Difficulty of Kotlin ● Many different ways of writing ● So we make many team rules ● These all rules can’t taught through word of mouth

Slide 4

Slide 4 text

We have many solutions ● Inspect by Android Studio ● Static code analytics ● Automate with Danger etc...

Slide 5

Slide 5 text

Static code analytics e.g. FindBugs Android Lint Ktlint ...

Slide 6

Slide 6 text

What is ktlint?

Slide 7

Slide 7 text

Customize with editorconfig

Slide 8

Slide 8 text

Basic usage Write code Push CI Analytics + Danger Fix format Push Review Fix Push

Slide 9

Slide 9 text

Not good enough Write code Push CI Analytics + Danger Fix format Push Review Fix Push we S I L ne fi d o r d .

Slide 10

Slide 10 text

Redundant commits... ● fix danger comment ● fix danger ● fix code format ● format code ● format ● :put_litter_in_its_place: ...

Slide 11

Slide 11 text

Write code Push CI Analytics + Danger Fix format Push Review Fix Push More and more automation

Slide 12

Slide 12 text

Write code build & format push CI Analytics + Danger Review Fix Push More and more automation

Slide 13

Slide 13 text

Write code build & format push CI Analytics + Danger Review Fix Push More and more automation No m ed n ev . No m or c it. No m or c e r a d!

Slide 14

Slide 14 text

Add ktformat task to build.gradle task ktFormat { description "R.I.P danger..." classpath = configrations.ktlint Main = "com.github.shyiko.ktlint.Main" args "-F", "src/**/*.kt" }

Slide 15

Slide 15 text

Add ktformat task to build.gradle task ktFormat { description "R.I.P danger..." classpath = configrations.ktlint Main = "com.github.shyiko.ktlint.Main" args "-F", "src/**/*.kt" } For p i

Slide 16

Slide 16 text

Add ktformat task to build.gradle task ktFormat { description "R.I.P danger..." classpath = configrations.ktlint Main = "com.github.shyiko.ktlint.Main" args "-F", "src/**/*.kt" } Yo c ha t et s

Slide 17

Slide 17 text

Only format @ local debug build time e.g. applicationVariants.all { variant -> def flavor = variant.productFlavors[0].name def buildType = variant.buildType.name if (flavor == 'develop' && buildType == 'debug') { ktFormat.execute() } }

Slide 18

Slide 18 text

$./gradlew --profile ktFormat Che p r a c on p o c !

Slide 19

Slide 19 text

What I talk about ● Use ktlint for your team ● Do not review about code fomat ● And I want to remove “Format commit” ● Use ktFormat for reviewer and you ● Format at local debug build time ● Focus your coding

Slide 20

Slide 20 text

Tha y . What I talk about when I talk about Ktlint