Skip to content

Commit

Permalink
chore: Use ifEmpty and ifBlank to simplify code
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
  • Loading branch information
mnonnenmacher committed Sep 7, 2024
1 parent 146f9a0 commit 714996c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class AnalyzerCommand : OrtCommand(
echo("Found ${files.size} $manager definition file(s) at:")

files.forEach { file ->
val relativePath = file.toRelativeString(inputDir).takeIf { it.isNotEmpty() } ?: "."
val relativePath = file.toRelativeString(inputDir).ifEmpty { "." }
echo("\t$relativePath")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private fun PythonInspector.Result.resolveIdentifier(
else -> PackageManager.getFallbackProjectName(analysisRoot, definitionFile)
}

val projectVersion = setupVersion.takeIf { it.isNotEmpty() } ?: requirementsVersion
val projectVersion = setupVersion.ifEmpty { requirementsVersion }

return Identifier(
type = managerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class OpossumReporter : Reporter {
if (idFromPath in baseUrlsForSources) return

if (VcsHost.GITHUB.isApplicable(vcs)) {
val revision = vcs.revision.takeIf { it.isNotBlank() } ?: "HEAD"
val revision = vcs.revision.ifBlank { "HEAD" }
val baseUrl = vcs.url
.replace("ssh://git@github.com/", "https://github.com/")
.replace(Regex("\\.git$"), "")
Expand Down

0 comments on commit 714996c

Please sign in to comment.