Install ktlint plugin
This commit is contained in:
parent
3719382569
commit
03bdcee3ad
|
@ -9,25 +9,6 @@ insert_final_newline=true
|
||||||
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
|
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
|
||||||
max_line_length=off
|
max_line_length=off
|
||||||
|
|
||||||
# Comma-separated list of rules to disable (Since 0.34.0)
|
# From https://github.com/pinterest/ktlint#custom-ktlint-specific-editorconfig-properties
|
||||||
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
|
# default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
|
||||||
# by the ruleset identifier.
|
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^
|
||||||
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
|
|
||||||
|
|
|
@ -21,8 +21,12 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Run klint
|
- name: Run klint
|
||||||
run: |
|
run: |
|
||||||
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.36.0/ktlint && chmod a+x ktlint
|
./gradlew ktlintCheck --continue
|
||||||
./ktlint --android --experimental -v
|
- 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
|
# Lint for main module and all the other modules
|
||||||
android-lint:
|
android-lint:
|
||||||
|
|
|
@ -16,4 +16,4 @@
|
||||||
/fastlane/private
|
/fastlane/private
|
||||||
/fastlane/report.xml
|
/fastlane/report.xml
|
||||||
|
|
||||||
ktlint
|
/library/build
|
||||||
|
|
|
@ -80,14 +80,13 @@ Make sure the following commands execute without any error:
|
||||||
#### ktlint
|
#### ktlint
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.2/ktlint && chmod a+x ktlint
|
./gradlew ktlintCheck --continue
|
||||||
./ktlint --android --experimental -v
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Note that you can run
|
Note that you can run
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
./ktlint --android --experimental -v -F
|
./gradlew ktlintFormat
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)
|
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)
|
||||||
|
|
27
build.gradle
27
build.gradle
|
@ -27,7 +27,14 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ktlint Plugin
|
||||||
|
plugins {
|
||||||
|
id "org.jlleitschuh.gradle.ktlint" version "10.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
|
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
|
||||||
maven {
|
maven {
|
||||||
|
@ -75,6 +82,26 @@ allprojects {
|
||||||
// You can override by passing `-PallWarningsAsErrors=false` in the command line
|
// You can override by passing `-PallWarningsAsErrors=false` in the command line
|
||||||
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
|
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) {
|
task clean(type: Delete) {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Use ktlint plugin. See [the documentation](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#ktlint) for more detail.
|
Loading…
Reference in New Issue