Skip to content

Commit

Permalink
fix(pub): Improve containsFlutterSdk()
Browse files Browse the repository at this point in the history
Make the function return true for any dependency which is part of the
Flutter SDK, independently of the respective dependency name.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Sep 5, 2024
1 parent 399d507 commit 694ac3c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/package-managers/pub/src/main/kotlin/Pub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import org.ossreviewtoolkit.model.config.PackageManagerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.model.createAndLogIssue
import org.ossreviewtoolkit.plugins.packagemanagers.pub.Pubspec.Dependency
import org.ossreviewtoolkit.plugins.packagemanagers.pub.Pubspec.SdkDependency
import org.ossreviewtoolkit.plugins.packagemanagers.pub.utils.PubCacheReader
import org.ossreviewtoolkit.utils.common.CommandLineTool
import org.ossreviewtoolkit.utils.common.Os
Expand Down Expand Up @@ -744,9 +745,8 @@ class Pub(
* Check the [PUBSPEC_YAML] within [workingDir] if the project contains the Flutter SDK.
*/
private fun containsFlutterSdk(workingDir: File): Boolean {
val pubspec = parsePubspec(workingDir.resolve(PUBSPEC_YAML))

return (pubspec.dependencies?.get("flutter") as? Pubspec.SdkDependency)?.sdk == "flutter"
val dependencies = parsePubspec(workingDir.resolve(PUBSPEC_YAML)).dependencies ?: return false
return dependencies.values.filterIsInstance<SdkDependency>().any { it.sdk == "flutter" }
}

/**
Expand Down

0 comments on commit 694ac3c

Please sign in to comment.