Skip to content

Commit

Permalink
Adds ktlint to project
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuskiser committed May 2, 2022
1 parent 2501c49 commit 7679a98
Show file tree
Hide file tree
Showing 13 changed files with 168 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ jobs:
- name: Build Project
run: ./gradlew assemble

- name: Lint Checks
run: ./gradlew ktlint

- name: Run Tests
run: ./gradlew test
117 changes: 117 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

apply from: new File(rootProject.projectDir, "./buildscripts/ktlint.gradle")

android {
compileSdk 31

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.example.envelopebudget

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand All @@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.envelopebudget", appContext.packageName)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ fun DefaultPreview() {
EnvelopeBudgetTheme {
Greeting("Android")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import androidx.compose.ui.graphics.Color
val Purple200 = Color(0xFFBB86FC)
val Purple500 = Color(0xFF6200EE)
val Purple700 = Color(0xFF3700B3)
val Teal200 = Color(0xFF03DAC5)
val Teal200 = Color(0xFF03DAC5)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ val Shapes = Shapes(
small = RoundedCornerShape(4.dp),
medium = RoundedCornerShape(4.dp),
large = RoundedCornerShape(0.dp)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ fun EnvelopeBudgetTheme(
shapes = Shapes,
content = content
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ val Typography = Typography(
fontSize = 12.sp
)
*/
)
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.example.envelopebudget

import junit.framework.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand All @@ -14,4 +13,4 @@ class ExampleUnitTest {
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
}
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ buildscript {
ext {
compose_version = '1.0.1'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
Expand Down
28 changes: 28 additions & 0 deletions buildscripts/ktlint.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
configurations {
ktlint
}

dependencies {
ktlint "com.pinterest:ktlint:0.43.1"
// additional 3rd party ruleset(s) can be specified here
// just add them to the classpath (ktlint 'groupId:artifactId:version') and
// ktlint will pick them up
}

task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
check.dependsOn ktlint

task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
main = "com.pinterest.ktlint.Main"
classpath = configurations.ktlint
args "-F", "src/**/*.kt"
}

0 comments on commit 7679a98

Please sign in to comment.