Skip to content

Commit

Permalink
refactor(report)!: Turn ReportTableModelMapper into a class
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fviernau committed Nov 23, 2023
1 parent f07cc1d commit 3a00866
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Identifier, IssueRow>()

val analyzerResult = ortResult.analyzer?.result
Expand Down

0 comments on commit 3a00866

Please sign in to comment.