Skip to content

Commit

Permalink
refactor(conan): Inline a function
Browse files Browse the repository at this point in the history
In order to not loose information, merge relevant aspects of the
functions KDoc.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jul 17, 2024
1 parent a942c7e commit 3181191
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions plugins/package-managers/conan/src/main/kotlin/Conan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class Conan(
dependencies = parseDependencyTree(pkgInfos, projectInfo.buildRequires, workingDir)
)

val projectPackage = parseProjectPackage(pkgInfos, definitionFile, workingDir)
val projectPackage = generateProjectPackage(projectInfo, definitionFile, workingDir)

return listOf(
ProjectAnalyzerResult(
Expand Down Expand Up @@ -403,23 +403,14 @@ class Conan(
}

/**
* Return a [Package] containing project-level information depending on which [definitionFile] was found:
* Return a [Package] containing project-level information from [pkgInfo] and [definitionFile] using the
* `conan inspect` command if possible:
* - conanfile.txt: `conan inspect conanfile.txt` is not supported.
* - conanfile.py: `conan inspect conanfile.py` is supported and more useful project metadata is parsed.
*
* TODO: The format of `conan info` output for a conanfile.txt file may be such that we can get project metadata
* from the `requires` field. Need to investigate whether this is a sure thing before implementing.
*/
private fun parseProjectPackage(pkgInfos: List<PackageInfo>, definitionFile: File, workingDir: File): Package {
val projectPackage = findProjectPackageInfo(pkgInfos, definitionFile.name)

return generateProjectPackage(projectPackage, definitionFile, workingDir)
}

/**
* Return a [Package] containing project-level information from [pkgInfo] and [definitionFile] using the
* `conan inspect` command.
*/
private fun generateProjectPackage(pkgInfo: PackageInfo, definitionFile: File, workingDir: File): Package {
fun inspectOrNull(field: String) =
definitionFile.name.takeIf { it == "conanfile.py" }?.let { inspectField(it, workingDir, field) }
Expand Down

0 comments on commit 3181191

Please sign in to comment.