Skip to content

Commit dde6d71

Browse files
Merge pull request #126 from droidconKE/issue-117
Setup Lint Plugins
2 parents b671acb + ce18048 commit dde6d71

File tree

81 files changed

+880
-335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+880
-335
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[*.{kt,kts}]
2+
insert_final_newline=false
3+
max_line_length=off
4+
disabled_rules=no-wildcard-imports,import-ordering

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ jobs:
2323
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/src/main/kotlin/Dependencies.kt') }}
2424
- name: Unit tests
2525
run: ./gradlew -Pci --console=plain bundleDebug
26+
lint-check:
27+
name: Lint check
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: gradle/wrapper-validation-action@v1
33+
- uses: actions/setup-java@v1
34+
with:
35+
java-version: 8
36+
- uses: actions/cache@v1
37+
with:
38+
path: ~/.gradle/caches
39+
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/src/main/kotlin/Dependencies.kt') }}
40+
- name: Lint checks
41+
run: ./gradlew -Pci --console=plain ktlintFormat ktlintCheck detekt
2642
unit-tests:
2743
name: Unit tests
2844
runs-on: ubuntu-latest

app/build.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id(BuildPlugins.kotlinAndroid)
44
id(BuildPlugins.kotlinAndroidExtensions)
55
id(BuildPlugins.safeArgs)
6+
id(BuildPlugins.ktlintPlugin)
67
}
78
android {
89
compileSdkVersion(AndroidSDK.compile)
@@ -88,15 +89,11 @@ dependencies {
8889
implementation(Libraries.koinScope)
8990
implementation(Libraries.koinViewModel)
9091

91-
androidTestImplementation(TestLibraries.testRunner)
9292
androidTestImplementation(TestLibraries.testRules)
9393
androidTestImplementation(TestLibraries.koin)
9494
debugImplementation(TestLibraries.fragment)
9595
androidTestImplementation(TestLibraries.kakao)
96-
97-
//Google services
9896
implementation(Libraries.googleServices)
99-
10097
// Mock data
10198
api(Libraries.fakeit)
102-
}
99+
}

app/src/main/java/com/android254/droidconKE2020/DroidConKeApp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class DroidConKeApp : Application() {
2323
setSavedTheme()
2424
}
2525

26-
fun setSavedTheme() {
27-
val sharedPrefs: Preferences by inject()
26+
fun setSavedTheme() {
27+
val sharedPrefs: Preferences by inject()
2828
val savedTheme = sharedPrefs.getUserTheme()
2929
AppCompatDelegate.setDefaultNightMode(savedTheme)
3030
}

app/src/main/java/com/android254/droidconKE2020/DynamicToolbar.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class DynamicToolbar @JvmOverloads constructor(
2323
var authHandler: (() -> Unit)? = null
2424
var feedbackHandler: (() -> Unit)? = null
2525
var nightModeHandler: (() -> Unit)? = null
26-
var sessionsHandler :(() -> Unit)? = null
26+
var sessionsHandler: (() -> Unit)? = null
2727

28-
fun onDestinationChanged(destination: Int, destinationName : String) {
28+
fun onDestinationChanged(destination: Int, destinationName: String) {
2929
when (destination) {
3030
R.id.homeFragment, R.id.authDialog -> setHomeToolbar()
3131
R.id.feedFragment -> setFeedToolbar()
@@ -52,7 +52,8 @@ class DynamicToolbar @JvmOverloads constructor(
5252
}
5353
addView(view)
5454
} else {
55-
val view = LayoutInflater.from(context).inflate(R.layout.home_signed_out_toolbar, this, false)
55+
val view = LayoutInflater.from(context).inflate(R.layout.home_signed_out_toolbar,
56+
this, false)
5657
val droidconIcon = view.findViewById<ImageView>(R.id.imgToolbarLogo)
5758
droidconIcon.setOnClickListener {
5859
nightModeHandler?.invoke()
@@ -75,5 +76,4 @@ class DynamicToolbar @JvmOverloads constructor(
7576
}
7677
return view
7778
}
78-
7979
}

app/src/main/java/com/android254/droidconKE2020/HomeActivity.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ class HomeActivity : AppCompatActivity() {
3333
feedback()
3434
}
3535
toolbar.nightModeHandler = {
36-
Toast.makeText(applicationContext,"Night",Toast.LENGTH_SHORT).show()
36+
Toast.makeText(applicationContext, "Night", Toast.LENGTH_SHORT).show()
3737
toggleDarkTheme()
3838
}
3939
}
4040

41-
//Set up bottom navigation
41+
// Set up bottom navigation
4242
private fun setUpBottomNavigation() {
43-
//Retrieve fragment container view as nav host fragment
43+
// Retrieve fragment container view as nav host fragment
4444
val navHostFragment =
4545
supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
4646
val navController = navHostFragment.findNavController()
47-
//Setup bottom navigation view with nav controller for dynamic navigation
47+
// Setup bottom navigation view with nav controller for dynamic navigation
4848
bottomNavigation.setupWithNavController(navController = navController)
4949
navController.addOnDestinationChangedListener { _, destination, _ ->
5050
toolbar.onDestinationChanged(destination.id, destination.label as String)
@@ -77,4 +77,4 @@ class HomeActivity : AppCompatActivity() {
7777
sharedPrefs.setUserTheme(newTheme)
7878
(application as DroidConKeApp).setSavedTheme()
7979
}
80-
}
80+
}
Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
package com.android254.droidconKE2020
22

33
import android.content.Intent
4-
import androidx.appcompat.app.AppCompatActivity
54
import android.os.Bundle
6-
import android.util.Log
5+
import androidx.appcompat.app.AppCompatActivity
76
import com.android254.droidconKE2020.core.PreferencesImpl
87
import com.example.android_animation.AndroidAnimation
98
import com.example.android_animation.enums.Easing
109
import kotlinx.android.synthetic.main.activity_splash_screen.*
1110

1211
class SplashScreenActivity : AppCompatActivity() {
1312

14-
private val MAX_SCALE = 1.5f
15-
private val MIN_SCALE = .3f
16-
private val MAX_ROTATION = 360f
17-
private val MIN_ROTATION = -45f
18-
private val MAX_TRANSLATION_X = 310f
19-
private val MAX_TRANSLATION_Y = 170f
13+
private val maxScale = 1.5f
14+
private val minScale = .3f
15+
private val maxRotation = 360f
16+
private val minRotation = -45f
17+
private val maxTranslationX = 310f
18+
private val maxTranslationY = 170f
2019

2120
private lateinit var preferencesImpl: PreferencesImpl
2221

@@ -37,26 +36,26 @@ class SplashScreenActivity : AppCompatActivity() {
3736
AndroidAnimation().apply {
3837
delay = 300
3938
targetViews(imageViewLogo)
40-
scaleX(MAX_SCALE)
41-
scaleY(MAX_SCALE)
39+
scaleX(maxScale)
40+
scaleY(maxScale)
4241
duration = 1000
4342
thenPlay()
4443
easing = Easing.EXP_IN
45-
translateX(MAX_TRANSLATION_X)
46-
translateY(-MAX_TRANSLATION_Y + 40f)
47-
scaleX(MAX_SCALE - 1f)
48-
scaleY(MAX_SCALE - 1f)
49-
rotate(MIN_ROTATION)
44+
translateX(maxTranslationX)
45+
translateY(-maxTranslationY + 40f)
46+
scaleX(maxScale - 1f)
47+
scaleY(maxScale - 1f)
48+
rotate(minRotation)
5049
thenPlay()
5150
easing = Easing.CIRC_OUT
52-
translateX(-MAX_TRANSLATION_X)
53-
translateY(-MAX_TRANSLATION_Y, delay = 3500)
54-
scaleX(MIN_SCALE)
55-
scaleY(MIN_SCALE)
56-
rotate(MAX_ROTATION)
51+
translateX(-maxTranslationX)
52+
translateY(-maxTranslationY, delay = 3500)
53+
scaleX(minScale)
54+
scaleY(minScale)
55+
rotate(maxRotation)
5756
targetChildViews(linearLayout, stagger = 100, reverse = true)
58-
scaleX((MIN_SCALE + .2f), 1f, MAX_SCALE, 1f)
59-
scaleY((MIN_SCALE + .2f), 1f, MAX_SCALE, 1f)
57+
scaleX((minScale + .2f), 1f, maxScale, 1f)
58+
scaleY((minScale + .2f), 1f, maxScale, 1f)
6059
alpha(1f)
6160
onAnimationEnd {
6261
preferencesImpl.setShowSplashScreen(false)
@@ -65,4 +64,4 @@ class SplashScreenActivity : AppCompatActivity() {
6564
start()
6665
}
6766
}
68-
}
67+
}

app/src/test/java/com/android254/droidconKE2020/ExampleUnitTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.android254.droidconKE2020
22

3-
import org.junit.Test
4-
53
import org.junit.Assert.*
4+
import org.junit.Test
65

76
/**
87
* Example local unit test, which will execute on the development machine (host).
@@ -14,4 +13,4 @@ class ExampleUnitTest {
1413
fun addition_isCorrect() {
1514
assertEquals(4, 2 + 2)
1615
}
17-
}
16+
}

build.gradle.kts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
buildscript {
3-
repositories {
4-
google()
5-
jcenter()
6-
7-
}
8-
dependencies {
9-
classpath(BuildPlugins.androidGradlePlugin)
10-
classpath(BuildPlugins.kotlinGradlePlugin)
11-
classpath(BuildPlugins.safeArgsGradlePlugin)
12-
// NOTE: Do not place your application dependencies here; they belong
13-
// in the individual module build.gradle files
14-
}
2+
plugins {
3+
id(BuildPlugins.ktlintPlugin)
4+
id(BuildPlugins.dektPlugin)
5+
id(BuildPlugins.dynamicFeature) apply false
6+
id(BuildPlugins.androidLibrary) apply false
7+
id(BuildPlugins.androidApplication) apply false
8+
id(BuildPlugins.kotlinAndroid) apply false
9+
id(BuildPlugins.kotlinAndroidExtensions) apply false
10+
id(BuildPlugins.safeArgs) apply false
1511
}
1612

1713
allprojects {
@@ -20,9 +16,24 @@ allprojects {
2016
jcenter()
2117
maven(url = "https://jitpack.io")
2218
}
19+
apply(plugin = BuildPlugins.ktlintPlugin)
20+
ktlint {
21+
android.set(true)
22+
verbose.set(true)
23+
filter {
24+
exclude { element -> element.file.path.contains("generated/") }
25+
}
26+
}
27+
}
28+
subprojects {
29+
apply(plugin = BuildPlugins.dektPlugin)
30+
detekt {
31+
config = files("${project.rootDir}/detekt.yml")
32+
parallel = true
33+
}
2334
}
2435

25-
tasks.register("clean").configure{
36+
tasks.register("clean").configure {
2637
delete("build")
2738
}
2839

@@ -81,4 +92,4 @@ fun printResults(desc: TestDescriptor, result: TestResult) {
8192
println(testResultLine)
8293
println(separationLine)
8394
}
84-
}
95+
}

buildSrc/local.properties

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)