Skip to content

properly use settings to determine which kinds of depth output to create #647

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

Merged
merged 2 commits into from
May 15, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>()
"-opt-in=kotlin.ExperimentalStdlibApi",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.anvil.AnvilFactoryParser
import modulecheck.core.anvil.CouldUseAnvilFinding
import modulecheck.finding.FindingName
Expand All @@ -31,7 +31,7 @@ class AnvilFactoryRule : DocumentedRule<CouldUseAnvilFinding>() {
return AnvilFactoryParser.parse(name, project)
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.anvilFactoryGeneration
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.anvilFactoryGeneration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package modulecheck.core.rule

import modulecheck.api.DepthFinding
import modulecheck.api.context.depthForSourceSetName
import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.finding.FindingName
import modulecheck.project.McProject
import modulecheck.rule.ReportOnlyRule
Expand All @@ -43,7 +43,9 @@ class DepthRule : DocumentedRule<DepthFinding>(), ReportOnlyRule<DepthFinding> {
}
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.depths
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.depths ||
settings.reports.depths.enabled ||
settings.reports.graphs.enabled
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import modulecheck.api.context.androidResourceDeclaredNamesForSourceSetName
import modulecheck.api.context.androidResourceReferencesForSourceSetName
import modulecheck.api.context.dependents
import modulecheck.api.context.referencesForSourceSetName
import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.rule.android.UnusedResourcesGenerationFinding
import modulecheck.finding.FindingName
import modulecheck.parsing.gradle.model.AndroidPlatformPlugin.AndroidLibraryPlugin
Expand Down Expand Up @@ -95,7 +95,7 @@ class DisableAndroidResourcesRule : DocumentedRule<UnusedResourcesGenerationFind
return findingList()
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.disableAndroidResources
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.disableAndroidResources
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package modulecheck.core.rule
import modulecheck.api.context.androidDataBindingDeclarationsForSourceSetName
import modulecheck.api.context.dependents
import modulecheck.api.context.referencesForSourceSetName
import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.rule.android.DisableViewBindingGenerationFinding
import modulecheck.finding.FindingName
import modulecheck.project.McProject
Expand Down Expand Up @@ -93,7 +93,7 @@ class DisableViewBindingRule : DocumentedRule<DisableViewBindingGenerationFindin
)
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.disableViewBinding
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.disableViewBinding
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package modulecheck.core.rule

import kotlinx.coroutines.flow.toList
import modulecheck.api.context.classpathDependencies
import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.InheritedDependencyFinding
import modulecheck.core.context.asApiOrImplementation
import modulecheck.core.internal.uses
Expand Down Expand Up @@ -223,7 +223,7 @@ class InheritedDependencyRule : DocumentedRule<InheritedDependencyFinding>() {
}
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.inheritedDependency
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.inheritedDependency
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MultiRuleFindingFactory(
.sortedBy { it.first }
.map { it.second }

return rules.filter { predicate(it) && it.shouldApply(settings.checks) }
return rules.filter { predicate(it) && it.shouldApply(settings) }
.flatMap { rule ->
sortedProjects.mapAsync { project ->
rule.check(project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.MustBeApiFinding
import modulecheck.core.context.MustBeApi
import modulecheck.finding.FindingName
Expand Down Expand Up @@ -43,7 +43,7 @@ class MustBeApiRule : DocumentedRule<MustBeApiFinding>() {
}
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.mustBeApi
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.mustBeApi
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.OverShotDependencyFinding
import modulecheck.core.context.overshotDependencies
Expand All @@ -38,7 +37,7 @@ class OverShotDependencyRule(
.map { it.toFinding(name) }
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.overShotDependency
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.overShotDependency
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.RedundantDependencyFinding
import modulecheck.core.context.RedundantDependencies
import modulecheck.finding.FindingName
Expand All @@ -35,7 +35,7 @@ class RedundantRule : DocumentedRule<RedundantDependencyFinding>() {
.map { it.toFinding(findingName = name) }
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.redundantDependency
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.redundantDependency
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.rule.sort.SortDependenciesFinding
import modulecheck.core.rule.sort.sortedDependenciesFileText
Expand Down Expand Up @@ -73,7 +72,7 @@ class SortDependenciesRule(
}
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.sortDependencies
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.sortDependencies
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.rule.sort.SortPluginsFinding
import modulecheck.core.rule.sort.sortedPlugins
Expand Down Expand Up @@ -74,7 +73,7 @@ class SortPluginsRule(
}
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.sortPlugins
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.sortPlugins
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.UnusedDependencyFinding
import modulecheck.core.context.UnusedDependencies
Expand All @@ -37,7 +36,7 @@ class UnusedDependencyRule(
.map { it.toFinding(name) }
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.unusedDependency
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.unusedDependency
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package modulecheck.core.rule

import modulecheck.api.context.kaptDependencies
import modulecheck.config.ChecksSettings
import modulecheck.config.CodeGeneratorBinding
import modulecheck.config.ModuleCheckSettings
import modulecheck.config.asMap
Expand Down Expand Up @@ -84,7 +83,7 @@ class UnusedKaptPluginRule(
}
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.unusedKapt
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.unusedKapt
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

package modulecheck.core.rule

import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.context.unusedKaptProcessors
import modulecheck.finding.Finding
Expand All @@ -39,7 +38,7 @@ class UnusedKaptProcessorRule(
return project.unusedKaptProcessors().all(settings)
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.unusedKapt
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.unusedKapt
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package modulecheck.core.rule

import modulecheck.api.context.referencesForSourceSetName
import modulecheck.config.ChecksSettings
import modulecheck.config.ModuleCheckSettings
import modulecheck.core.UnusedPluginFinding
import modulecheck.finding.FindingName
import modulecheck.parsing.gradle.model.PluginDefinition
Expand Down Expand Up @@ -66,7 +66,7 @@ class UnusedKotlinAndroidExtensionsRule : DocumentedRule<UnusedPluginFinding>()
)
}

override fun shouldApply(checksSettings: ChecksSettings): Boolean {
return checksSettings.unusedKotlinAndroidExtensions
override fun shouldApply(settings: ModuleCheckSettings): Boolean {
return settings.checks.unusedKotlinAndroidExtensions
}
}
Loading