diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/MissingVersionEntries.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/MissingVersionEntries.kt index 70f406f24..ce0aeadd0 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/MissingVersionEntries.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/MissingVersionEntries.kt @@ -14,20 +14,26 @@ fun addMissingEntriesInVersionsProperties(project: Project) { val versionsMap = RefreshVersionsConfigHolder.readVersionsMap() val versionKeyReader = RefreshVersionsConfigHolder.versionKeyReader + val newEntries: Map = findMissingEntries( configurations = configurationsWithHardcodedDependencies, versionsMap = versionsMap, versionKeyReader = versionKeyReader - ) + UsedPluginsTracker.usedPluginsWithoutEntryInVersionsFile - .associateBy { d -> pluginDependencyNotationToVersionKey(d.name) } - .filterKeys { key -> key != null && key !in versionsMap } - .mapKeys { (k, _) -> k!! } + ) + externalDependencyMap(UsedPluginsTracker.usedPluginsWithoutEntryInVersionsFile, versionsMap) VersionsPropertiesModel.writeWithNewEntries(newEntries) OutputFile.VERSIONS_PROPERTIES.logFileWasModified() } +@InternalRefreshVersionsApi +@FunctionalCore(testName = "TODO") +private fun externalDependencyMap(usedPluginsWithoutEntryInVersionsFile: List, versionsMap: Map) = + usedPluginsWithoutEntryInVersionsFile + .associateBy { d -> pluginDependencyNotationToVersionKey(d.name) } + .filterKeys { key -> key != null && key !in versionsMap } + .mapKeys { (k, _) -> k!! } + @InternalRefreshVersionsApi fun Configuration.countDependenciesWithHardcodedVersions( @@ -77,6 +83,7 @@ fun Configuration.shouldBeIgnored(): Boolean { // implementation, api, compileOnly, runtimeOnly, kapt, plus test, MPP and MPP test variants. } +@FunctionalCore(testName = "TODO") internal fun findMissingEntries( configurations: List, versionsMap: Map, diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ArtifactVersionKeysReading.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ArtifactVersionKeysReading.kt index 40c6edb4f..fed790f45 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ArtifactVersionKeysReading.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ArtifactVersionKeysReading.kt @@ -1,6 +1,7 @@ package de.fayard.refreshVersions.core.internal import de.fayard.refreshVersions.core.ModuleId +import java.io.File @InternalRefreshVersionsApi abstract class ArtifactVersionKeyReader private constructor( @@ -11,6 +12,7 @@ abstract class ArtifactVersionKeyReader private constructor( companion object { + @FunctionalCore(testName = "TODO") fun fromRules( filesContent: List, getRemovedDependenciesVersionsKeys: () -> Map = { emptyMap() } diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ConfigurationLessDependency.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ConfigurationLessDependency.kt index 5f77714fc..655b930f3 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ConfigurationLessDependency.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ConfigurationLessDependency.kt @@ -4,6 +4,7 @@ import de.fayard.refreshVersions.core.ModuleId import org.gradle.api.artifacts.Dependency import org.gradle.api.internal.artifacts.dependencies.AbstractDependency +@NeedsRefactoring("Simpler name and use it everywhere") internal class ConfigurationLessDependency( private val group: String, private val name: String, @@ -20,6 +21,7 @@ internal class ConfigurationLessDependency( ) companion object { + @FunctionalCore(testName = "TODO") operator fun invoke(dependencyNotation: String): ConfigurationLessDependency { val beforeFirstColon = dependencyNotation.substringBefore(':') val afterFirstColon = dependencyNotation.substringAfter(':') diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/DependencyNotations.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/DependencyNotations.kt index 2fc164bde..618bb60a1 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/DependencyNotations.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/DependencyNotations.kt @@ -30,6 +30,8 @@ val MEANING_LESS_NAMES: MutableList = mutableListOf( ) @InternalRefreshVersionsApi +@NeedsRefactoring("Use Dependency instead of Library") +@FunctionalCore(testName = "TODO") fun List.computeAliases( configured: List, byDefault: List = MEANING_LESS_NAMES @@ -71,6 +73,7 @@ fun Project.findDependencies(): List { @InternalRefreshVersionsApi +@NeedsRefactoring("Use Dependency instead") data class Library( val group: String = "", val module: String = "", @@ -102,6 +105,7 @@ data class Library( } @InternalRefreshVersionsApi +@NeedsRefactoring("Use Dependency instead") class Deps( val libraries: List, val names: Map @@ -114,6 +118,8 @@ enum class VersionMode { } @InternalRefreshVersionsApi +@NeedsRefactoring("Use Dependency instead of Library and Deps") +@FunctionalCore(testName = "TODO") fun List.checkModeAndNames(useFdqnByDefault: List, case: Case): Deps { val dependencies = this diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/FunctionalCore.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/FunctionalCore.kt new file mode 100644 index 000000000..3e2cb2dce --- /dev/null +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/FunctionalCore.kt @@ -0,0 +1,15 @@ +package de.fayard.refreshVersions.core.internal + +/** + * FunctionalCore/ImperativeShell is a simple but powerful testing strategy + * where you express your business logic as pure functions + * and you use the tested functions in a simple imperative shell that actually do things. + * + * In practical terms, a function annotated by @FunctionalCore must be tested + * + * See https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell + */ +@InternalRefreshVersionsApi +annotation class FunctionalCore( + val testName: String, +) diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/NeedsRefactoring.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/NeedsRefactoring.kt new file mode 100644 index 000000000..b8fdfbed4 --- /dev/null +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/NeedsRefactoring.kt @@ -0,0 +1,9 @@ +package de.fayard.refreshVersions.core.internal + +/** + * For refactorings we don't want to do right now but want to keep track of + */ +@InternalRefreshVersionsApi +annotation class NeedsRefactoring( + val issueAndMessage: String, +) diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/OutputFile.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/OutputFile.kt index 1c528afd6..05faa04f3 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/OutputFile.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/OutputFile.kt @@ -4,6 +4,7 @@ import de.fayard.refreshVersions.core.internal.VersionsCatalogs.LIBS_VERSIONS_TO import java.io.File @InternalRefreshVersionsApi +@NeedsRefactoring("Design a better API") enum class OutputFile( val path: String, var existed: Boolean = false, diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ResettableDelegates.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ResettableDelegates.kt index 2a009b8c5..8073d69ef 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ResettableDelegates.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/ResettableDelegates.kt @@ -3,6 +3,7 @@ package de.fayard.refreshVersions.core.internal import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty +@FunctionalCore(testName = "TODO") internal class ResettableDelegates { fun reset() { @@ -26,7 +27,7 @@ internal class ResettableDelegates { override fun getValue(thisRef: Any?, property: KProperty<*>): T = field ?: error( "Property ${property.name} not initialized yet! " + - "Has it been used after reset or before init?" + "Has it been used after reset or before init?" ) operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/Toml.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/Toml.kt index 75572ee7d..12ccbb477 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/Toml.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/Toml.kt @@ -1,5 +1,6 @@ package de.fayard.refreshVersions.core.internal +@FunctionalCore(testName = "VersionsCatalogUpdaterTest") internal data class Toml( val sections: MutableMap> ) { diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlLine.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlLine.kt index dddba9371..2c0967370 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlLine.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlLine.kt @@ -7,6 +7,7 @@ import org.gradle.api.artifacts.Dependency * Despite TOML supporting braces in its syntax, they must open and close on * the same line, so having a per-line model is fine. */ +@FunctionalCore(testName = "TomlLineTest") internal data class TomlLine( val section: TomlSection, val text: String, diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionManagementKind.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionManagementKind.kt index f4d99fc90..fab0591b8 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionManagementKind.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionManagementKind.kt @@ -43,6 +43,7 @@ internal sealed class VersionManagementKind { object NoMatch : VersionManagementKind() } +@FunctionalCore(testName = "TODO") internal fun Dependency.versionManagementKind( versionMap: Map, versionKeyReader: ArtifactVersionKeyReader, @@ -55,6 +56,7 @@ internal fun Dependency.versionManagementKind( this is ExternalDependency && versionPlaceholder in this.versionConstraint.rejectedVersions -> { Match.VersionsFile.VersionPlaceholder } + name.endsWith(".gradle.plugin") -> { when (val moduleId = moduleId()) { is ModuleId.Maven -> { @@ -68,23 +70,29 @@ internal fun Dependency.versionManagementKind( versionsCatalogLibraries = versionsCatalogLibraries, versionsCatalogPlugins = versionsCatalogPlugins ) -> Match.VersionsCatalog.MatchingVersionConstraint + else -> NoMatch } + version -> Match.VersionsFile.MatchingPluginVersion else -> NoMatch } } + else -> NoMatch } } + else -> when { hasVersionInVersionCatalog( versionsCatalogLibraries = versionsCatalogLibraries ) -> Match.VersionsCatalog.MatchingVersionConstraint + else -> NoMatch } } +@FunctionalCore(testName = "TODO") private fun Dependency.hasVersionInVersionCatalog( versionsCatalogLibraries: Collection, versionsCatalogPlugins: Set = emptySet() diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogs.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogs.kt index de67fbfc4..d5155311a 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogs.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogs.kt @@ -19,6 +19,7 @@ object VersionsCatalogs { fun isSupported(): Boolean = GradleVersion.current() >= minimumGradleVersion + @FunctionalCore(testName = "TODO") fun defaultCatalogName(): String = try { @Suppress("UnstableApiUsage") RefreshVersionsConfigHolder.settings.dependencyResolutionManagement.defaultLibrariesExtensionName.get() @@ -27,11 +28,13 @@ object VersionsCatalogs { "libs" } + @FunctionalCore(testName = "TODO") fun getDefault(project: Project): VersionCatalog? { val versionCatalogs = project.extensions.findByType() return versionCatalogs?.find(defaultCatalogName())?.orElse(null) } + @FunctionalCore(testName = "TODO") internal fun libraries(versionCatalog: VersionCatalog?): Set { if (versionCatalog == null) return emptySet() val aliases = versionCatalog.libraryAliases @@ -40,6 +43,7 @@ object VersionsCatalogs { } } + @FunctionalCore(testName = "TODO") internal fun plugins(versionCatalog: VersionCatalog?): Set { if (versionCatalog == null) return emptySet() val aliases = versionCatalog.pluginAliases @@ -48,6 +52,7 @@ object VersionsCatalogs { } } + @FunctionalCore(testName = "TODO") fun dependencyAliases(versionCatalog: VersionCatalog?): Map = when { FeatureFlag.VERSIONS_CATALOG.isNotEnabled -> emptyMap() versionCatalog == null -> emptyMap() @@ -64,6 +69,7 @@ object VersionsCatalogs { }.toMap() } + @FunctionalCore("VersionsCatalogUpdaterTest") internal fun parseToml(toml: String): Toml { val map = parseTomlInSections(toml) .map { (sectionName, paragraph) -> @@ -76,6 +82,7 @@ object VersionsCatalogs { /** * Returns a map where the key is the section name, and the value, the section content. */ + @FunctionalCore("TomlSectionTest") internal fun parseTomlInSections(toml: String): Map { val result = mutableMapOf() result["root"] = StringBuilder() @@ -96,6 +103,7 @@ object VersionsCatalogs { return result.mapValues { it.value.toString() } } + @FunctionalCore("VersionsCatalogUpdaterTest") fun generateVersionsCatalogText( versionsMap: Map = RefreshVersionsConfigHolder.readVersionsMap(), versionKeyReader: ArtifactVersionKeyReader = RefreshVersionsConfigHolder.versionKeyReader, diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/ArgumentsExtracting.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/ArgumentsExtracting.kt index d370f5c2e..c6dea095c 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/ArgumentsExtracting.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/ArgumentsExtracting.kt @@ -1,7 +1,10 @@ package de.fayard.refreshVersions.core.internal.codeparsing +import de.fayard.refreshVersions.core.internal.FunctionalCore +import de.fayard.refreshVersions.core.internal.NeedsRefactoring import de.fayard.refreshVersions.core.internal.codeparsing.SourceCodeSection.* +@NeedsRefactoring("parameterName and expressionWithCommentsIfAny properties are never used") internal class FunctionArgument( val parameterName: String?, val expressionWithCommentsIfAny: String @@ -13,6 +16,7 @@ internal class FunctionArgument( * or if the passed [functionCallText] lacks the parentheses, * it might fail in unexpected ways. */ +@FunctionalCore(testName = "TODO") internal fun extractArgumentsOfFunctionCall( programmingLanguage: ProgrammingLanguage, functionCallText: CharSequence diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/FindInRanges.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/FindInRanges.kt index 2277ade12..96930331f 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/FindInRanges.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/FindInRanges.kt @@ -1,7 +1,10 @@ package de.fayard.refreshVersions.core.internal.codeparsing +import de.fayard.refreshVersions.core.internal.FunctionalCore +import de.fayard.refreshVersions.core.internal.NeedsRefactoring import de.fayard.refreshVersions.core.internal.TaggedRange +@FunctionalCore(testName = "TODO") internal fun CharSequence.rangesOfCode( code: String, startIndex: Int = 0, @@ -33,6 +36,7 @@ internal fun CharSequence.rangesOfCode( return list } +@FunctionalCore(testName = "TODO") internal fun CharSequence.rangeOfCode( code: String, startIndex: Int = 0, @@ -46,6 +50,8 @@ internal fun CharSequence.rangeOfCode( sectionsRanges = sectionsRanges ) +@FunctionalCore(testName = "TODO") +@NeedsRefactoring("Dead code") internal fun CharSequence.rangeOfStringLiteral( stringLiteral: String, startIndex: Int = 0, @@ -59,6 +65,7 @@ internal fun CharSequence.rangeOfStringLiteral( sectionsRanges = sectionsRanges ) +@FunctionalCore(testName = "TODO") internal fun CharSequence.rangeOf( text: String, sectionKind: SourceCodeSection, @@ -83,6 +90,7 @@ internal fun CharSequence.rangeOf( /** * Returns -1 if there's no import statement */ +@FunctionalCore(testName = "TODO") internal fun CharSequence.findFirstImportStatement( sectionsRanges: List> ): Int { @@ -103,6 +111,7 @@ internal fun CharSequence.findFirstImportStatement( /** * Returns lastIndex + 1 (i.e. [CharSequence.length]) if no non-blank code chunk is found. */ +@FunctionalCore(testName = "TODO") internal fun CharSequence.indexOfFirstNonBlankCodeChunk( sectionsRanges: List> ): Int { diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/SourceCodeRangesFinding.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/SourceCodeRangesFinding.kt index 9bb1914c9..b96831145 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/SourceCodeRangesFinding.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/SourceCodeRangesFinding.kt @@ -1,6 +1,7 @@ package de.fayard.refreshVersions.core.internal.codeparsing import de.fayard.refreshVersions.core.extensions.text.forEachIndexedSkippable +import de.fayard.refreshVersions.core.internal.FunctionalCore import de.fayard.refreshVersions.core.internal.TaggedRange /** @@ -9,6 +10,7 @@ string literals, and the rest, separately. The returned list covers the entire passed CharSequence. */ +@FunctionalCore(testName = "TODO") internal fun CharSequence.findRanges( programmingLanguage: ProgrammingLanguage ): List> = mutableListOf>().also { diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/GradleScriptParsing.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/GradleScriptParsing.kt index 050cbcf14..3bbbf91f7 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/GradleScriptParsing.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/GradleScriptParsing.kt @@ -1,10 +1,12 @@ package de.fayard.refreshVersions.core.internal.codeparsing.gradle +import de.fayard.refreshVersions.core.internal.FunctionalCore import de.fayard.refreshVersions.core.internal.TaggedRange import de.fayard.refreshVersions.core.internal.codeparsing.ProgrammingLanguage import de.fayard.refreshVersions.core.internal.codeparsing.SourceCodeSection import de.fayard.refreshVersions.core.internal.codeparsing.findRanges +@FunctionalCore(testName = "SettingsPluginUpdaterTest") internal fun CharSequence.extractGradleScriptSections( isKotlinDsl: Boolean ): List> = findRanges( diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/PluginBlocksLocating.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/PluginBlocksLocating.kt index 2c82733c7..5370c9780 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/PluginBlocksLocating.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/codeparsing/gradle/PluginBlocksLocating.kt @@ -1,10 +1,12 @@ package de.fayard.refreshVersions.core.internal.codeparsing.gradle +import de.fayard.refreshVersions.core.internal.FunctionalCore import de.fayard.refreshVersions.core.internal.TaggedRange import de.fayard.refreshVersions.core.internal.codeparsing.SourceCodeSection import de.fayard.refreshVersions.core.internal.codeparsing.SymbolLocationFindingRule import de.fayard.refreshVersions.core.internal.codeparsing.findSymbolsRanges +@FunctionalCore(testName = "TODO") internal fun CharSequence.findPluginBlocksRanges( ranges: List> ): List> = findSymbolsRanges( diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/failures/FailureCause.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/failures/FailureCause.kt index 7b6c6fba0..8b45cb35b 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/failures/FailureCause.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/failures/FailureCause.kt @@ -1,16 +1,20 @@ package de.fayard.refreshVersions.core.internal.failures import de.fayard.refreshVersions.core.DependencyVersionsFetcher +import de.fayard.refreshVersions.core.internal.FunctionalCore +@FunctionalCore(testName = "TODO") internal fun DependencyVersionsFetcher.FailureCause.oneLineSummary(): String = when (this) { is DependencyVersionsFetcher.FailureCause.CommunicationIssue.HttpResponse -> { val message = exception?.message ?: "" "http status code $statusCode $message" } + is DependencyVersionsFetcher.FailureCause.CommunicationIssue.NetworkIssue -> { val message = exception.message ?: exception.cause?.message ?: "" "network or server issue (${exception.javaClass} ${message})" } + is DependencyVersionsFetcher.FailureCause.ParsingIssue -> { val message = exception.message ?: exception.cause?.message ?: "" "error while parsing metadata (${exception.javaClass} ${message})" diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/migrations/LegacySymbolsMigration.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/migrations/LegacySymbolsMigration.kt index b58d35a08..ff89cafdd 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/migrations/LegacySymbolsMigration.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/migrations/LegacySymbolsMigration.kt @@ -1,12 +1,13 @@ package de.fayard.refreshVersions.core.internal.migrations import de.fayard.refreshVersions.core.extensions.collections.forEachReversedWithIndex +import de.fayard.refreshVersions.core.internal.NeedsRefactoring import de.fayard.refreshVersions.core.internal.codeparsing.* -import de.fayard.refreshVersions.core.internal.codeparsing.SymbolLocationFindingRule import de.fayard.refreshVersions.core.internal.codeparsing.gradle.extractGradleScriptSections import java.io.File internal fun migrateLegacySymbolsIfNeeded(projectDir: File, revisionOfLastRefreshVersionsRun: Int) { + @NeedsRefactoring("What does 11 mean here?") if (revisionOfLastRefreshVersionsRun < 11) addNewArgumentToVersionForCalls(projectDir) } diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/removals_replacement/RemovedDependencyNotationsHistoryParsing.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/removals_replacement/RemovedDependencyNotationsHistoryParsing.kt index fb22cd9be..e4508ce7e 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/removals_replacement/RemovedDependencyNotationsHistoryParsing.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/removals_replacement/RemovedDependencyNotationsHistoryParsing.kt @@ -1,12 +1,14 @@ package de.fayard.refreshVersions.core.internal.removals_replacement import de.fayard.refreshVersions.core.ModuleId +import de.fayard.refreshVersions.core.internal.FunctionalCore import java.io.InputStream internal fun InputStream.parseRemovedDependencyNotationsHistory(currentRevision: Int): List { return bufferedReader().lineSequence().parseRemovedDependencyNotationsHistory(currentRevision) } +@FunctionalCore(testName = "TODO") internal fun Sequence.parseRemovedDependencyNotationsHistory( currentRevision: Int? ): List { @@ -41,11 +43,13 @@ internal fun Sequence.parseRemovedDependencyNotationsHistory( check(replacementMavenCoordinates.isEmpty()) dependencyNotation = line.removeSurrounding("~~").also { check(it.isNotEmpty()) } } + line.startsWith("//") -> { checkNotNull(dependencyNotation) check(replacementMavenCoordinates.isEmpty()) commentLines.add(line) } + line.startsWith("moved:[") -> { checkNotNull(dependencyNotation) check(replacementMavenCoordinates.isEmpty()) { @@ -53,6 +57,7 @@ internal fun Sequence.parseRemovedDependencyNotationsHistory( } replacementMavenCoordinates += parseReplacementLine(line, "moved:") } + line.startsWith("extra:[") -> { checkNotNull(dependencyNotation) check(replacementMavenCoordinates.isNotEmpty()) { @@ -62,6 +67,7 @@ internal fun Sequence.parseRemovedDependencyNotationsHistory( check(coordinates !in replacementMavenCoordinates) replacementMavenCoordinates += coordinates } + line.startsWith("id:[") -> { checkNotNull(dependencyNotation) val newElement = RemovedDependencyNotation( @@ -81,12 +87,14 @@ internal fun Sequence.parseRemovedDependencyNotationsHistory( commentLines.clear() list.add(newElement) } + line.startsWith("## [WIP]") -> { check(dependencyNotation == null) check(commentLines.isEmpty()) check(replacementMavenCoordinates.isEmpty()) return list } + line.startsWith("**") -> throw IllegalArgumentException() else -> throw IllegalArgumentException() } diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/versions/VersionsPropertiesModel.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/versions/VersionsPropertiesModel.kt index dac34bded..4d597266d 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/versions/VersionsPropertiesModel.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/versions/VersionsPropertiesModel.kt @@ -1,11 +1,13 @@ package de.fayard.refreshVersions.core.internal.versions import de.fayard.refreshVersions.core.DependencyVersionsFetcher +import de.fayard.refreshVersions.core.internal.FunctionalCore import de.fayard.refreshVersions.core.internal.failures.oneLineSummary /** * @property dependencyNotationRemovalsRevision Designed to be used only for snapshot publications. */ +@FunctionalCore(testName = "VersionsPropertiesModelTest") internal actual data class VersionsPropertiesModel( actual val preHeaderContent: String, actual val generatedByVersion: String, diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/xor/Xor.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/xor/Xor.kt index 2241fde51..42c1d41b3 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/xor/Xor.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/xor/Xor.kt @@ -1,10 +1,15 @@ package de.fayard.refreshVersions.core.internal.xor +import de.fayard.refreshVersions.core.internal.FunctionalCore +import de.fayard.refreshVersions.core.internal.NeedsRefactoring + /** * A class similar to `Either` from Arrow, but with less features (because some are not needed). * * XOR stands for eXclusive OR. */ +@FunctionalCore(testName = "TODO") +@NeedsRefactoring("Either without .map() and .flatmap() isn't really useful") internal sealed class Xor { fun firstOrNull(): FirstT? = if (this is First) this.value else null diff --git a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsDependenciesMigrationTask.kt b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsDependenciesMigrationTask.kt index b65acd2bf..caa8254e6 100644 --- a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsDependenciesMigrationTask.kt +++ b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsDependenciesMigrationTask.kt @@ -1,13 +1,15 @@ package de.fayard.refreshVersions +import de.fayard.refreshVersions.core.internal.NeedsRefactoring +import de.fayard.refreshVersions.core.internal.cli.AnsiColor import de.fayard.refreshVersions.internal.promptProjectSelection import de.fayard.refreshVersions.internal.runInteractiveMigrationToDependenciesConstants -import de.fayard.refreshVersions.core.internal.cli.AnsiColor import kotlinx.coroutines.* import org.gradle.api.DefaultTask import org.gradle.api.logging.configuration.ConsoleOutput import org.gradle.api.tasks.TaskAction +@NeedsRefactoring("Almost dead code") open class RefreshVersionsDependenciesMigrationTask : DefaultTask() { @TaskAction diff --git a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsPlugin.kt b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsPlugin.kt index af9ec154b..7fda46d40 100644 --- a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsPlugin.kt +++ b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/RefreshVersionsPlugin.kt @@ -2,6 +2,7 @@ package de.fayard.refreshVersions import de.fayard.refreshVersions.core.* import de.fayard.refreshVersions.core.extensions.gradle.isBuildSrc +import de.fayard.refreshVersions.core.internal.NeedsRefactoring import de.fayard.refreshVersions.core.internal.removals_replacement.RemovedDependencyNotationsReplacementInfo import de.fayard.refreshVersions.core.internal.skipConfigurationCache import de.fayard.refreshVersions.internal.getArtifactNameToConstantMapping @@ -163,6 +164,7 @@ open class RefreshVersionsPlugin : Plugin { private fun applyToProject(project: Project) { if (project != project.rootProject) return // We want the tasks only for the root project + @NeedsRefactoring("Almost dead code") if (FeatureFlag.OLD_TASKS.isEnabled) project.tasks.register( name = "migrateToRefreshVersionsDependenciesConstants" ) { @@ -173,6 +175,7 @@ open class RefreshVersionsPlugin : Plugin { skipConfigurationCache() } + @NeedsRefactoring("Almost dead code") if (FeatureFlag.OLD_TASKS.isEnabled) project.tasks.register( name = "refreshVersionsDependenciesMapping" ) { diff --git a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/Mapping.kt b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/Mapping.kt index 08a7fafc1..5113f0615 100644 --- a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/Mapping.kt +++ b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/Mapping.kt @@ -3,6 +3,8 @@ package de.fayard.refreshVersions.internal import de.fayard.refreshVersions.core.AbstractDependencyGroup import de.fayard.refreshVersions.core.DependencyNotation import de.fayard.refreshVersions.core.internal.DependencyMapping +import de.fayard.refreshVersions.core.internal.FunctionalCore +import de.fayard.refreshVersions.core.internal.NeedsRefactoring import dependencies.ALL_DEPENDENCIES_NOTATIONS import org.gradle.api.artifacts.ModuleIdentifier import java.lang.reflect.Field @@ -15,6 +17,7 @@ import kotlin.reflect.jvm.javaField import kotlin.reflect.jvm.javaType import kotlin.reflect.typeOf +@FunctionalCore(testName = "TODO") internal fun getArtifactNameToConstantMapping(excludeBomDependencies: Boolean = false): List { AbstractDependencyGroup.disableBomCheck = true val result = ALL_DEPENDENCIES_NOTATIONS.asSequence().flatMap { objectInstance -> @@ -28,6 +31,7 @@ internal fun getArtifactNameToConstantMapping(excludeBomDependencies: Boolean = return result } +@NeedsRefactoring("Dead code") internal fun getArtifactsFromDependenciesObject(objectInstance: Any): List { return getArtifactNameToConstantMappingFromObject( objectInstance, diff --git a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/MigrationToDependenciesConstants.kt b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/MigrationToDependenciesConstants.kt index 64bb6f10e..2ab46b4ee 100644 --- a/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/MigrationToDependenciesConstants.kt +++ b/plugins/dependencies/src/main/kotlin/de/fayard/refreshVersions/internal/MigrationToDependenciesConstants.kt @@ -1,6 +1,7 @@ package de.fayard.refreshVersions.internal import de.fayard.refreshVersions.core.countDependenciesWithHardcodedVersions +import de.fayard.refreshVersions.core.internal.NeedsRefactoring import de.fayard.refreshVersions.core.internal.RefreshVersionsConfigHolder import de.fayard.refreshVersions.core.internal.cli.AnsiColor import de.fayard.refreshVersions.core.internal.cli.CliGenericUi @@ -13,7 +14,7 @@ import kotlin.coroutines.coroutineContext //TODO: Ignore the following dependency: org.jetbrains.kotlin:kotlin-android-extensions-runtime - +@NeedsRefactoring("Almost dead code") internal fun promptProjectSelection(rootProject: Project): Project? { require(rootProject == rootProject.rootProject) { "Expected a rootProject but got $rootProject" } val versionsMap = RefreshVersionsConfigHolder.readVersionsMap() @@ -34,6 +35,7 @@ internal fun promptProjectSelection(rootProject: Project): Project? { return projectsWithHardcodedDependenciesVersions.getOrNull(index.value)?.first } +@NeedsRefactoring("Almost dead code") internal suspend fun runInteractiveMigrationToDependenciesConstants(project: Project) { val versionsMap = RefreshVersionsConfigHolder.readVersionsMap() while (coroutineContext.isActive) { @@ -46,6 +48,7 @@ internal suspend fun runInteractiveMigrationToDependenciesConstants(project: Pro } } +@NeedsRefactoring("Almost dead code") private fun Project.promptConfigurationSelection(versionsMap: Map): Configuration? { @Suppress("UnstableApiUsage") val versionKeyReader = RefreshVersionsConfigHolder.versionKeyReader diff --git a/plugins/dependencies/src/main/resources/removed-dependencies-versions-keys.txt b/plugins/dependencies/src/main/resources/removed-dependencies-versions-keys.txt index 448234ad5..eab60f21d 100644 --- a/plugins/dependencies/src/main/resources/removed-dependencies-versions-keys.txt +++ b/plugins/dependencies/src/main/resources/removed-dependencies-versions-keys.txt @@ -107,3 +107,4 @@ androidx.health..health-connect-client=version.androidx.health-connect-client com.google.accompanist..accompanist-glide=version.google.accompanist com.google.accompanist..accompanist-imageloading-core=version.google.accompanist app.cash.molecule..molecule-testing=version.app.cash.molecule +androidx.compose.runtime..runtime-tracing=version.androidx.compose.runtime diff --git a/plugins/dependencies/src/test/resources/dependencies-versions-key-validated.txt b/plugins/dependencies/src/test/resources/dependencies-versions-key-validated.txt index 270347229..27f67a81f 100644 --- a/plugins/dependencies/src/test/resources/dependencies-versions-key-validated.txt +++ b/plugins/dependencies/src/test/resources/dependencies-versions-key-validated.txt @@ -58,7 +58,7 @@ androidx.compose.runtime..runtime-livedata=version.androidx.compose.runtime androidx.compose.runtime..runtime-rxjava2=version.androidx.compose.runtime androidx.compose.runtime..runtime-rxjava3=version.androidx.compose.runtime androidx.compose.runtime..runtime-saveable=version.androidx.compose.runtime -androidx.compose.runtime..runtime-tracing=version.androidx.compose.runtime +androidx.compose.runtime..runtime-tracing=version.androidx.compose.runtime-tracing androidx.compose.runtime..runtime=version.androidx.compose.runtime androidx.compose.ui..ui-geometry=version.androidx.compose.ui androidx.compose.ui..ui-graphics=version.androidx.compose.ui