Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching for Kotlinter for #17. #28

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
run: ./gradlew test

- name: Lint Checks
run: ./gradlew detekt ktlintCheck lint
run: ./gradlew detekt lintKotlin lint
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ You may notice that dependencies are set up in a very specific way. Each of the

```groovy
subprojects {
apply from: "../buildscripts/ktlint.gradle"
apply from: "../buildscripts/detekt.gradle"
apply from: "../buildscripts/versionsplugin.gradle"
}
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("org.jmailen.kotlinter")
}

android {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/template/theme/Shape.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import androidx.compose.ui.unit.dp
val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp),
large = RoundedCornerShape(0.dp)
)
4 changes: 2 additions & 2 deletions app/src/main/java/template/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import androidx.compose.ui.platform.LocalContext

private val darkColorScheme = darkColorScheme(
primary = Purple200,
secondary = Teal200,
secondary = Teal200
)

private val lightColorScheme = lightColorScheme(
primary = Purple500,
secondary = Teal200,
secondary = Teal200
)

@Composable
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/template/theme/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ val Typography = Typography(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
),
)
)
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ buildscript {
extra.apply {
set("kotlinVersion", "1.7.10")

// https://github.com/JLLeitschuh/ktlint-gradle/releases
set("ktlintPluginVersion", "11.0.0")

// https://github.com/detekt/detekt/releases
set("detektVersion", "1.21.0")

Expand All @@ -22,7 +19,6 @@ buildscript {
dependencies {
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra.get("kotlinVersion")}")
classpath("org.jlleitschuh.gradle:ktlint-gradle:${rootProject.extra.get("ktlintPluginVersion")}")
classpath("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${rootProject.extra.get("detektVersion")}")
classpath("com.github.ben-manes:gradle-versions-plugin:${rootProject.extra.get("versionsPluginVersion")}")

Expand All @@ -31,11 +27,15 @@ buildscript {
}
}

plugins {
// https://github.com/jeremymailen/kotlinter-gradle/releases
id("org.jmailen.kotlinter") version "3.13.0" apply false
}

apply(from = "buildscripts/githooks.gradle")
apply(from = "buildscripts/setup.gradle")

subprojects {
apply(from = "../buildscripts/ktlint.gradle")
apply(from = "../buildscripts/detekt.gradle")
apply(from = "../buildscripts/versionsplugin.gradle")
}
Expand Down
14 changes: 0 additions & 14 deletions buildscripts/ktlint.gradle

This file was deleted.

6 changes: 3 additions & 3 deletions documentation/StaticAnalysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ To run a detekt validation, use the following Gradle command:

[Ktlint](https://github.com/pinterest/ktlint) is a static analysis tool from Pinterest that prevents bike shedding when it comes to code formatting. It also comes with a Gradle task to automatically format your entire codebase, if it can. The benefit of a tool like this is to ensure everyone on the team will have code formatted the same way, and there's no debating around white spaces, indentation, imports, etc.

We use the [JLLeitschuh](https://github.com/jlleitschuh/ktlint-gradle) Ktlint Gradle plugin in this project. You can find the setup in [this Gradle file](/buildscripts/ktlint.gradle).
We use the [Kotlinter](https://github.com/jeremymailen/kotlinter-gradle) Ktlint Gradle plugin in this project.

The following Gradle commands can be helpful:

```
// Will format the codebase
./gradlew ktlintFormat
./gradlew formatKotlin

// Will check if everything is formatted correctly
./gradlew ktlintCheck
./gradlew lintKotlin
```
2 changes: 1 addition & 1 deletion git-hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi;
echo "Running ktlint over these files:"
echo "$CHANGED_FILES"

./gradlew --quiet ktlintFormat -PinternalKtlintGitFilter="$CHANGED_FILES"
./gradlew --quiet formatKotlin -PinternalKtlintGitFilter="$CHANGED_FILES"

echo "Completed ktlint run."

Expand Down
2 changes: 1 addition & 1 deletion git-hooks/pre-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

echo "Running static analysis."

./gradlew ktlintCheck
./gradlew lintKotlin
./gradlew detekt