What I Talk About When I Talk About Ktlint

What I Talk About When I Talk About Ktlint

A967476c5855d593710a9a580f6b2aed?s=128

Yuichi Maekawa

March 20, 2018
Tweet

Transcript

  1. What I talk about when I talk about Ktlint kaelaela

  2. 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
  3. Difficulty of Kotlin • Many different ways of writing •

    So we make many team rules • These all rules can’t taught through word of mouth
  4. We have many solutions • Inspect by Android Studio •

    Static code analytics • Automate with Danger etc...
  5. Static code analytics e.g. FindBugs Android Lint Ktlint ...

  6. What is ktlint?

  7. Customize with editorconfig

  8. Basic usage Write code Push CI Analytics + Danger Fix

    format Push Review Fix Push
  9. 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 .
  10. Redundant commits... • fix danger comment • fix danger •

    fix code format • format code • format • :put_litter_in_its_place: ...
  11. Write code Push CI Analytics + Danger Fix format Push

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

    Review Fix Push More and more automation
  13. 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!
  14. 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" }
  15. 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
  16. 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
  17. 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() } }
  18. $./gradlew --profile ktFormat Che p r a c on p

    o c !
  19. 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
  20. Tha y . What I talk about when I talk

    about Ktlint