{"id":20548101,"url":"https://github.com/lusingander/ktlint-format-example","last_synced_at":"2025-08-04T21:44:27.317Z","repository":{"id":105969069,"uuid":"303110697","full_name":"lusingander/ktlint-format-example","owner":"lusingander","description":"Sample application that calls the ktlint formatter from the Kotlin source code","archived":false,"fork":false,"pushed_at":"2020-10-24T02:36:10.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-16T16:24:00.567Z","etag":null,"topics":["kotlin","ktlint"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lusingander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-11T11:59:12.000Z","updated_at":"2020-10-24T02:36:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"30361451-fef7-446f-8b7e-a9e193224174","html_url":"https://github.com/lusingander/ktlint-format-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fktlint-format-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fktlint-format-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fktlint-format-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fktlint-format-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lusingander","download_url":"https://codeload.github.com/lusingander/ktlint-format-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242151773,"owners_count":20080167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","ktlint"],"created_at":"2024-11-16T02:12:11.184Z","updated_at":"2025-03-06T05:22:28.492Z","avatar_url":"https://github.com/lusingander.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ktlint-format-example\n\nSample application that calls the [ktlint](https://github.com/pinterest/ktlint) formatter from the Kotlin source code\n\n```kotlin\nfun main() {\n    val code = \"\"\"\n        class Foo(\n        val id : String, val age : Int,\n        val name:String )\n        {\n            fun foo() : Boolean { return name.isEmpty()\n        }\n        }\n    \"\"\".trimIndent()\n\n    val ruleSets = setOf(\n        StandardRuleSetProvider().get()\n    )\n    val formatted = KtLint.format(\n        KtLint.Params(\n            fileName = null,\n            text = code,\n            ruleSets = ruleSets,\n            userData = emptyMap(),\n            cb = { _, _ -\u003e run {} },\n            script = false,\n            editorConfigPath = null,\n            debug = false\n        )\n    )\n\n    println(formatted)\n}\n\n// Output:\n//\n// class Foo(\n//     val id: String,\n//     val age: Int,\n//     val name: String\n// ) {\n//     fun foo(): Boolean {\n//         return name.isEmpty()\n//     }\n// }\n```\n\n## Standard rules\n\n|Rule|Format|Test|\n|:-|:-:|:-:|\n|Indentation formatting|o||\n|No semicolons|o||\n|No unused imports|o||\n|No consecutive blank lines|o||\n|No blank lines before }|o||\n|No trailing whitespaces|o||\n|No Unit returns|o||\n|No empty ({}) class bodies|o||\n|No wildcard imports|x||\n|When wrapping chained calls ., ?. and ?: should be placed on the next line|o||\n|When a line is broken at an assignment (=) operator the break comes after the symbol|o||\n|When class/function signature doesn't fit on a single line, each parameter must be on a separate line|o||\n|Consistent string templates|o||\n|Consistent order of modifiers|o||\n|Consistent spacing after keywords, commas; around colons, curly braces, parens, infix operators, comments, range operators, etc|o||\n|Newline at the end of each file|o||\n|Imports ordered consistently|o||\n\n## Experimental rules\n\n|Rule|Format|Test|\n|:-|:-:|:-:|\n|Annotation formatting|o||\n|Annotations should be separated by the annotated declaration by a single line break|o||\n|Argument list wrapping|o||\n|Enum entry names should be uppercase underscore-separated names|o||\n|Braces required for multiline if/else statements|o||\n|No leading empty lines in method blocks|o||\n|No underscores in package names|x||\n|No spaces around angle brackets|o||\n|No spaces around ::|o||\n|No spaces around unary operators|o||\n|Declarations with annotations should be separated by a blank line|o||\n|Declarations with comments should be separated by a blank line|o||","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flusingander%2Fktlint-format-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flusingander%2Fktlint-format-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flusingander%2Fktlint-format-example/lists"}