Skip to content

delete ConfiguredModule #609

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 1 commit into from
May 12, 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 @@ -16,7 +16,6 @@
package modulecheck.finding

import modulecheck.parsing.gradle.dsl.HasBuildFile
import modulecheck.parsing.gradle.model.ConfiguredProjectDependency
import modulecheck.parsing.gradle.model.Dependency
import modulecheck.parsing.gradle.model.PluginDependency
import modulecheck.project.HasProjectCache
Expand Down Expand Up @@ -54,13 +53,7 @@ suspend fun <T> T.getSuppressions(): Suppressions
.map { it.allSuppressions }
.fold(mutableMapOf<Dependency, MutableSet<FindingName>>()) { acc, block ->

block.forEach { (configuredModule, newNames) ->

val cpd = ConfiguredProjectDependency(
configuredModule.configName,
configuredModule.projectPath,
configuredModule.testFixtures
)
block.forEach { (cpd, newNames) ->

val cachedNames = acc.getOrPut(cpd) { mutableSetOf() }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
package modulecheck.parsing.gradle.dsl

import modulecheck.finding.FindingName
import modulecheck.parsing.gradle.dsl.DependenciesBlock.ConfiguredModule
import modulecheck.parsing.gradle.model.ConfigurationName
import modulecheck.parsing.gradle.model.ConfiguredProjectDependency
import modulecheck.parsing.gradle.model.MavenCoordinates
import modulecheck.parsing.gradle.model.ProjectPath

interface DependenciesBlock :
Block<DependencyDeclaration>,
HasSuppressedChildren<ConfiguredModule, FindingName> {
HasSuppressedChildren<ConfiguredProjectDependency, FindingName> {

fun getOrEmpty(
moduleRef: String,
Expand All @@ -41,12 +41,6 @@ interface DependenciesBlock :
mavenCoordinates: MavenCoordinates,
configName: ConfigurationName
): List<ExternalDependencyDeclaration>

data class ConfiguredModule(
val configName: ConfigurationName,
val projectPath: ProjectPath,
val testFixtures: Boolean
)
}

interface DependenciesBlocksProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package modulecheck.parsing.gradle.dsl.internal
import modulecheck.finding.FindingName
import modulecheck.finding.FindingName.Companion.migrateLegacyIdOrNull
import modulecheck.parsing.gradle.dsl.DependenciesBlock
import modulecheck.parsing.gradle.dsl.DependenciesBlock.ConfiguredModule
import modulecheck.parsing.gradle.dsl.DependencyDeclaration
import modulecheck.parsing.gradle.dsl.DependencyDeclaration.ConfigurationNameTransform
import modulecheck.parsing.gradle.dsl.ExternalDependencyDeclaration
Expand All @@ -27,6 +26,7 @@ import modulecheck.parsing.gradle.dsl.ModuleDependencyDeclaration
import modulecheck.parsing.gradle.dsl.ProjectAccessor
import modulecheck.parsing.gradle.dsl.UnknownDependencyDeclaration
import modulecheck.parsing.gradle.model.ConfigurationName
import modulecheck.parsing.gradle.model.ConfiguredProjectDependency
import modulecheck.parsing.gradle.model.MavenCoordinates
import modulecheck.parsing.gradle.model.ProjectPath
import modulecheck.parsing.gradle.model.ProjectPath.StringProjectPath
Expand All @@ -46,8 +46,8 @@ abstract class AbstractDependenciesBlock(

val suppressedForEntireBlock = suppressedForEntireBlock.updateOldSuppresses()

override val allSuppressions: Map<ConfiguredModule, Set<FindingName>> by resetManager.lazyResets {
buildMap<ConfiguredModule, MutableSet<FindingName>> {
override val allSuppressions: Map<ConfiguredProjectDependency, Set<FindingName>> by resetManager.lazyResets {
buildMap<ConfiguredProjectDependency, MutableSet<FindingName>> {

allModuleDeclarations.forEach { (configuredModule, declarations) ->

Expand Down Expand Up @@ -76,7 +76,7 @@ abstract class AbstractDependenciesBlock(
mutableMapOf<MavenCoordinates, MutableList<ExternalDependencyDeclaration>>()

private val allModuleDeclarations =
mutableMapOf<ConfiguredModule, MutableList<ModuleDependencyDeclaration>>()
mutableMapOf<ConfiguredProjectDependency, MutableList<ModuleDependencyDeclaration>>()

fun addNonModuleStatement(
configName: ConfigurationName,
Expand Down Expand Up @@ -134,10 +134,10 @@ abstract class AbstractDependenciesBlock(

val isTestFixtures = parsedString.contains(testFixturesRegex)

val cm = ConfiguredModule(
configName = configName,
projectPath = projectPath,
testFixtures = isTestFixtures
val cpd = ConfiguredProjectDependency(
configurationName = configName,
path = projectPath,
isTestFixture = isTestFixtures
)

val originalString = getOriginalString(parsedString)
Expand All @@ -152,7 +152,7 @@ abstract class AbstractDependenciesBlock(
configurationNameTransform = configurationNameTransform
)

allModuleDeclarations.getOrPut(cm) { mutableListOf() }
allModuleDeclarations.getOrPut(cpd) { mutableListOf() }
.add(declaration)

_allDeclarations.add(declaration)
Expand Down Expand Up @@ -185,9 +185,13 @@ abstract class AbstractDependenciesBlock(
testFixtures: Boolean
): List<ModuleDependencyDeclaration> {

return allModuleDeclarations[ConfiguredModule(configName, moduleRef, testFixtures)]
?: allModuleDeclarations[ConfiguredModule(configName, moduleRef.toTypeSafe(), testFixtures)]
?: emptyList()
return allModuleDeclarations[
ConfiguredProjectDependency(
configurationName = configName,
path = moduleRef,
isTestFixture = testFixtures
)
].orEmpty()
}

override fun getOrEmpty(
Expand Down