Carmi Grushko
03/28/2021, 7:01 PMktfmt
, a predictable Kotlin code formatter, inside the browser.
ktfmt is distinctive in that it always produces the same output, regardless of how the code looks initially. It is based on google-java-format, if you're familiar with it from Java.
(The website is powered by an AWS Lambda which is notorious for slow cold-startup times for JVM programs, so it might take a few seconds the first time to get a response.
When running locally, it is fast enough to run as a save hook.)Big Chungus
03/28/2021, 7:49 PMDmitry Kandalov
03/28/2021, 8:38 PMEmil Kantis
03/28/2021, 9:54 PMgammax
03/28/2021, 10:00 PMkqr
03/29/2021, 7:42 AMCarmi Grushko
03/29/2021, 7:43 AMkqr
03/29/2021, 7:47 AMBig Chungus
03/29/2021, 7:48 AMCarmi Grushko
03/29/2021, 7:58 AMBig Chungus
03/29/2021, 7:59 AMCarmi Grushko
03/29/2021, 8:00 AMAlan B
03/29/2021, 12:59 PM.editorconfig
solves this problem. I am in the 2 space camp and will always be. I also don’t use ;
in my javascript, nor does my team. 😄 If we want kotlin to look like Java, the write Java. Or, start using semicolons on everything. Don’t use type inference, don’t use external functions or extension functions, or Kotlin features. If you want the Java look and feel, use Java. The worst was the Sun Java coding conventions. Go look at that original source from 1.1. That’s a hot mess.fillMode
assignment here is broken up into yet another line because it’s at column 20 where it could have been at 10. That makes things harder to read. Not to mention that code should be extracted. Too many if statements in a loop. Too hard to test. That’s off topic. But anyway. all just my opinion.Dmitry Kandalov
03/29/2021, 1:31 PMBig Chungus
03/29/2021, 1:32 PMCLOVIS
03/29/2021, 2:02 PMtddmonkey
03/29/2021, 3:11 PMnkiesel
03/29/2021, 4:12 PMif/else
and the formatter did not reverse that. So clearly such braces are not covered in "how the code looks initially". Is it really exclusively adjusting whitespace?Carmi Grushko
03/29/2021, 4:24 PMnkiesel
03/29/2021, 4:33 PMCarmi Grushko
03/29/2021, 4:50 PMnkiesel
03/29/2021, 6:52 PMCarmi Grushko
03/29/2021, 7:00 PMBig Chungus
03/29/2021, 7:04 PMnkiesel
03/29/2021, 7:08 PM--dropbox-style
. And I do not see facebook-style
in the source code...Javier
03/29/2021, 7:15 PMnkiesel
03/29/2021, 7:16 PMCarmi Grushko
03/29/2021, 7:42 PMWhich brings up the question: ...There are additional changes related to whitespace arrangement, such as where closing parenthesis / braces are placed. Easiest is to play around with the https://facebookincubator.github.io/ktfmt/ and see what you like best. Alternatively, compare https://github.com/facebookincubator/ktfmt/blob/master/core/src/test/java/com/facebook/ktfmt/GoogleStyleFormatterKtTest.kt to https://github.com/facebookincubator/ktfmt/blob/master/core/src/test/java/com/facebook/ktfmt/FormatterKtTest.kt
Jilles van Gurp
03/30/2021, 12:24 PMNikky
03/30/2021, 3:49 PMCarmi Grushko
03/30/2021, 3:51 PMNikky
03/30/2021, 3:52 PMCarmi Grushko
03/30/2021, 3:53 PMJavier
03/30/2021, 4:09 PMMichal Harakal
03/31/2021, 7:29 PMimport kotlin.Throws
in actual JVM implementation file.