Skip to content

Commit

Permalink
Added lint & detekt plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
LachlanMcKee committed Aug 14, 2022
1 parent 3121360 commit 6387107
Show file tree
Hide file tree
Showing 62 changed files with 466 additions and 365 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,31 @@ jobs:
- name: "Build project & run tests"
uses: gradle/gradle-build-action@v2
with:
arguments: build
arguments: |
build
mergeLintSarif
mergeDetektSarif
:plugins:buildPlugins
--continue
- name: "Verify publishing"
uses: gradle/gradle-build-action@v2
with:
arguments: publishToMavenLocal
- uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
sarif_file: build/lint-merged.sarif
category: lint
- uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
sarif_file: build/detekt-merged.sarif
category: detekt
- name: Upload failure artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: unit-test-failures
name: reports
path: '**/build/reports'

instrumentation-tests:
Expand Down
1 change: 1 addition & 0 deletions binder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'mvi-core-publish-java'
id 'kotlin'
id 'org.jetbrains.dokka'
id 'mvi-core-detekt'
}

dependencies {
Expand Down
11 changes: 11 additions & 0 deletions binder/detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8'?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MaxLineLength:Connection.kt$infix</ID>
<ID>MaxLineLength:ManualLifecycle.kt$ManualLifecycle$class</ID>
<ID>ReturnCount:Consumer.kt$fun &lt;In> Consumer&lt;In>.wrapWithMiddleware( standalone: Boolean = true, name: String? = null, postfix: String? = null, wrapperOf: Any? = null ): Consumer&lt;In></ID>
<ID>TooManyFunctions:Binder.kt$Binder : Disposable</ID>
<ID>UseCheckOrError:StandaloneMiddleware.kt$StandaloneMiddleware$throw IllegalStateException("Middleware was initialised in standalone mode, can't accept other connections")</ID>
</CurrentIssues>
</SmellBaseline>
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ buildscript {
}
}

plugins {
id 'mvi-core-collect-sarif'
}

task clean(type: Delete) {
delete rootProject.buildDir
}
2 changes: 2 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config:
warningsAsErrors: true
7 changes: 6 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[versions]
kotlinVersion = "1.6.21"
detekt = "1.21.0"

# Android
androidLifecycleVersion = "2.2.0"
Expand All @@ -17,7 +18,7 @@ daggerVersion = "2.43.2"

# Utils
debugDrawerVersion = "0.9.0"
timberVersion = "4.7.1"
timberVersion = "5.0.1"
scalpelVersion = "1.1.2"
glideVersion = "4.13.2"

Expand Down Expand Up @@ -86,4 +87,8 @@ androidx-test-runner = { module = "androidx.test:runner", version.ref = "support
androidx-test-rules = { module = "androidx.test:rules", version.ref = "supportTestVersion" }

plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinVersion" }
plugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
plugin-android = "com.android.tools.build:gradle:7.2.2"

[plugins]
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
2 changes: 2 additions & 0 deletions mvicore-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'mvi-core-publish-android'
id 'mvi-core-lint'
id 'mvi-core-detekt'
}

group='com.github.badoo.mvicore'
Expand Down
7 changes: 7 additions & 0 deletions mvicore-android/detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MaxLineLength:AndroidTimeCapsule.kt$AndroidTimeCapsule$fun saveState(outState: Bundle)</ID>
</CurrentIssues>
</SmellBaseline>
15 changes: 15 additions & 0 deletions mvicore-android/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.2.2" type="baseline" client="gradle" dependencies="false" name="AGP (7.2.2)" variant="all" version="7.2.2">

<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
errorLine1=" targetSdkVersion 31"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="16"
column="9"/>
</issue>

</issues>
2 changes: 2 additions & 0 deletions mvicore-debugdrawer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'mvi-core-publish-android'
id 'mvi-core-lint'
id 'mvi-core-detekt'
}

group='com.github.badoo.mvicore'
Expand Down
15 changes: 15 additions & 0 deletions mvicore-debugdrawer/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.2.2" type="baseline" client="gradle" dependencies="false" name="AGP (7.2.2)" variant="all" version="7.2.2">

<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
errorLine1=" targetSdkVersion 31"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="16"
column="9"/>
</issue>

</issues>
5 changes: 5 additions & 0 deletions mvicore-debugdrawer/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="ContentDescription" severity="ignore" />
<issue id="HardcodedText" severity="ignore" />
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import android.widget.ImageButton
import android.widget.Spinner
import android.widget.Toast
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware.RecordStore.PlaybackState.*
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware.RecordStore.PlaybackState.FINISHED_PLAYBACK
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware.RecordStore.PlaybackState.IDLE
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware.RecordStore.PlaybackState.PLAYBACK
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware.RecordStore.PlaybackState.RECORDING
import com.badoo.mvicore.consumer.middleware.PlaybackMiddleware.RecordStore.RecordKey
import io.palaima.debugdrawer.DebugDrawer
import io.palaima.debugdrawer.base.DebugModuleAdapter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -10,4 +11,5 @@
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:minHeight="?android:attr/listPreferredItemHeightSmall" />
android:minHeight="?android:attr/listPreferredItemHeightSmall"
tools:ignore="SmallSp" />
7 changes: 0 additions & 7 deletions mvicore-debugdrawer/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="grey_50">#fafafa</color>
<color name="grey_100">#f5f5f5</color>
<color name="grey_200">#eeeeee</color>
<color name="grey_300">#e0e0e0</color>
<color name="grey_400">#bdbdbd</color>
<color name="grey_500">#9e9e9e</color>
<color name="grey_600">#757575</color>
<color name="grey_700">#616161</color>
<color name="grey_800">#424242</color>
<color name="grey_900">#212121</color>
</resources>
2 changes: 2 additions & 0 deletions mvicore-demo/mvicore-demo-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'mvi-core-lint'
id 'mvi-core-detekt'
}

android {
Expand Down
13 changes: 13 additions & 0 deletions mvicore-demo/mvicore-demo-app/detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MagicNumber:ViewModelTransformer.kt$ViewModelTransformer$3</ID>
<ID>MagicNumber:ViewModelTransformer1.kt$ViewModelTransformer1$3</ID>
<ID>MaxLineLength:MainActivityBindings.kt$MainActivityBindings$binder.bind(combineLatest(feature1, feature2) to view using ViewModelTransformer() named "MainActivity.ViewModels")</ID>
<ID>TooManyFunctions:LifecycleDemoActivity.kt$LifecycleDemoActivity : AppCompatActivity</ID>
<ID>UtilityClassWithPublicConstructor:Auth.kt$PrefsHelper</ID>
<ID>WildcardImport:UiEventTransformer1.kt$import com.badoo.feature1.Feature1.Wish.*</ID>
<ID>WildcardImport:UiEventTransformer2.kt$import com.badoo.feature2.Feature2.Wish.*</ID>
</CurrentIssues>
</SmellBaseline>
15 changes: 15 additions & 0 deletions mvicore-demo/mvicore-demo-app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.2.2" type="baseline" client="gradle" dependencies="false" name="AGP (7.2.2)" variant="all" version="7.2.2">

<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
errorLine1=" targetSdkVersion 31"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="14"
column="9"/>
</issue>

</issues>
5 changes: 5 additions & 0 deletions mvicore-demo/mvicore-demo-app/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="ContentDescription" severity="ignore" />
<issue id="HardcodedText" severity="ignore" />
</lint>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.badoo.mvicoredemo.ui.lifecycle

import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
Expand All @@ -14,12 +13,13 @@ import com.badoo.mvicoredemo.databinding.ActivityLifecycleDemoBinding
import init
import io.reactivex.functions.Consumer
import io.reactivex.subjects.PublishSubject
import timber.log.Timber

class LifecycleDemoActivity : AppCompatActivity() {

private val events = PublishSubject.create<String>()
private val dummyConsumer = Consumer<String> {
Log.d("LifecycleDemo", it)
Timber.tag("LifecycleDemo").d(it)
}
private lateinit var binding: ActivityLifecycleDemoBinding

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/main_drawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/main_drawer_menu"/>
</androidx.drawerlayout.widget.DrawerLayout>
3 changes: 0 additions & 3 deletions mvicore-demo/mvicore-demo-app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
<color name="colorPrimary">@color/grey_800</color>
<color name="colorPrimaryDark">@color/grey_900</color>
<color name="colorAccent">#FF4081</color>

<color name="darkYellow">#a3951a</color>
<color name="darkLime">#778c20</color>
</resources>
Loading

0 comments on commit 6387107

Please sign in to comment.