Add code style `ktlint_official`

* Add code style `ktlint_official` (functionally equivalent with old `official` code style), `intellij_idea` (replacement for old `official` code style) and `android_studio` (replacement for old `android` code style).

Closes #1699

* Format project itself to "official ktlint" codestyle.

* Add Gradle "ktlint format" task.

* Ensure that the subcommand generateEditorConfig, gitPreCommitHook and gitPrePushHook can receive the code-style before or after the subcommand and print error in case the code style option is not specified explicitly.

* Add option to KtLintRuleEngine to ignore the '.editorconfig' on the file system. Unit test classed have to obey to '.editorconfig' settings of the project. Code snippets inside those unit tests should not be influenced by the '.editorconfig' settings of the project but only by properties which have been explicitly defined in the unit test.

* Files used for CLI tests contain lint violations on purpose in order to validate the tests. The tests may not be affected by the ".editorconfig" files which are used to lint/format the code of the Ktlint project itself. Neither may the ".editorconfig" files of the project lead to changing the input files for the tests. Files used as input for the cli test use the ".test" extension so that those files can be separated from the actual project files.
 The tests that used the "filename" rule have been replaced with the "no-wildcard-imports" rule. Reason for this is that the "filename" rule contains a hardcoded check that excludes all files not ending with a ".kt" extension.

* Do not add the (first line of the) body expression on the same line as the function signature in case the max line length would be exceeded. `function-signature`.

* Do not add the first line of a multiline body expression on the same line as the function signature in case function body expression wrapping property is set to `multiline`. `function-signature`.
165 files changed
tree: 7f4946fceb2473748734489a774450e03a037abb
  1. .github/
  2. build-logic/
  3. docs/
  4. gradle/
  5. ktlint/
  6. ktlint-api-consumer/
  7. ktlint-core/
  8. ktlint-reporter-baseline/
  9. ktlint-reporter-checkstyle/
  10. ktlint-reporter-format/
  11. ktlint-reporter-html/
  12. ktlint-reporter-json/
  13. ktlint-reporter-plain/
  14. ktlint-reporter-plain-summary/
  15. ktlint-reporter-sarif/
  16. ktlint-ruleset-experimental/
  17. ktlint-ruleset-standard/
  18. ktlint-ruleset-template/
  19. ktlint-ruleset-test/
  20. ktlint-test/
  21. ktlint-test-logging/
  22. .announce
  23. .editorconfig
  24. .gitattributes
  25. .gitignore
  26. .homebrew
  27. ADOPTERS.md
  28. build.gradle.kts
  29. CHANGELOG.md
  30. CODE_OF_CONDUCT.md
  31. CONTRIBUTING.md
  32. gradle.properties
  33. gradlew
  34. gradlew.bat
  35. jitpack.yml
  36. LICENSE
  37. mkdocs.yml
  38. README.md
  39. RELEASE_TESTING.MD
  40. RELEASING.md
  41. run-mkdocs-server.sh
  42. settings.gradle.kts
README.md

Key features

  • No configuration required
  • Built-in Rule sets
  • Built-in formatter
  • .editorconfig support
  • Several built-in reporters: plain, json, html and checkstyle
  • Executable jar
  • Allows extension with custom rule sets and reporters

Documentation

User guide

Legal

This project is not affiliated with nor endorsed by JetBrains.
All code, unless specified otherwise, is licensed under the MIT license.
Copyright (c) 2019 Pinterest, Inc.
Copyright (c) 2016-2019 Stanley Shyiko.