A program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions.
by facebookKotlin
Last 12 weeks · 21 commits
4 of 6 standards met
Kotlin allows arbitrarily escaping reserved words and symbols in statements using backticks, e.g. and are both supported and work. However, using the latter form causes 's unused imports removal feature to incorrectly remove the statement entirely: Interestingly, this happens only if there is no alias at the end of the statement. I made a repro in https://github.com/facebook/ktfmt/commit/9e5310417bd2bfa6f88c01ef0e8721e12289f1df . Here's the output of the test when it fails:
Repository: facebook/ktfmt. Description: A program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions. Stars: 1209, Forks: 98. Primary language: Kotlin. Languages: Kotlin (96.1%), CSS (1.2%), JavaScript (1.2%), HTML (1.1%), Shell (0.4%). License: Apache-2.0. Homepage: https://facebook.github.io/ktfmt/ Latest release: v0.61 (2mo ago). Open PRs: 3, open issues: 42. Last activity: 3h ago. Community health: 75%. Top contributors: cgrushko, strulovich, davidtorosyan, nreid260, hick209, dependabot[bot], cortinico, rock3r, salvatorebenedetto, JavierSegoviaCordoba and others.
Ktfmt erroneously removes some blank lines from KDoc (Markdown) comments. This behavior is inconsistent with: How ktfmt treats kotlin code (preserve up to one consecutive blank line) How other markdown formatters treat markdown (KDoc is essentially Markdown with javadoc-like tags) For example, I have a KDoc comment with some inline Markdown to denote a blockquote: This gets collapsed by ktfmt to It seems ktfmt collapses other bits of inline markdown too, harming readability. For example: json {"code": "block"} is collapsed to json {"code": "block"} Note that in addition to removing whitespace, the two separate bulleted lists were combined into one, _changing the HTML rendering of the documentation comment_.