From 3a00866888993ce56e6601eabb6e972fdd1742c6 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Thu, 23 Nov 2023 08:39:01 +0100 Subject: [PATCH] refactor(report)!: Turn `ReportTableModelMapper` into a class Prepare for splitting up the rather large `map()` function into multiple functions. Previously, this would require passing around the input variables as parameters. Avoid that by making them class member variables. Signed-off-by: Frank Viernau --- .../src/main/kotlin/ReportTableModelMapper.kt | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt index 19e3a24acffac..fd47490800c82 100644 --- a/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt +++ b/plugins/reporters/static-html/src/main/kotlin/ReportTableModelMapper.kt @@ -43,13 +43,23 @@ import org.ossreviewtoolkit.reporter.HowToFixTextProvider /** * A mapper which converts an [OrtResult] to a [ReportTableModel]. */ -internal object ReportTableModelMapper { - fun map( - ortResult: OrtResult, - licenseInfoResolver: LicenseInfoResolver, - resolutionProvider: ResolutionProvider, - howToFixTextProvider: HowToFixTextProvider - ): ReportTableModel { +internal class ReportTableModelMapper private constructor( + private val ortResult: OrtResult, + private val licenseInfoResolver: LicenseInfoResolver, + private val resolutionProvider: ResolutionProvider, + private val howToFixTextProvider: HowToFixTextProvider +) { + companion object { + fun map( + ortResult: OrtResult, + licenseInfoResolver: LicenseInfoResolver, + resolutionProvider: ResolutionProvider, + howToFixTextProvider: HowToFixTextProvider + ): ReportTableModel = + ReportTableModelMapper(ortResult, licenseInfoResolver, resolutionProvider, howToFixTextProvider).map() + } + + fun map(): ReportTableModel { val issueSummaryRows = mutableMapOf() val analyzerResult = ortResult.analyzer?.result