Moves to spotless

pull/741/head
Vitor Pamplona 2024-01-06 10:44:05 -05:00
rodzic ed6c1e62e4
commit de61f7f383
9 zmienionych plików z 60 dodań i 16 usunięć

14
.editorconfig 100644
Wyświetl plik

@ -0,0 +1,14 @@
root = true
[*]
charset = utf-8
trim_trailing_whitespace = true
[*.{kt,kts}]
max_line_length = 9000
ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true
ktlint_function_naming_ignore_when_annotated_with=Composable, Test
[*.gradle]
indent_size = 4

Wyświetl plik

@ -28,7 +28,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Linter (gradle)
run: ./gradlew ktlintCheck
run: ./gradlew spotlessCheck
- name: Test (gradle)
run: ./gradlew test --no-daemon

1
.gitignore vendored
Wyświetl plik

@ -8,6 +8,7 @@
/.idea/androidTestResultsUserPreferences.xml
/.idea/deploymentTargetDropDown.xml
/.idea/appInsightsSettings.xml
/.idea/ktlint-plugin.xml
.DS_Store
/build
/captures

Wyświetl plik

@ -150,8 +150,8 @@ Build the app:
## Linting
```bash
./gradlew ktlintCheck
./gradlew ktlintFormat
./gradlew spotlessCheck
./gradlew spotlessApply
```
## Installing on device

Wyświetl plik

@ -1,7 +1,6 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jlleitschuh.gradle.ktlint' version "11.6.1"
id 'com.google.gms.google-services'
}

Wyświetl plik

@ -1 +0,0 @@
package com.vitorpamplona.amethyst.ui.note

Wyświetl plik

@ -26,16 +26,9 @@ plugins {
id 'org.jetbrains.kotlin.jvm' version '1.9.10' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.10' apply false
id 'androidx.benchmark' version '1.1.1' apply false
id 'com.diffplug.spotless' version '6.22.0' apply false
}
tasks.register('installGitHook', Copy) {
from new File(rootProject.rootDir, 'git-hooks/pre-commit')
from new File(rootProject.rootDir, 'git-hooks/pre-push')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
tasks.getByPath(':app:preBuild').dependsOn installGitHook
subprojects {
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
@ -55,4 +48,35 @@ subprojects {
}
}
}
}
apply plugin: 'com.diffplug.spotless'
spotless {
kotlin {
target '**/*.kt'
targetExclude("$buildDir/**/*.kt")
ktlint("1.1.0")
ktfmt().googleStyle()
licenseHeaderFile rootProject.file('spotless/copyright.txt'), "package|import|class|object|sealed|open|interface|abstract "
}
groovyGradle {
target '*.gradle'
}
afterEvaluate {
tasks.named("preBuild") {
dependsOn("spotlessApply")
}
}
}
}
tasks.register('installGitHook', Copy) {
from new File(rootProject.rootDir, 'git-hooks/pre-commit')
from new File(rootProject.rootDir, 'git-hooks/pre-push')
into { new File(rootProject.rootDir, '.git/hooks') }
fileMode 0777
}
tasks.getByPath(':app:preBuild').dependsOn installGitHook

Wyświetl plik

@ -12,7 +12,7 @@ echo "$JAVA_HOME"
echo "$(java -version)"
echo "Running test... "
./gradlew ktlintCheck
./gradlew spotlessCheck
status=$?
@ -22,7 +22,7 @@ if [ "$status" = 0 ] ; then
else
echo "*********************************************************"
echo 1>&2 "Static analysis found violations it could not fix."
printf "Run ${GREEN}./gradlew ktlintFormat${NO_COLOR} to fix formatting related issues...\n"
printf "Run ${GREEN}./gradlew spotlessApply${NO_COLOR} to fix formatting related issues...\n"
echo "*********************************************************"
exit 1
fi

Wyświetl plik

@ -0,0 +1,7 @@
Copyright (c) 2023 Vitor Pamplona
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.