├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── scenic.jpg
│ │ │ │ ├── gradient.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ ├── layout
│ │ │ │ ├── fragment_email_login.xml
│ │ │ │ └── activity_main.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── github
│ │ │ │ └── olegosipenko
│ │ │ │ └── kointestsample
│ │ │ │ ├── EmailLoginViewState.kt
│ │ │ │ ├── KoinApp.kt
│ │ │ │ ├── EmailLoginFragmentViewModel.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── EmailLoginFragment.kt
│ │ │ │ └── EmailFragmentView.kt
│ │ └── AndroidManifest.xml
│ ├── debug
│ │ └── AndroidManifest.xml
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── olegosipenko
│ │ └── kointestsample
│ │ ├── bootstrap
│ │ └── KoinTestRunner.kt
│ │ └── EmailLoginFragmentTest.kt
├── proguard-rules.pro
└── build.gradle
├── detekt-rules
├── .gitignore
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ └── io.gitlab.arturbosch.detekt.api.RuleSetProvider
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── olegosipenko
│ │ │ └── detektrules
│ │ │ ├── CustomRulesetProvider.kt
│ │ │ └── NonExhaustiveWhen.kt
│ └── test
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── olegosipenko
│ │ └── detektrules
│ │ └── NonExhaustiveWhenTest.kt
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
└── config
└── detekt
└── detekt.yml
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/detekt-rules/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | include ':detekt-rules'
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/scenic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/drawable/scenic.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/detekt-rules/src/main/resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider:
--------------------------------------------------------------------------------
1 | com.github.olegosipenko.detektrules.CustomRulesetProvider
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/olegosipenko/SamplesApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | KoinTestApp
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Oct 29 01:09:30 CET 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | /app/google-services.json
15 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/olegosipenko/kointestsample/EmailLoginViewState.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | sealed class EmailLoginViewState {
4 | object INITIAL: EmailLoginViewState()
5 | object LOADING: EmailLoginViewState()
6 | object SUCCESS: EmailLoginViewState()
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/olegosipenko/kointestsample/KoinApp.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class KoinApp: Application() {
8 | override fun onCreate() {
9 | super.onCreate()
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/detekt-rules/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'kotlin'
2 |
3 | dependencies {
4 | compileOnly Libs.detektApi
5 |
6 | testImplementation Libs.detektApi
7 | testImplementation Libs.detektTest
8 | implementation Libs.kotlin
9 | testImplementation Libs.junitApi
10 | testImplementation Libs.junitParams
11 | testImplementation Libs.assertJ
12 | testRuntimeOnly Libs.junitEngine
13 | }
14 |
15 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
16 | kotlinOptions {
17 | jvmTarget = "1.8"
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/github/olegosipenko/kointestsample/EmailLoginFragmentViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | import android.util.Log
4 | import androidx.lifecycle.ViewModel
5 | import dagger.hilt.android.lifecycle.HiltViewModel
6 | import javax.inject.Inject
7 |
8 | @HiltViewModel
9 | class EmailLoginFragmentViewModel @Inject constructor() : ViewModel() {
10 | fun loginWithCredentials(email: String, password: String) {
11 | Log.d(this.javaClass.name, "login with:$email, $password")
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_email_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/detekt-rules/src/main/java/com/github/olegosipenko/detektrules/CustomRulesetProvider.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.detektrules
2 |
3 | import io.gitlab.arturbosch.detekt.api.Config
4 | import io.gitlab.arturbosch.detekt.api.RuleSet
5 | import io.gitlab.arturbosch.detekt.api.RuleSetProvider
6 |
7 | class CustomRulesetProvider: RuleSetProvider {
8 | override val ruleSetId: String = "detekt-rules"
9 |
10 | override fun instance(config: Config): RuleSet = RuleSet(
11 | ruleSetId,
12 | listOf(
13 | NonExhaustiveWhen(config)
14 | )
15 | )
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/olegosipenko/kointestsample/bootstrap/KoinTestRunner.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample.bootstrap
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import androidx.test.runner.AndroidJUnitRunner
6 | import dagger.hilt.android.testing.HiltTestApplication
7 |
8 | class KoinTestRunner: AndroidJUnitRunner() {
9 | override fun newApplication(
10 | cl: ClassLoader?, className: String?, context: Context?
11 | ): Application {
12 | return super.newApplication(
13 | cl, HiltTestApplication::class.java.name, context
14 | )
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/olegosipenko/kointestsample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | import android.graphics.Color
4 | import android.os.Build
5 | import android.os.Bundle
6 | import android.view.View
7 | import android.view.Window
8 | import android.view.WindowInsetsController
9 | import androidx.appcompat.app.AppCompatActivity;
10 | import androidx.core.view.WindowCompat
11 | import dagger.hilt.android.AndroidEntryPoint
12 |
13 | @AndroidEntryPoint
14 | class MainActivity: AppCompatActivity() {
15 |
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContentView(R.layout.activity_main)
19 | WindowCompat.setDecorFitsSystemWindows(window, false)
20 | window.statusBarColor = Color.TRANSPARENT
21 | window.setStatusBarDarkIcons(true)
22 | }
23 |
24 | @Suppress("DEPRECATION")
25 | fun Window.setStatusBarDarkIcons(dark: Boolean) {
26 | when {
27 | Build.VERSION_CODES.R <= Build.VERSION.SDK_INT -> insetsController?.setSystemBarsAppearance(
28 | if (dark) WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS else 0,
29 | WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
30 | )
31 | Build.VERSION_CODES.M <= Build.VERSION.SDK_INT -> decorView.systemUiVisibility = if (dark) {
32 | decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
33 | } else {
34 | decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
35 | }
36 | else -> if (dark) {
37 | // dark status bar icons not supported on API level below 23, set status bar
38 | // color to black to keep icons visible
39 | statusBarColor = Color.BLACK
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/olegosipenko/kointestsample/EmailLoginFragment.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.compose.material.MaterialTheme
8 | import androidx.compose.ui.platform.ViewCompositionStrategy
9 | import androidx.fragment.app.Fragment
10 | import androidx.fragment.app.viewModels
11 | import com.github.olegosipenko.kointestsample.databinding.FragmentEmailLoginBinding
12 | import dagger.hilt.android.AndroidEntryPoint
13 |
14 | @AndroidEntryPoint
15 | class EmailLoginFragment: Fragment() {
16 |
17 | private val fragmentViewModel: EmailLoginFragmentViewModel by viewModels()
18 | private var _viewBinding: FragmentEmailLoginBinding? = null
19 | private val viewBinding get() = requireNotNull(_viewBinding)
20 |
21 | override fun onCreateView(inflater: LayoutInflater,
22 | container: ViewGroup?,
23 | savedInstanceState: Bundle?
24 | ): View {
25 | _viewBinding = FragmentEmailLoginBinding.inflate(inflater, container, false)
26 | return viewBinding.root
27 | }
28 |
29 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
30 | super.onViewCreated(view, savedInstanceState)
31 | viewBinding.composeView.apply {
32 | setViewCompositionStrategy(
33 | ViewCompositionStrategy.DisposeOnLifecycleDestroyed(viewLifecycleOwner)
34 | )
35 | setContent {
36 | MaterialTheme {
37 | EmailLoginFragmentView(::onLoginClick)
38 | }
39 | }
40 | }
41 | }
42 |
43 | private fun onLoginClick(email: String, password: String) {
44 | fragmentViewModel.loginWithCredentials(email, password)
45 | }
46 |
47 | override fun onDestroyView() {
48 | super.onDestroyView()
49 | _viewBinding = null
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/detekt-rules/src/main/java/com/github/olegosipenko/detektrules/NonExhaustiveWhen.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.detektrules
2 |
3 | import io.gitlab.arturbosch.detekt.api.CodeSmell
4 | import io.gitlab.arturbosch.detekt.api.Config
5 | import io.gitlab.arturbosch.detekt.api.Debt
6 | import io.gitlab.arturbosch.detekt.api.Entity
7 | import io.gitlab.arturbosch.detekt.api.Issue
8 | import io.gitlab.arturbosch.detekt.api.Rule
9 | import io.gitlab.arturbosch.detekt.api.Severity
10 | import org.jetbrains.kotlin.com.intellij.psi.PsiElement
11 | import org.jetbrains.kotlin.psi.KtBlockExpression
12 | import org.jetbrains.kotlin.psi.KtLambdaExpression
13 | import org.jetbrains.kotlin.psi.KtNamedFunction
14 | import org.jetbrains.kotlin.psi.KtWhenExpression
15 |
16 | class NonExhaustiveWhen(config: Config = Config.empty): Rule(config) {
17 | override val issue = Issue(
18 | javaClass.simpleName,
19 | Severity.Defect,
20 | DESCR,
21 | Debt.FIVE_MINS
22 | )
23 |
24 | override fun visitNamedFunction(function: KtNamedFunction) {
25 | super.visitNamedFunction(function)
26 |
27 | val whenExpressions =
28 | function.children.filterIsInstance()
29 | .flatMap { blockExpression -> blockExpression.children.asIterable() }
30 | .filterIsInstance()
31 |
32 | checkIfPresent(whenExpressions, function)
33 | }
34 |
35 | override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
36 | super.visitLambdaExpression(lambdaExpression)
37 |
38 | val whenExpressions = lambdaExpression.bodyExpression?.statements
39 | ?.filterIsInstance()
40 |
41 | checkIfPresent(whenExpressions, lambdaExpression)
42 | }
43 |
44 | private fun checkIfPresent(
45 | whenExpressions: List?, psiElement: PsiElement
46 | ) {
47 | if (whenExpressions?.isNotEmpty() == true) {
48 | report(
49 | CodeSmell(
50 | issue, Entity.from(psiElement), MESSAGE
51 | )
52 | )
53 | }
54 | }
55 | }
56 |
57 | internal const val DESCR = "When should be used as expression"
58 | internal const val MESSAGE = "When not used as expression"
59 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/olegosipenko/kointestsample/EmailLoginFragmentTest.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | import android.util.Log
4 | import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
5 | import androidx.compose.ui.test.junit4.createAndroidComposeRule
6 | import androidx.test.espresso.action.ViewActions.typeText
7 | import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
8 | import dagger.hilt.android.testing.BindValue
9 | import dagger.hilt.android.testing.HiltAndroidRule
10 | import dagger.hilt.android.testing.HiltAndroidTest
11 | import io.github.kakaocup.compose.node.element.ComposeScreen
12 | import io.github.kakaocup.compose.node.element.ComposeScreen.Companion.onComposeScreen
13 | import io.github.kakaocup.compose.node.element.KNode
14 | import io.mockk.every
15 | import io.mockk.mockk
16 | import io.mockk.verify
17 | import org.junit.Before
18 | import org.junit.Rule
19 | import org.junit.Test
20 | import org.junit.runner.RunWith
21 |
22 | @HiltAndroidTest
23 | @RunWith(AndroidJUnit4ClassRunner::class)
24 | class EmailLoginFragmentTest {
25 | @get:Rule(order = 0)
26 | var hiltRule = HiltAndroidRule(this)
27 |
28 | @get:Rule(order = 1)
29 | val composeTestRule = createAndroidComposeRule()
30 |
31 | @BindValue
32 | @JvmField
33 | val fragmentViewModel: EmailLoginFragmentViewModel = mockk(relaxed = true)
34 |
35 | @Before
36 | fun init() {
37 | hiltRule.inject()
38 | }
39 |
40 | @Test
41 | fun testBasicInvocation() {
42 | onComposeScreen(composeTestRule) {
43 | emailField { performTextInput(EMAIL) }
44 | passwordField { performTextInput(PASSWORD) }
45 | loginButton { performClick() }
46 |
47 | verify {
48 | fragmentViewModel.loginWithCredentials(EMAIL, PASSWORD)
49 | }
50 | }
51 | }
52 |
53 | class EmailLoginForm(
54 | semanticsProvider: SemanticsNodeInteractionsProvider
55 | ) : ComposeScreen(semanticsProvider) {
56 | val emailField: KNode = child { hasTestTag("email-field") }
57 | val passwordField: KNode = child { hasTestTag("password-field") }
58 | val loginButton: KNode = child { hasTestTag("button") }
59 | }
60 | }
61 |
62 | private const val EMAIL = "some@email.com"
63 | private const val PASSWORD = "password"
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/detekt-rules/src/test/java/com/github/olegosipenko/detektrules/NonExhaustiveWhenTest.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.detektrules
2 |
3 | import io.gitlab.arturbosch.detekt.test.lint
4 | import org.assertj.core.api.Assertions.assertThat
5 | import org.junit.jupiter.api.DisplayName
6 | import org.junit.jupiter.api.Test
7 | import org.junit.jupiter.params.ParameterizedTest
8 | import org.junit.jupiter.params.provider.Arguments
9 | import org.junit.jupiter.params.provider.Arguments.arguments
10 | import org.junit.jupiter.params.provider.MethodSource
11 | import java.util.stream.Stream
12 |
13 | internal class NonExhaustiveWhenTest {
14 | @Test
15 | @DisplayName("non compliant when statement should warn")
16 | internal fun nonCompliantCodeShouldWarn() {
17 | val findings = NonExhaustiveWhen().lint(WHEN_STATEMENT.trimIndent())
18 |
19 | assertThat(findings).hasSize(1)
20 | assertThat(findings[0].message).isEqualTo(MESSAGE)
21 | }
22 |
23 | @DisplayName("compliant ")
24 | @MethodSource("compliantProvider")
25 | @ParameterizedTest(name = "{1} should not warn")
26 | internal fun testCompliantWhen(source: String, whenKind: String) {
27 | val findings = NonExhaustiveWhen().lint(source)
28 | assertThat(findings).isEmpty()
29 | }
30 |
31 | companion object {
32 | @JvmStatic
33 | fun compliantProvider(): Stream =
34 | Stream.of(
35 | arguments(COMPLIANT_WHEN_DOT, "dot expression"),
36 | arguments(COMPLIANT_WHEN_PROPERTY, "property"),
37 | arguments(COMPLIANT_WHEN_RETURN, "return")
38 | )
39 | }
40 | }
41 |
42 | const val WHEN_STATEMENT = """
43 | sealed class S {
44 | object A: S()
45 | object B: S()
46 | }
47 |
48 | class WhenTester {
49 | fun checkS(state: S) {
50 | when (state) {
51 | S.A -> println("a")
52 | }
53 | }
54 | }
55 | """
56 |
57 | const val COMPLIANT_WHEN_DOT = """
58 | sealed class S {
59 | object A: S()
60 | object B: S()
61 | }
62 |
63 | class WhenTester {
64 | fun checkS(state: S) {
65 | when (state) {
66 | S.A -> println("a")
67 | S.B -> println("b")
68 | }.exhaustive
69 | }
70 | }
71 | """
72 |
73 | const val COMPLIANT_WHEN_PROPERTY = """
74 | sealed class S {
75 | object A: S()
76 | object B: S()
77 | }
78 |
79 | class WhenTester {
80 | fun checkS(state: S) {
81 | val r = when (state) {
82 | S.A -> println("a")
83 | S.B -> println("b")
84 | }
85 | }
86 | }
87 |
88 | """
89 |
90 | const val COMPLIANT_WHEN_RETURN = """
91 | sealed class S {
92 | object A: S()
93 | object B: S()
94 | }
95 |
96 | class WhenTester {
97 | fun checkS(state: S) {
98 | return when (state) {
99 | S.A -> println("a")
100 | S.B -> println("b")
101 | }
102 | }
103 | }
104 |
105 | """
106 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'io.gitlab.arturbosch.detekt'
6 |
7 | apply plugin: 'dagger.hilt.android.plugin'
8 |
9 | apply plugin: 'kotlin-kapt'
10 |
11 | apply plugin: "com.google.gms.google-services"
12 |
13 | android {
14 | compileSdkVersion 33
15 | defaultConfig {
16 | applicationId "com.github.olegosipenko.kointestsample"
17 | minSdkVersion 21
18 | targetSdkVersion 33
19 | versionCode 1
20 | versionName "1.0"
21 | testInstrumentationRunner "com.github.olegosipenko.kointestsample.bootstrap.KoinTestRunner"
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | testOptions {
31 | animationsDisabled = true
32 | }
33 |
34 | kapt {
35 | correctErrorTypes true
36 | }
37 |
38 | compileOptions {
39 | sourceCompatibility JavaVersion.VERSION_1_8
40 | targetCompatibility JavaVersion.VERSION_1_8
41 | }
42 |
43 | kotlinOptions {
44 | jvmTarget = "1.8"
45 | }
46 |
47 | buildFeatures {
48 | compose true
49 | }
50 |
51 | composeOptions {
52 | kotlinCompilerExtensionVersion '1.4.7'
53 | }
54 |
55 | packagingOptions {
56 | exclude 'META-INF/DEPENDENCIES'
57 | exclude 'META-INF/LICENSE'
58 | exclude 'META-INF/LICENSE.txt'
59 | exclude 'META-INF/license.txt'
60 | exclude 'META-INF/NOTICE'
61 | exclude 'META-INF/NOTICE.txt'
62 | exclude 'META-INF/notice.txt'
63 | exclude 'META-INF/ASL2.0'
64 | exclude 'META-INF/AL2.0'
65 | exclude 'META-INF/LGPL2.1'
66 | exclude 'META-INF/LICENSE.md'
67 | exclude 'META-INF/LICENSE-notice.md'
68 | }
69 |
70 | buildFeatures {
71 | viewBinding = true
72 | }
73 | }
74 |
75 | detekt {
76 | reports {
77 | xml {
78 | enabled = false
79 | }
80 | txt {
81 | enabled = false
82 | }
83 | }
84 | }
85 |
86 | dependencies {
87 | implementation Libs.kotlin
88 | implementation Libs.appCompat
89 | implementation Libs.coreKtx
90 | implementation Libs.constraintLayout
91 | implementation Libs.material
92 | implementation Libs.viewModelKtx
93 |
94 | implementation Libs.activityCompose
95 | // Compose Material Design
96 | implementation Libs.composeMaterial
97 | // Animations
98 | implementation Libs.composeAnimation
99 | // Tooling support (Previews, etc.)
100 | implementation Libs.composeTooling
101 | // Integration with ViewModels
102 | implementation Libs.composeViewModel
103 | implementation Libs.composeConstraint
104 |
105 | implementation Libs.hiltAndroid
106 | kapt Libs.hiltCompiler
107 |
108 | detekt project(":detekt-rules")
109 | detekt Libs.detektCli
110 |
111 | implementation(platform(Libs.firebaseBom))
112 |
113 | androidTestImplementation Libs.testRunner
114 | androidTestImplementation Libs.espressoCore
115 | androidTestImplementation Libs.testRules
116 | androidTestImplementation Libs.mockkAndroid
117 | androidTestImplementation Libs.kakao
118 | androidTestImplementation Libs.hiltInstrumentation
119 | kaptAndroidTest Libs.hiltCompiler
120 | androidTestAnnotationProcessor Libs.hiltCompiler
121 | androidTestImplementation Libs.composeTest
122 | androidTestImplementation Libs.composeJUnit
123 | androidTestImplementation Libs.fragmentTesting
124 | }
125 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/olegosipenko/kointestsample/EmailFragmentView.kt:
--------------------------------------------------------------------------------
1 | package com.github.olegosipenko.kointestsample
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.material.Button
8 | import androidx.compose.material.Text
9 | import androidx.compose.material.TextField
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.runtime.getValue
12 | import androidx.compose.runtime.mutableStateOf
13 | import androidx.compose.runtime.remember
14 | import androidx.compose.runtime.setValue
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.graphics.Brush
17 | import androidx.compose.ui.graphics.Color
18 | import androidx.compose.ui.layout.ContentScale
19 | import androidx.compose.ui.res.painterResource
20 | import androidx.compose.ui.semantics.semantics
21 | import androidx.compose.ui.semantics.testTag
22 | import androidx.compose.ui.text.input.TextFieldValue
23 | import androidx.compose.ui.tooling.preview.Preview
24 | import androidx.constraintlayout.compose.ChainStyle
25 | import androidx.constraintlayout.compose.ConstraintLayout
26 | import androidx.constraintlayout.compose.Dimension
27 |
28 | @Composable
29 | fun EmailLoginFragmentView(clickListener: (String, String) -> Unit) {
30 | var emailState by remember { mutableStateOf(TextFieldValue()) }
31 | var passwordState by remember { mutableStateOf(TextFieldValue()) }
32 | ConstraintLayout(
33 | modifier = Modifier.fillMaxSize()
34 | ) {
35 | val (email, password, button) = createRefs()
36 |
37 | createVerticalChain(email, password, button, chainStyle = ChainStyle.Packed)
38 |
39 | Image(
40 | painter = painterResource(id = R.drawable.scenic),
41 | contentDescription = "scenery background",
42 | modifier = Modifier.fillMaxSize(),
43 | contentScale = ContentScale.Crop
44 | )
45 | Box(
46 | modifier = Modifier
47 | .fillMaxSize()
48 | .background(
49 | brush = Brush.verticalGradient(
50 | colors = listOf(
51 | Color.Transparent,
52 | Color.White
53 | )
54 | )
55 | )
56 | )
57 | TextField(
58 | modifier = Modifier
59 | .constrainAs(email) {
60 | top.linkTo(parent.top)
61 | bottom.linkTo(password.top)
62 | start.linkTo(parent.start)
63 | end.linkTo(parent.end)
64 | }
65 | .semantics { testTag = "email-field" },
66 | label = {
67 | Text(text = "E-mail")
68 | },
69 | value = emailState,
70 | onValueChange = {
71 | emailState = it
72 | }
73 | )
74 | TextField(
75 | modifier = Modifier
76 | .constrainAs(password) {
77 | top.linkTo(email.bottom)
78 | bottom.linkTo(button.top)
79 | start.linkTo(parent.start)
80 | end.linkTo(parent.end)
81 | }
82 | .semantics { testTag = "password-field" },
83 | label = {
84 | Text(text = "password")
85 | },
86 | value = passwordState,
87 | onValueChange = {
88 | passwordState = it
89 | }
90 | )
91 | Button(
92 | modifier = Modifier
93 | .constrainAs(button) {
94 | width = Dimension.fillToConstraints
95 | start.linkTo(email.start)
96 | end.linkTo(email.end)
97 | top.linkTo(password.bottom)
98 | bottom.linkTo(parent.bottom)
99 | }
100 | .semantics { testTag = "button" },
101 | onClick = {
102 | clickListener.invoke(
103 | emailState.text, passwordState.text
104 | )
105 | }
106 | ) {
107 | Text(text = "Login")
108 | }
109 | }
110 | }
111 |
112 | @Preview
113 | @Composable
114 | fun PreviewFragment() {
115 | EmailLoginFragmentView { _, _ -> }
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/config/detekt/detekt.yml:
--------------------------------------------------------------------------------
1 | config:
2 | validation: true
3 | excludes: "detekt-rules.*"
4 |
5 | build:
6 | maxIssues: 0
7 | weights:
8 | # complexity: 2
9 | # LongParameterList: 1
10 | # style: 1
11 | # comments: 1
12 |
13 | processors:
14 | active: true
15 | exclude:
16 | # - 'DetektProgressListener'
17 | # - 'FunctionCountProcessor'
18 | # - 'PropertyCountProcessor'
19 | # - 'ClassCountProcessor'
20 | # - 'PackageCountProcessor'
21 | # - 'KtFileCountProcessor'
22 |
23 | console-reports:
24 | active: true
25 | exclude:
26 | # - 'ProjectStatisticsReport'
27 | # - 'ComplexityReport'
28 | # - 'NotificationReport'
29 | # - 'FindingsReport'
30 | # - 'BuildFailureReport'
31 |
32 | comments:
33 | active: true
34 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
35 | CommentOverPrivateFunction:
36 | active: false
37 | CommentOverPrivateProperty:
38 | active: false
39 | EndOfSentenceFormat:
40 | active: false
41 | endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!:]$)
42 | UndocumentedPublicClass:
43 | active: false
44 | searchInNestedClass: true
45 | searchInInnerClass: true
46 | searchInInnerObject: true
47 | searchInInnerInterface: true
48 | UndocumentedPublicFunction:
49 | active: false
50 |
51 | complexity:
52 | active: true
53 | ComplexCondition:
54 | active: true
55 | threshold: 4
56 | ComplexInterface:
57 | active: false
58 | threshold: 10
59 | includeStaticDeclarations: false
60 | ComplexMethod:
61 | active: true
62 | threshold: 10
63 | ignoreSingleWhenExpression: false
64 | ignoreSimpleWhenEntries: false
65 | LabeledExpression:
66 | active: false
67 | ignoredLabels: ""
68 | LargeClass:
69 | active: true
70 | threshold: 600
71 | LongMethod:
72 | active: true
73 | threshold: 60
74 | LongParameterList:
75 | active: true
76 | threshold: 6
77 | ignoreDefaultParameters: false
78 | MethodOverloading:
79 | active: false
80 | threshold: 6
81 | NestedBlockDepth:
82 | active: true
83 | threshold: 4
84 | StringLiteralDuplication:
85 | active: false
86 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
87 | threshold: 3
88 | ignoreAnnotation: true
89 | excludeStringsWithLessThan5Characters: true
90 | ignoreStringsRegex: '$^'
91 | TooManyFunctions:
92 | active: true
93 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
94 | thresholdInFiles: 11
95 | thresholdInClasses: 11
96 | thresholdInInterfaces: 11
97 | thresholdInObjects: 11
98 | thresholdInEnums: 11
99 | ignoreDeprecated: false
100 | ignorePrivate: false
101 | ignoreOverridden: false
102 |
103 | empty-blocks:
104 | active: true
105 | EmptyCatchBlock:
106 | active: true
107 | allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
108 | EmptyClassBlock:
109 | active: true
110 | EmptyDefaultConstructor:
111 | active: true
112 | EmptyDoWhileBlock:
113 | active: true
114 | EmptyElseBlock:
115 | active: true
116 | EmptyFinallyBlock:
117 | active: true
118 | EmptyForBlock:
119 | active: true
120 | EmptyFunctionBlock:
121 | active: true
122 | ignoreOverriddenFunctions: false
123 | EmptyIfBlock:
124 | active: true
125 | EmptyInitBlock:
126 | active: true
127 | EmptyKtFile:
128 | active: true
129 | EmptySecondaryConstructor:
130 | active: true
131 | EmptyWhenBlock:
132 | active: true
133 | EmptyWhileBlock:
134 | active: true
135 |
136 | exceptions:
137 | active: true
138 | ExceptionRaisedInUnexpectedLocation:
139 | active: false
140 | methodNames: 'toString,hashCode,equals,finalize'
141 | InstanceOfCheckForException:
142 | active: false
143 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
144 | NotImplementedDeclaration:
145 | active: false
146 | PrintStackTrace:
147 | active: false
148 | RethrowCaughtException:
149 | active: false
150 | ReturnFromFinally:
151 | active: false
152 | SwallowedException:
153 | active: false
154 | ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException'
155 | allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
156 | ThrowingExceptionFromFinally:
157 | active: false
158 | ThrowingExceptionInMain:
159 | active: false
160 | ThrowingExceptionsWithoutMessageOrCause:
161 | active: false
162 | exceptions: 'IllegalArgumentException,IllegalStateException,IOException'
163 | ThrowingNewInstanceOfSameException:
164 | active: false
165 | TooGenericExceptionCaught:
166 | active: true
167 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
168 | exceptionNames:
169 | - ArrayIndexOutOfBoundsException
170 | - Error
171 | - Exception
172 | - IllegalMonitorStateException
173 | - NullPointerException
174 | - IndexOutOfBoundsException
175 | - RuntimeException
176 | - Throwable
177 | allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
178 | TooGenericExceptionThrown:
179 | active: true
180 | exceptionNames:
181 | - Error
182 | - Exception
183 | - Throwable
184 | - RuntimeException
185 |
186 | formatting:
187 | active: true
188 | android: false
189 | autoCorrect: true
190 | AnnotationOnSeparateLine:
191 | active: false
192 | autoCorrect: true
193 | ChainWrapping:
194 | active: true
195 | autoCorrect: true
196 | CommentSpacing:
197 | active: true
198 | autoCorrect: true
199 | Filename:
200 | active: true
201 | FinalNewline:
202 | active: true
203 | autoCorrect: true
204 | ImportOrdering:
205 | active: false
206 | autoCorrect: true
207 | Indentation:
208 | active: false
209 | autoCorrect: true
210 | indentSize: 4
211 | continuationIndentSize: 4
212 | MaximumLineLength:
213 | active: true
214 | maxLineLength: 120
215 | ModifierOrdering:
216 | active: true
217 | autoCorrect: true
218 | MultiLineIfElse:
219 | active: true
220 | autoCorrect: true
221 | NoBlankLineBeforeRbrace:
222 | active: true
223 | autoCorrect: true
224 | NoConsecutiveBlankLines:
225 | active: true
226 | autoCorrect: true
227 | NoEmptyClassBody:
228 | active: true
229 | autoCorrect: true
230 | NoLineBreakAfterElse:
231 | active: true
232 | autoCorrect: true
233 | NoLineBreakBeforeAssignment:
234 | active: true
235 | autoCorrect: true
236 | NoMultipleSpaces:
237 | active: true
238 | autoCorrect: true
239 | NoSemicolons:
240 | active: true
241 | autoCorrect: true
242 | NoTrailingSpaces:
243 | active: true
244 | autoCorrect: true
245 | NoUnitReturn:
246 | active: true
247 | autoCorrect: true
248 | NoUnusedImports:
249 | active: true
250 | autoCorrect: true
251 | NoWildcardImports:
252 | active: true
253 | PackageName:
254 | active: true
255 | autoCorrect: true
256 | ParameterListWrapping:
257 | active: true
258 | autoCorrect: true
259 | indentSize: 4
260 | SpacingAroundColon:
261 | active: true
262 | autoCorrect: true
263 | SpacingAroundComma:
264 | active: true
265 | autoCorrect: true
266 | SpacingAroundCurly:
267 | active: true
268 | autoCorrect: true
269 | SpacingAroundDot:
270 | active: true
271 | autoCorrect: true
272 | SpacingAroundKeyword:
273 | active: true
274 | autoCorrect: true
275 | SpacingAroundOperators:
276 | active: true
277 | autoCorrect: true
278 | SpacingAroundParens:
279 | active: true
280 | autoCorrect: true
281 | SpacingAroundRangeOperator:
282 | active: true
283 | autoCorrect: true
284 | StringTemplate:
285 | active: true
286 | autoCorrect: true
287 |
288 | naming:
289 | active: true
290 | ClassNaming:
291 | active: true
292 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
293 | classPattern: '[A-Z$][a-zA-Z0-9$]*'
294 | ConstructorParameterNaming:
295 | active: true
296 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
297 | parameterPattern: '[a-z][A-Za-z0-9]*'
298 | privateParameterPattern: '[a-z][A-Za-z0-9]*'
299 | excludeClassPattern: '$^'
300 | EnumNaming:
301 | active: true
302 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
303 | enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*'
304 | ForbiddenClassName:
305 | active: false
306 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
307 | forbiddenName: ''
308 | FunctionMaxLength:
309 | active: false
310 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
311 | maximumFunctionNameLength: 30
312 | FunctionMinLength:
313 | active: false
314 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
315 | minimumFunctionNameLength: 3
316 | FunctionNaming:
317 | active: true
318 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
319 | functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
320 | excludeClassPattern: '$^'
321 | ignoreOverridden: true
322 | FunctionParameterNaming:
323 | active: true
324 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
325 | parameterPattern: '[a-z][A-Za-z0-9]*'
326 | excludeClassPattern: '$^'
327 | ignoreOverriddenFunctions: true
328 | InvalidPackageDeclaration:
329 | active: false
330 | rootPackage: ''
331 | MatchingDeclarationName:
332 | active: true
333 | MemberNameEqualsClassName:
334 | active: false
335 | ignoreOverriddenFunction: true
336 | ObjectPropertyNaming:
337 | active: true
338 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
339 | constantPattern: '[A-Za-z][_A-Za-z0-9]*'
340 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
341 | privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*'
342 | PackageNaming:
343 | active: true
344 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
345 | packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$'
346 | TopLevelPropertyNaming:
347 | active: true
348 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
349 | constantPattern: '[A-Z][_A-Z0-9]*'
350 | propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
351 | privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
352 | VariableMaxLength:
353 | active: false
354 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
355 | maximumVariableNameLength: 64
356 | VariableMinLength:
357 | active: false
358 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
359 | minimumVariableNameLength: 1
360 | VariableNaming:
361 | active: true
362 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
363 | variablePattern: '[a-z][A-Za-z0-9]*'
364 | privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
365 | excludeClassPattern: '$^'
366 | ignoreOverridden: true
367 |
368 | performance:
369 | active: true
370 | ArrayPrimitive:
371 | active: false
372 | ForEachOnRange:
373 | active: true
374 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
375 | SpreadOperator:
376 | active: true
377 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
378 | UnnecessaryTemporaryInstantiation:
379 | active: true
380 |
381 | potential-bugs:
382 | active: true
383 | DuplicateCaseInWhenExpression:
384 | active: true
385 | EqualsAlwaysReturnsTrueOrFalse:
386 | active: false
387 | EqualsWithHashCodeExist:
388 | active: true
389 | ExplicitGarbageCollectionCall:
390 | active: true
391 | InvalidRange:
392 | active: false
393 | IteratorHasNextCallsNextMethod:
394 | active: false
395 | IteratorNotThrowingNoSuchElementException:
396 | active: false
397 | LateinitUsage:
398 | active: false
399 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
400 | excludeAnnotatedProperties: ""
401 | ignoreOnClassesPattern: ""
402 | MissingWhenCase:
403 | active: false
404 | RedundantElseInWhen:
405 | active: false
406 | UnconditionalJumpStatementInLoop:
407 | active: false
408 | UnreachableCode:
409 | active: true
410 | UnsafeCallOnNullableType:
411 | active: false
412 | UnsafeCast:
413 | active: false
414 | UselessPostfixExpression:
415 | active: false
416 | WrongEqualsTypeParameter:
417 | active: false
418 |
419 | style:
420 | active: true
421 | CollapsibleIfStatements:
422 | active: false
423 | DataClassContainsFunctions:
424 | active: false
425 | conversionFunctionPrefix: 'to'
426 | DataClassShouldBeImmutable:
427 | active: false
428 | EqualsNullCall:
429 | active: false
430 | EqualsOnSignatureLine:
431 | active: false
432 | ExplicitItLambdaParameter:
433 | active: false
434 | ExpressionBodySyntax:
435 | active: false
436 | includeLineWrapping: false
437 | ForbiddenComment:
438 | active: true
439 | values: 'TODO:,FIXME:,STOPSHIP:'
440 | ForbiddenImport:
441 | active: false
442 | imports: ''
443 | ForbiddenVoid:
444 | active: false
445 | ignoreOverridden: false
446 | ignoreUsageInGenerics: false
447 | FunctionOnlyReturningConstant:
448 | active: false
449 | ignoreOverridableFunction: true
450 | excludedFunctions: 'describeContents'
451 | LibraryCodeMustSpecifyReturnType:
452 | active: false
453 | LoopWithTooManyJumpStatements:
454 | active: false
455 | maxJumpCount: 1
456 | MagicNumber:
457 | active: true
458 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
459 | ignoreNumbers: '-1,0,1,2'
460 | ignoreHashCodeFunction: true
461 | ignorePropertyDeclaration: false
462 | ignoreConstantDeclaration: true
463 | ignoreCompanionObjectPropertyDeclaration: true
464 | ignoreAnnotation: false
465 | ignoreNamedArgument: true
466 | ignoreEnums: false
467 | ignoreRanges: false
468 | MandatoryBracesIfStatements:
469 | active: false
470 | MaxLineLength:
471 | active: true
472 | maxLineLength: 120
473 | excludePackageStatements: true
474 | excludeImportStatements: true
475 | excludeCommentStatements: false
476 | MayBeConst:
477 | active: false
478 | ModifierOrder:
479 | active: true
480 | NestedClassesVisibility:
481 | active: false
482 | NewLineAtEndOfFile:
483 | active: true
484 | NoTabs:
485 | active: false
486 | OptionalAbstractKeyword:
487 | active: true
488 | OptionalUnit:
489 | active: false
490 | OptionalWhenBraces:
491 | active: false
492 | PreferToOverPairSyntax:
493 | active: false
494 | ProtectedMemberInFinalClass:
495 | active: false
496 | RedundantVisibilityModifierRule:
497 | active: false
498 | ReturnCount:
499 | active: true
500 | max: 2
501 | excludedFunctions: "equals"
502 | excludeLabeled: false
503 | excludeReturnFromLambda: true
504 | SafeCast:
505 | active: true
506 | SerialVersionUIDInSerializableClass:
507 | active: false
508 | SpacingBetweenPackageAndImports:
509 | active: false
510 | ThrowsCount:
511 | active: true
512 | max: 2
513 | TrailingWhitespace:
514 | active: false
515 | UnderscoresInNumericLiterals:
516 | active: false
517 | acceptableDecimalLength: 5
518 | UnnecessaryAbstractClass:
519 | active: false
520 | excludeAnnotatedClasses: "dagger.Module"
521 | UnnecessaryApply:
522 | active: false
523 | UnnecessaryInheritance:
524 | active: false
525 | UnnecessaryLet:
526 | active: false
527 | UnnecessaryParentheses:
528 | active: false
529 | UntilInsteadOfRangeTo:
530 | active: false
531 | UnusedImports:
532 | active: false
533 | UnusedPrivateClass:
534 | active: false
535 | UnusedPrivateMember:
536 | active: false
537 | allowedNames: "(_|ignored|expected|serialVersionUID)"
538 | UseCheckOrError:
539 | active: false
540 | UseDataClass:
541 | active: false
542 | excludeAnnotatedClasses: ""
543 | UseRequire:
544 | active: false
545 | UselessCallOnNotNull:
546 | active: false
547 | UtilityClassWithPublicConstructor:
548 | active: false
549 | VarCouldBeVal:
550 | active: false
551 | WildcardImport:
552 | active: true
553 | excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
554 | excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
555 |
556 | detekt-rules:
557 | NonExhaustiveWhen:
558 | active: true
--------------------------------------------------------------------------------