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

Dependency updates + Detekt #361

Merged
merged 8 commits into from
May 5, 2021
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
75 changes: 51 additions & 24 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.benmanes.gradle.versions.updates.gradle.GradleReleaseChannel
import io.gitlab.arturbosch.detekt.Detekt

plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
id("kotlin-parcelize")
id("io.gitlab.arturbosch.detekt") version Dependencies.Versions.detekt
id("de.mannodermaus.android-junit5")
id("com.github.ben-manes.versions") version Dependencies.Versions.dependencyUpdates
}

detekt {
buildUponDefaultConfig = true
nielsvanvelzen marked this conversation as resolved.
Show resolved Hide resolved
allRules = false
config = files("${rootProject.projectDir}/detekt.yml")
ignoreFailures = true

reports {
html.enabled = true
xml.enabled = false
txt.enabled = true
nielsvanvelzen marked this conversation as resolved.
Show resolved Hide resolved
sarif.enabled = true
}
}

android {
compileSdkVersion(30)
defaultConfig {
Expand Down Expand Up @@ -61,15 +77,12 @@ android {
buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
lintOptions {
isAbortOnError = false
sarifReport = true
disable("MissingTranslation", "ExtraTranslation")
}
}
Expand Down Expand Up @@ -145,31 +158,45 @@ dependencies {
androidTestImplementation(Dependencies.Health.androidXEspresso)
}

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
tasks {
withType<Detekt> {
jvmTarget = JavaVersion.VERSION_1_8.toString()
nielsvanvelzen marked this conversation as resolved.
Show resolved Hide resolved
}
}

tasks.withType<DependencyUpdatesTask> {
gradleReleaseChannel = GradleReleaseChannel.CURRENT.id
rejectVersionIf {
val currentType = classifyVersion(currentVersion)
val candidateType = classifyVersion(candidate.version)
// Testing
withType<Test> {
useJUnitPlatform()
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
}
}

(currentType == VersionType.STABLE && candidateType != VersionType.STABLE) ||
(currentType == VersionType.MILESTONE && candidateType == VersionType.UNSTABLE)
// Configure dependency updates task
withType<DependencyUpdatesTask> {
gradleReleaseChannel = GradleReleaseChannel.CURRENT.id
rejectVersionIf {
val currentType = classifyVersion(currentVersion)
val candidateType = classifyVersion(candidate.version)

when (candidateType) {
// Always accept stable updates
VersionType.STABLE -> true
// Accept milestone updates for current milestone and unstable
VersionType.MILESTONE -> currentType != VersionType.STABLE
// Only accept unstable for current unstable
VersionType.UNSTABLE -> currentType == VersionType.UNSTABLE
}.not()
}
}
}

tasks.register("versionTxt") {
val path = buildDir.resolve("version.txt")
register("versionTxt") {
val path = buildDir.resolve("version.txt")

doLast {
val versionString = "v${android.defaultConfig.versionName}=${android.defaultConfig.versionCode}"
println("Writing [$versionString] to $path")
path.writeText("$versionString\n")
doLast {
val versionString = "v${android.defaultConfig.versionName}=${android.defaultConfig.versionCode}"
println("Writing [$versionString] to $path")
path.writeText("$versionString\n")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.jellyfin.mobile.model.sql.entity.UserEntity.Key.TABLE_NAME
import org.jellyfin.mobile.model.sql.entity.UserEntity.Key.USER_ID

@Dao
@Suppress("TooManyFunctions")
interface UserDao {
@Insert(onConflict = OnConflictStrategy.ABORT)
fun insert(entity: UserEntity): Long
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SettingsFragment : Fragment() {
requireMainActivity().setSupportActionBar(null)
}

@Suppress("LongMethod")
private fun buildSettingsScreen() = screen(requireContext()) {
collapseIcon = true
categoryHeader(PREF_CATEGORY_MUSIC_PLAYER) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
dependencies {
val kotlinVersion: String by project
classpath("com.android.tools.build:gradle:4.1.3")
classpath("com.android.tools.build:gradle:4.2.0")
classpath(kotlin("gradle-plugin", kotlinVersion))
classpath("de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1")
}
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ object Dependencies {
object Versions {
// Gradle plugins
const val dependencyUpdates = "0.38.0"
const val detekt = "1.17.0-RC2"

// KotlinX
const val coroutines = "1.4.3"
Expand Down
29 changes: 29 additions & 0 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
build:
maxIssues: 0

complexity:
ComplexMethod:
ignoreSimpleWhenEntries: true
LongParameterList:
constructorThreshold: 10
functionThreshold: 10
TooManyFunctions:
thresholdInFiles: 16
thresholdInClasses: 16
thresholdInInterfaces: 8
thresholdInObjects: 16
thresholdInEnums: 8
ignoreOverridden: true
ignoreDeprecated: true

naming:
PackageNaming:
# Package names must be lowercase letters
packagePattern: '[a-z]+(\.[a-z]+)*'

style:
ForbiddenComment:
# Allow TODOs
values: [ 'FIXME:', 'STOPSHIP:' ]
MaxLineLength:
maxLineLength: 200