From d5f06968eb401babcb929fd25e6cbb2e1ffda1d6 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 27 Jan 2023 21:29:58 +0330 Subject: [PATCH] Replacing Spotless with Ktlint --- .github/workflows/android_build.yml | 2 +- .../watchlist/data/LightStreamerConnection.kt | 2 +- .../feature/watchlist/data/SubscriptionMode.kt | 6 +++--- .../feature/watchlist/presentation/StockList.kt | 2 +- .../watchlist/presentation/WatchlistScreen.kt | 1 - .../watchlist/presentation/WatchlistState.kt | 2 +- .../dev/garousi/stockwatcher/ui/StockWatcherApp.kt | 1 - .../dev/garousi/stockwatcher/ui/theme/Theme.kt | 2 +- build.gradle | 7 ++++--- buildscripts/ktlint.gradle | 14 ++++++++++++++ 10 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 buildscripts/ktlint.gradle diff --git a/.github/workflows/android_build.yml b/.github/workflows/android_build.yml index 0488908..2c295a0 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/android_build.yml @@ -24,4 +24,4 @@ jobs: run: ./gradlew assemble - name: Static Analysis - run: ./gradlew spotlessCheck detekt \ No newline at end of file + run: ./gradlew ktlintCheck detekt \ No newline at end of file diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt index bed5d5e..26738ae 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt @@ -1,4 +1,4 @@ -@file:Suppress("LongParameterList","TooManyFunctions") +@file:Suppress("LongParameterList", "TooManyFunctions") package dev.garousi.stockwatcher.feature.watchlist.data diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt index 892c7aa..ce6e560 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt @@ -1,7 +1,7 @@ @file:Suppress("UnusedPrivateMember") package dev.garousi.stockwatcher.feature.watchlist.data -enum class SubscriptionMode(mode: String) { - Merge("MERGE"), - Command("COMMAND"), +enum class SubscriptionMode { + Merge, + Command, } diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/StockList.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/StockList.kt index ece98d0..09fdf98 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/StockList.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/StockList.kt @@ -41,7 +41,7 @@ fun StockList( ) { itemsIndexed( items = stocks, - key = { index, item -> item.itemName }, + key = { _, item -> item.itemName }, ) { index, stock -> StockItem( stock = stock, diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistScreen.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistScreen.kt index 0321239..9e053de 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistScreen.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistScreen.kt @@ -28,7 +28,6 @@ import androidx.compose.material.primarySurface import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment.Companion.Center import androidx.compose.ui.Alignment.Companion.CenterVertically import androidx.compose.ui.Modifier diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistState.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistState.kt index 05cbd6b..520e108 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistState.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistState.kt @@ -1,4 +1,4 @@ -@file:Suppress("MagicNumber","ForEachOnRange") +@file:Suppress("MagicNumber", "ForEachOnRange") package dev.garousi.stockwatcher.feature.watchlist.presentation import dev.garousi.stockwatcher.feature.watchlist.domain.models.Stock diff --git a/app/src/main/java/dev/garousi/stockwatcher/ui/StockWatcherApp.kt b/app/src/main/java/dev/garousi/stockwatcher/ui/StockWatcherApp.kt index 41d22c0..3a5941f 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/ui/StockWatcherApp.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/ui/StockWatcherApp.kt @@ -33,7 +33,6 @@ fun StockWatcherApp( testTagsAsResourceId = true }, bottomBar = { - }, ) { padding -> Row( diff --git a/app/src/main/java/dev/garousi/stockwatcher/ui/theme/Theme.kt b/app/src/main/java/dev/garousi/stockwatcher/ui/theme/Theme.kt index d147fed..4edd93d 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/ui/theme/Theme.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/ui/theme/Theme.kt @@ -1,4 +1,4 @@ -@file:Suppress("MagicNumber","FunctionNaming") +@file:Suppress("MagicNumber", "FunctionNaming") package dev.garousi.stockwatcher.ui.theme import androidx.compose.foundation.isSystemInDarkTheme diff --git a/build.gradle b/build.gradle index 4098ff8..df828ac 100644 --- a/build.gradle +++ b/build.gradle @@ -9,12 +9,13 @@ plugins { id 'org.jetbrains.kotlin.android' version '1.7.20' apply false id 'com.google.dagger.hilt.android' version '2.44.2' apply false id "com.github.ben-manes.versions" version "0.44.0" - id "com.diffplug.spotless" version "6.12.1" +// id "com.diffplug.spotless" version "6.12.1" id "io.gitlab.arturbosch.detekt" version "1.22.0" + id "org.jlleitschuh.gradle.ktlint" version "10.2.0" } subprojects { - apply from: "../buildscripts/versionsplugin.gradle" - apply from: "../buildscripts/spotless.gradle" + apply from: "../buildscripts/ktlint.gradle" apply from: "../buildscripts/detekt.gradle" + apply from: "../buildscripts/versionsplugin.gradle" } \ No newline at end of file diff --git a/buildscripts/ktlint.gradle b/buildscripts/ktlint.gradle new file mode 100644 index 0000000..c706b57 --- /dev/null +++ b/buildscripts/ktlint.gradle @@ -0,0 +1,14 @@ +apply plugin: "org.jlleitschuh.gradle.ktlint" + +ktlint { + // https://github.com/pinterest/ktlint/releases + version = "0.45.2" + + reporters { + reporter "plain" + reporter "checkstyle" + reporter "html" + } + + outputColorName = "RED" +} \ No newline at end of file