Skip to content

Commit e4bfce0

Browse files
authored
refactor(build): simplify lint, spotless, and detekt configurations (#3133)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
1 parent df90256 commit e4bfce0

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

.github/workflows/reusable-android-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
echo "datadogApplicationId=$DATADOG_APPLICATION_ID" >> ./secrets.properties
7070
echo "datadogClientToken=$DATADOG_CLIENT_TOKEN" >> ./secrets.properties
7171
- name: Run Spotless, Detekt, Build, Lint, and Local Tests
72-
run: ./gradlew :app:spotlessCheck :app:detekt :app:lintFdroidDebug :app:lintGoogleDebug :app:assembleDebug koverXmlReport --configuration-cache --scan
72+
run: ./gradlew spotlessCheck detekt lintDebug :app:assembleDebug koverXmlReport --configuration-cache --scan
7373
env:
7474
VERSION_CODE: ${{ env.VERSION_CODE }}
7575

build-logic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import org.gradle.api.Plugin
2222
import org.gradle.api.Project
2323
import org.gradle.kotlin.dsl.apply
2424
import org.gradle.kotlin.dsl.configure
25-
import java.io.File
2625

2726
class AndroidLintConventionPlugin : Plugin<Project> {
2827
override fun apply(target: Project) {
@@ -49,6 +48,4 @@ private fun Lint.configure(project: Project) {
4948
checkDependencies = true
5049
abortOnError = false
5150
disable += "GradleDependency"
52-
sarifOutput = File("${project.layout.buildDirectory}/reports/lint/lint-results.sarif")
53-
xmlOutput = File("${project.layout.buildDirectory}/reports/lint/lint-results.xml")
5451
}

build-logic/convention/src/main/kotlin/DetektConventionPlugin.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.geeksville.mesh.buildlogic.configureDetekt
2+
import com.geeksville.mesh.buildlogic.configureKotlinJvm
23
import com.geeksville.mesh.buildlogic.libs
34
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
45
import org.gradle.api.Plugin
@@ -9,6 +10,7 @@ import org.gradle.kotlin.dsl.getByType
910
class DetektConventionPlugin : Plugin<Project> {
1011
override fun apply(target: Project) {
1112
with(target) {
13+
configureKotlinJvm()
1214
apply(plugin = libs.findPlugin("detekt").get().get().pluginId)
1315
val extension = extensions.getByType<DetektExtension>()
1416
configureDetekt(extension)

build-logic/convention/src/main/kotlin/SpotlessConventionPlugin.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
2+
import com.geeksville.mesh.buildlogic.configureKotlinJvm
23
import com.geeksville.mesh.buildlogic.configureSpotless
34
import com.geeksville.mesh.buildlogic.libs
45
import org.gradle.api.Plugin
@@ -9,6 +10,7 @@ import org.gradle.kotlin.dsl.getByType
910
class SpotlessConventionPlugin : Plugin<Project> {
1011
override fun apply(target: Project) {
1112
with(target) {
13+
configureKotlinJvm()
1214
apply(plugin = libs.findPlugin("spotless").get().get().pluginId)
1315
val extension = extensions.getByType<SpotlessExtension>()
1416
configureSpotless(extension)

mesh_service_example/src/main/kotlin/com/geeksville/mesh/util/Extensions.kt

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,16 @@ import android.widget.EditText
2121
import com.geeksville.mesh.ConfigProtos
2222

2323
/**
24-
* When printing strings to logs sometimes we want to print useful debugging information about users
25-
* or positions. But we don't want to leak things like usernames or locations. So this function
26-
* if given a string, will return a string which is a maximum of three characters long, taken from the tail
27-
* of the string. Which should effectively hide real usernames and locations,
28-
* but still let us see if values were zero, empty or different.
24+
* When printing strings to logs sometimes we want to print useful debugging information about users or positions. But
25+
* we don't want to leak things like usernames or locations. So this function if given a string, will return a string
26+
* which is a maximum of three characters long, taken from the tail of the string. Which should effectively hide real
27+
* usernames and locations, but still let us see if values were zero, empty or different.
2928
*/
3029
val Any?.anonymize: String
3130
get() = this.anonymize()
3231

33-
/**
34-
* A version of anonymize that allows passing in a custom minimum length
35-
*/
36-
fun Any?.anonymize(maxLen: Int = 3) =
37-
if (this != null) ("..." + this.toString().takeLast(maxLen)) else "null"
32+
/** A version of anonymize that allows passing in a custom minimum length */
33+
fun Any?.anonymize(maxLen: Int = 3) = if (this != null) ("..." + this.toString().takeLast(maxLen)) else "null"
3834

3935
// A toString that makes sure all newlines are removed (for nice logging).
4036
fun Any.toOneLineString() = this.toString().replace('\n', ' ')
@@ -66,7 +62,6 @@ fun formatAgo(lastSeenUnix: Int, currentTimeMillis: Long = System.currentTimeMil
6662
// Allows usage like email.onEditorAction(EditorInfo.IME_ACTION_NEXT, { confirm() })
6763
fun EditText.onEditorAction(actionId: Int, func: () -> Unit) {
6864
setOnEditorActionListener { _, receivedActionId, _ ->
69-
7065
if (actionId == receivedActionId) {
7166
func()
7267
}

0 commit comments

Comments
 (0)