Install ktlint plugin

This commit is contained in:
Benoit Marty 2021-10-01 13:28:47 +02:00 committed by Benoit Marty
parent 3719382569
commit 03bdcee3ad
6 changed files with 40 additions and 28 deletions

View File

@ -9,25 +9,6 @@ insert_final_newline=true
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=off
# Comma-separated list of rules to disable (Since 0.34.0)
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
# by the ruleset identifier.
disabled_rules=no-multi-spaces,colon-spacing,chain-wrapping,import-ordering,experimental:annotation
# The following (so far identified) rules are kept:
# no-blank-line-before-rbrace
# final-newline
# no-consecutive-blank-lines
# comment-spacing
# filename
# comma-spacing
# paren-spacing
# op-spacing
# string-template
# no-unused-imports
# curly-spacing
# no-semi
# no-empty-class-body
# experimental:multiline-if-else
# experimental:no-empty-first-line-in-method-block
# no-wildcard-imports
# From https://github.com/pinterest/ktlint#custom-ktlint-specific-editorconfig-properties
# default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^

View File

@ -21,8 +21,12 @@ jobs:
- uses: actions/checkout@v2
- name: Run klint
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.36.0/ktlint && chmod a+x ktlint
./ktlint --android --experimental -v
./gradlew ktlintCheck --continue
- name: Upload reports
uses: actions/upload-artifact@v2
with:
name: ktlinting-report
path: vector/build/reports/ktlint/*.*
# Lint for main module and all the other modules
android-lint:

2
.gitignore vendored
View File

@ -16,4 +16,4 @@
/fastlane/private
/fastlane/report.xml
ktlint
/library/build

View File

@ -80,14 +80,13 @@ Make sure the following commands execute without any error:
#### ktlint
<pre>
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.2/ktlint && chmod a+x ktlint
./ktlint --android --experimental -v
./gradlew ktlintCheck --continue
</pre>
Note that you can run
<pre>
./ktlint --android --experimental -v -F
./gradlew ktlintFormat
</pre>
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)

View File

@ -27,7 +27,14 @@ buildscript {
}
}
// ktlint Plugin
plugins {
id "org.jlleitschuh.gradle.ktlint" version "10.1.0"
}
allprojects {
apply plugin: "org.jlleitschuh.gradle.ktlint"
repositories {
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
maven {
@ -75,6 +82,26 @@ allprojects {
// You can override by passing `-PallWarningsAsErrors=false` in the command line
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
}
// Fix "Java heap space" issue
tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask).configureEach {
it.workerMaxHeapSize.set("2G")
}
// See https://github.com/JLLeitschuh/ktlint-gradle#configuration
ktlint {
android = true
ignoreFailures = false
enableExperimentalRules = true
// display the corresponding rule
verbose = true
disabledRules = [
"spacing-between-declarations-with-comments",
"no-multi-spaces",
"experimental:spacing-between-declarations-with-annotations",
"experimental:annotation"
]
}
}
task clean(type: Delete) {

1
changelog.d/3957.misc Normal file
View File

@ -0,0 +1 @@
Use ktlint plugin. See [the documentation](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#ktlint) for more detail.