Skip to content

Commit e20cdaa

Browse files
committed
properly use settings to determine which kinds of depth output to create
fixes #576
1 parent 5cb7c44 commit e20cdaa

File tree

27 files changed

+231
-115
lines changed

27 files changed

+231
-115
lines changed

build-logic/mcbuild/src/main/kotlin/mcbuild.kotlin.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>()
3939
"-opt-in=kotlin.ExperimentalStdlibApi",
4040
"-opt-in=kotlin.RequiresOptIn",
4141
"-opt-in=kotlin.contracts.ExperimentalContracts",
42+
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
4243
"-opt-in=kotlinx.coroutines.FlowPreview"
4344
)
4445
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/AnvilFactoryRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
18+
import modulecheck.config.ModuleCheckSettings
1919
import modulecheck.core.anvil.AnvilFactoryParser
2020
import modulecheck.core.anvil.CouldUseAnvilFinding
2121
import modulecheck.finding.FindingName
@@ -31,7 +31,7 @@ class AnvilFactoryRule : DocumentedRule<CouldUseAnvilFinding>() {
3131
return AnvilFactoryParser.parse(name, project)
3232
}
3333

34-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
35-
return checksSettings.anvilFactoryGeneration
34+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
35+
return settings.checks.anvilFactoryGeneration
3636
}
3737
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/DepthRule.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package modulecheck.core.rule
1717

1818
import modulecheck.api.DepthFinding
1919
import modulecheck.api.context.depthForSourceSetName
20-
import modulecheck.config.ChecksSettings
20+
import modulecheck.config.ModuleCheckSettings
2121
import modulecheck.finding.FindingName
2222
import modulecheck.project.McProject
2323
import modulecheck.rule.ReportOnlyRule
@@ -43,7 +43,9 @@ class DepthRule : DocumentedRule<DepthFinding>(), ReportOnlyRule<DepthFinding> {
4343
}
4444
}
4545

46-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
47-
return checksSettings.depths
46+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
47+
return settings.checks.depths ||
48+
settings.reports.depths.enabled ||
49+
settings.reports.graphs.enabled
4850
}
4951
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/DisableAndroidResourcesRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import modulecheck.api.context.androidResourceDeclaredNamesForSourceSetName
2121
import modulecheck.api.context.androidResourceReferencesForSourceSetName
2222
import modulecheck.api.context.dependents
2323
import modulecheck.api.context.referencesForSourceSetName
24-
import modulecheck.config.ChecksSettings
24+
import modulecheck.config.ModuleCheckSettings
2525
import modulecheck.core.rule.android.UnusedResourcesGenerationFinding
2626
import modulecheck.finding.FindingName
2727
import modulecheck.parsing.gradle.model.AndroidPlatformPlugin.AndroidLibraryPlugin
@@ -95,7 +95,7 @@ class DisableAndroidResourcesRule : DocumentedRule<UnusedResourcesGenerationFind
9595
return findingList()
9696
}
9797

98-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
99-
return checksSettings.disableAndroidResources
98+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
99+
return settings.checks.disableAndroidResources
100100
}
101101
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/DisableViewBindingRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package modulecheck.core.rule
1818
import modulecheck.api.context.androidDataBindingDeclarationsForSourceSetName
1919
import modulecheck.api.context.dependents
2020
import modulecheck.api.context.referencesForSourceSetName
21-
import modulecheck.config.ChecksSettings
21+
import modulecheck.config.ModuleCheckSettings
2222
import modulecheck.core.rule.android.DisableViewBindingGenerationFinding
2323
import modulecheck.finding.FindingName
2424
import modulecheck.project.McProject
@@ -93,7 +93,7 @@ class DisableViewBindingRule : DocumentedRule<DisableViewBindingGenerationFindin
9393
)
9494
}
9595

96-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
97-
return checksSettings.disableViewBinding
96+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
97+
return settings.checks.disableViewBinding
9898
}
9999
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/InheritedDependencyRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package modulecheck.core.rule
1717

1818
import kotlinx.coroutines.flow.toList
1919
import modulecheck.api.context.classpathDependencies
20-
import modulecheck.config.ChecksSettings
20+
import modulecheck.config.ModuleCheckSettings
2121
import modulecheck.core.InheritedDependencyFinding
2222
import modulecheck.core.context.asApiOrImplementation
2323
import modulecheck.core.internal.uses
@@ -223,7 +223,7 @@ class InheritedDependencyRule : DocumentedRule<InheritedDependencyFinding>() {
223223
}
224224
}
225225

226-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
227-
return checksSettings.inheritedDependency
226+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
227+
return settings.checks.inheritedDependency
228228
}
229229
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/MultiRuleFindingFactory.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class MultiRuleFindingFactory(
103103
.sortedBy { it.first }
104104
.map { it.second }
105105

106-
return rules.filter { predicate(it) && it.shouldApply(settings.checks) }
106+
return rules.filter { predicate(it) && it.shouldApply(settings) }
107107
.flatMap { rule ->
108108
sortedProjects.mapAsync { project ->
109109
rule.check(project)

modulecheck-core/src/main/kotlin/modulecheck/core/rule/MustBeApiRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
18+
import modulecheck.config.ModuleCheckSettings
1919
import modulecheck.core.MustBeApiFinding
2020
import modulecheck.core.context.MustBeApi
2121
import modulecheck.finding.FindingName
@@ -43,7 +43,7 @@ class MustBeApiRule : DocumentedRule<MustBeApiFinding>() {
4343
}
4444
}
4545

46-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
47-
return checksSettings.mustBeApi
46+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
47+
return settings.checks.mustBeApi
4848
}
4949
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/OverShotDependencyRule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
1918
import modulecheck.config.ModuleCheckSettings
2019
import modulecheck.core.OverShotDependencyFinding
2120
import modulecheck.core.context.overshotDependencies
@@ -38,7 +37,7 @@ class OverShotDependencyRule(
3837
.map { it.toFinding(name) }
3938
}
4039

41-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
42-
return checksSettings.overShotDependency
40+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
41+
return settings.checks.overShotDependency
4342
}
4443
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/RedundantRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
18+
import modulecheck.config.ModuleCheckSettings
1919
import modulecheck.core.RedundantDependencyFinding
2020
import modulecheck.core.context.RedundantDependencies
2121
import modulecheck.finding.FindingName
@@ -35,7 +35,7 @@ class RedundantRule : DocumentedRule<RedundantDependencyFinding>() {
3535
.map { it.toFinding(findingName = name) }
3636
}
3737

38-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
39-
return checksSettings.redundantDependency
38+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
39+
return settings.checks.redundantDependency
4040
}
4141
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/SingleRuleFindingFactory.kt

-61
This file was deleted.

modulecheck-core/src/main/kotlin/modulecheck/core/rule/SortDependenciesRule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
1918
import modulecheck.config.ModuleCheckSettings
2019
import modulecheck.core.rule.sort.SortDependenciesFinding
2120
import modulecheck.core.rule.sort.sortedDependenciesFileText
@@ -73,7 +72,7 @@ class SortDependenciesRule(
7372
}
7473
}
7574

76-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
77-
return checksSettings.sortDependencies
75+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
76+
return settings.checks.sortDependencies
7877
}
7978
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/SortPluginsRule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
1918
import modulecheck.config.ModuleCheckSettings
2019
import modulecheck.core.rule.sort.SortPluginsFinding
2120
import modulecheck.core.rule.sort.sortedPlugins
@@ -74,7 +73,7 @@ class SortPluginsRule(
7473
}
7574
}
7675

77-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
78-
return checksSettings.sortPlugins
76+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
77+
return settings.checks.sortPlugins
7978
}
8079
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/UnusedDependencyRule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
1918
import modulecheck.config.ModuleCheckSettings
2019
import modulecheck.core.UnusedDependencyFinding
2120
import modulecheck.core.context.UnusedDependencies
@@ -37,7 +36,7 @@ class UnusedDependencyRule(
3736
.map { it.toFinding(name) }
3837
}
3938

40-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
41-
return checksSettings.unusedDependency
39+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
40+
return settings.checks.unusedDependency
4241
}
4342
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/UnusedKaptPluginRule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package modulecheck.core.rule
1717

1818
import modulecheck.api.context.kaptDependencies
19-
import modulecheck.config.ChecksSettings
2019
import modulecheck.config.CodeGeneratorBinding
2120
import modulecheck.config.ModuleCheckSettings
2221
import modulecheck.config.asMap
@@ -84,7 +83,7 @@ class UnusedKaptPluginRule(
8483
}
8584
}
8685

87-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
88-
return checksSettings.unusedKapt
86+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
87+
return settings.checks.unusedKapt
8988
}
9089
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/UnusedKaptProcessorRule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
package modulecheck.core.rule
1717

18-
import modulecheck.config.ChecksSettings
1918
import modulecheck.config.ModuleCheckSettings
2019
import modulecheck.core.context.unusedKaptProcessors
2120
import modulecheck.finding.Finding
@@ -39,7 +38,7 @@ class UnusedKaptProcessorRule(
3938
return project.unusedKaptProcessors().all(settings)
4039
}
4140

42-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
43-
return checksSettings.unusedKapt
41+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
42+
return settings.checks.unusedKapt
4443
}
4544
}

modulecheck-core/src/main/kotlin/modulecheck/core/rule/UnusedKotlinAndroidExtensionsRule.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package modulecheck.core.rule
1717

1818
import modulecheck.api.context.referencesForSourceSetName
19-
import modulecheck.config.ChecksSettings
19+
import modulecheck.config.ModuleCheckSettings
2020
import modulecheck.core.UnusedPluginFinding
2121
import modulecheck.finding.FindingName
2222
import modulecheck.parsing.gradle.model.PluginDefinition
@@ -66,7 +66,7 @@ class UnusedKotlinAndroidExtensionsRule : DocumentedRule<UnusedPluginFinding>()
6666
)
6767
}
6868

69-
override fun shouldApply(checksSettings: ChecksSettings): Boolean {
70-
return checksSettings.unusedKotlinAndroidExtensions
69+
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
70+
return settings.checks.unusedKotlinAndroidExtensions
7171
}
7272
}

0 commit comments

Comments
 (0)