Skip to content
Open
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ antlr-shadowed = "4.13.2.0"
asm-relocated = "9.7.1.0"
caffeine = "3.1.8"
commons-io = "2.16.0"
dagp = "2.4.2"
dagp = "2.16.0"
error-prone = "2.26.1"
gradle-publish-plugin = "1.1.0"
grammar = "0.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ final class ReasonSpec extends AbstractAndroidSpec {
"""\
----------------------------------------
You asked about the Android score for ':proj'.
There was no Android-related module structure advice for this project. It uses several Android features.
There was no Android-related module structure advice for this project. It uses at least one Android feature.
----------------------------------------

Android features:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ internal class ProjectHealthConsoleReportBuilder(

moduleAdvice.forEach { m ->
when (m) {
is AndroidScore -> if (m.couldBeJvm()) append(m.text())
is AndroidScore -> if (m.shouldBeJvm()) append(m.text())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,8 @@ internal class ModuleAdviceExplainer(
"You have been advised to change this project from an Android project to a JVM project. No use of any " +
"Android feature was detected."
)
finalAndroidScore.couldBeJvm() -> append(
"You have been advised to change this project from an Android project to a JVM project. Only limited use " +
"of Android feature was detected."
)
else -> append(
"There was no Android-related module structure advice for this project. It uses several Android features."
"There was no Android-related module structure advice for this project. It uses at least one Android feature."
)
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/main/kotlin/com/autonomousapps/model/ModuleAdvice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ data class AndroidScore(
/** True if this project uses no Android facilities at all. */
fun shouldBeJvm(): Boolean = score == 0f

/** True if this project only uses some limited number of Android facilities. */
fun couldBeJvm(): Boolean = score < THRESHOLD

override fun isActionable(): Boolean = couldBeJvm()
override fun isActionable(): Boolean = shouldBeJvm()

internal companion object {
private const val THRESHOLD = 2f

fun ofVariants(scores: Collection<AndroidScoreVariant>): AndroidScore? {
// JVM projects don't have an AndroidScore
if (scores.isEmpty()) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ abstract class GenerateBuildHealthTask : DefaultTask() {
projectAdvice.moduleAdvice.filterIsInstance<AndroidScore>().forEach {
if (it.shouldBeJvm()) {
androidMetricsBuilder.shouldBeJvmCount++
} else if (it.couldBeJvm()) {
androidMetricsBuilder.couldBeJvmCount++
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ internal class ModuleAdviceExplainerTest {
).inOrder()
}

@Test fun `can explain there is little reason for this to be an Android project`() {
@Test fun `can explain there is at least one reason for this to be an Android project`() {
// Given
val score = Fixture.emptyScore.copy(
hasBuildConfig = true,
hasAndroidDependencies = true
)
val computer = Fixture(
Expand All @@ -47,14 +46,13 @@ internal class ModuleAdviceExplainerTest {
// Then
assertThat(reason.decolorize().lines()).containsExactlyElementsIn(
"""

----------------------------------------
You asked about the Android score for ':root'.
You have been advised to change this project from an Android project to a JVM project. Only limited use of Android feature was detected.
There was no Android-related module structure advice for this project. It uses at least one Android feature.
----------------------------------------

Android features:
* Includes BuildConfig.
* Has Android library dependencies.
""".trimIndent().lines()
).inOrder()
Expand Down