Skip to content

Commit

Permalink
refactor(reporter)!: Remove the unnused config argument
Browse files Browse the repository at this point in the history
All reporters have been migrated to receive their configuration options
via the constructor, so remove the now unused `config` argument from the
`generateReport` function.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
  • Loading branch information
mnonnenmacher committed Nov 7, 2024
1 parent f9ad568 commit c02be70
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class ReporterCommand : OrtCommand(
reporter to measureTimedValue {
val options = reportConfigMap[reporter.descriptor.id] ?: PluginConfiguration.EMPTY
reporter.create(PluginConfig(options.options, options.secrets))
.generateReport(input, outputDir, options)
.generateReport(input, outputDir)
}
}
}.awaitAll()
Expand Down
7 changes: 1 addition & 6 deletions plugins/reporters/aosd/src/main/kotlin/Aosd2Reporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.ossreviewtoolkit.model.HashAlgorithm
import org.ossreviewtoolkit.model.Package
import org.ossreviewtoolkit.model.RemoteArtifact
import org.ossreviewtoolkit.model.RepositoryProvenance
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.licenses.LicenseView
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand All @@ -44,11 +43,7 @@ import org.ossreviewtoolkit.utils.spdx.SpdxLicense
factory = ReporterFactory::class
)
class Aosd2Reporter(override val descriptor: PluginDescriptor = Aosd2ReporterFactory.descriptor) : Reporter {
override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val reportFiles = input.ortResult.getProjects(omitExcluded = true).map { project ->
val directDependencies = input.ortResult.getDependencies(project.id, maxLevel = 1, omitExcluded = true)
.map { it.toCoordinates() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.asciidoctor.Attributes
import org.asciidoctor.Options
import org.asciidoctor.SafeMode

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.reporters.freemarker.FreemarkerTemplateProcessor
import org.ossreviewtoolkit.reporter.Reporter
Expand Down Expand Up @@ -85,11 +84,7 @@ abstract class AsciiDocTemplateReporter(private val config: AsciiDocTemplateRepo
*/
protected open fun generateAsciiDocAttributes(outputDir: File): Attributes = Attributes.builder().build()

final override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
final override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val asciiDocOutputDir = createOrtTempDir("asciidoc")

val asciidoctorAttributes = generateAsciiDocAttributes(asciiDocOutputDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import java.io.File
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToStream

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.licenses.LicenseView
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -53,11 +52,7 @@ class CtrlXAutomationReporter(override val descriptor: PluginDescriptor = CtrlXA
)
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val packages = input.ortResult.getPackages(omitExcluded = true)
val components = packages.mapTo(mutableListOf()) { (pkg, _) ->
val qualifiedName = when (pkg.id.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.LicenseSource
import org.ossreviewtoolkit.model.Package
import org.ossreviewtoolkit.model.Project
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.licenses.ResolvedLicenseInfo
import org.ossreviewtoolkit.model.utils.toPurl
import org.ossreviewtoolkit.model.vulnerabilities.Vulnerability
Expand Down Expand Up @@ -171,11 +170,7 @@ class CycloneDxReporter(
}
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val reportFileResults = mutableListOf<Result<File>>()

val projects = input.ortResult.getProjects(omitExcluded = true).sortedBy { it.id }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package org.ossreviewtoolkit.plugins.reporters.evaluatedmodel
import java.io.File

import org.ossreviewtoolkit.model.FileFormat
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -67,11 +66,7 @@ class EvaluatedModelReporter(
const val OPTION_DEDUPLICATE_DEPENDENCY_TREE = "deduplicateDependencyTree"
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val evaluatedModel = EvaluatedModel.create(input, this.config.deduplicateDependencyTree)

val outputFileFormats = this.config.outputFileFormats.map { FileFormat.forExtension(it) }
Expand Down
7 changes: 1 addition & 6 deletions plugins/reporters/fossid/src/main/kotlin/FossIdReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import org.ossreviewtoolkit.clients.fossid.generateReport
import org.ossreviewtoolkit.clients.fossid.model.report.ReportType
import org.ossreviewtoolkit.clients.fossid.model.report.SelectionType
import org.ossreviewtoolkit.model.ScanResult
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -93,11 +92,7 @@ class FossIdReporter(
const val SCAN_CODE_KEY = "scancode"
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val reportType = ReportType.valueOf(this.config.reportType)
val selectionType = SelectionType.valueOf(this.config.selectionType)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package org.ossreviewtoolkit.plugins.reporters.fossid

import java.io.File

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
import org.ossreviewtoolkit.plugins.reporters.asciidoc.AsciiDocTemplateReporterConfig
Expand All @@ -44,11 +43,7 @@ class FossIdSnippetReporter(override val descriptor: PluginDescriptor = FossIdSn
)
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val hasFossIdResults = input.ortResult.scanner?.scanResults?.any { it.scanner.name == "FossId" } == true
require(hasFossIdResults) { "No FossID scan results have been found." }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package org.ossreviewtoolkit.plugins.reporters.freemarker

import java.io.File

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -75,11 +74,7 @@ class PlainTextTemplateReporter(

private val templateProcessor = FreemarkerTemplateProcessor(TEMPLATE_DIRECTORY)

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val actualConfig = this.config.takeIf {
it.templateIds?.isNotEmpty() == true || it.templatePaths?.isNotEmpty() == true
} ?: PlainTextTemplateReporterConfig.DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNamingStrategy

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -67,11 +66,7 @@ class GitLabLicenseModelReporter(

private val reportFilename = "gl-license-scanning-report.json"

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val licenseModel = GitLabLicenseModelMapper.map(input.ortResult, this.config.skipExcluded)

val reportFileResult = runCatching {
Expand Down
7 changes: 1 addition & 6 deletions plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import org.ossreviewtoolkit.model.Package
import org.ossreviewtoolkit.model.Project
import org.ossreviewtoolkit.model.ScanResult
import org.ossreviewtoolkit.model.VcsInfo
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.utils.getPurlType
import org.ossreviewtoolkit.model.utils.toPurl
import org.ossreviewtoolkit.plugins.api.OrtPlugin
Expand Down Expand Up @@ -545,11 +544,7 @@ class OpossumReporter(
return opossumInput
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val reportFileResult = runCatching {
val opossumInput = generateOpossumInput(input, this.config.maxDepth)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import java.io.File

import org.apache.logging.log4j.kotlin.logger

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -98,11 +97,7 @@ class SpdxDocumentReporter(
const val REPORT_BASE_FILENAME = "bom.spdx"
}

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val outputFileFormats = this.config.outputFileFormats
.mapTo(mutableSetOf()) { FileFormat.valueOf(it.uppercase()) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import org.ossreviewtoolkit.model.RepositoryProvenance
import org.ossreviewtoolkit.model.Severity
import org.ossreviewtoolkit.model.VcsInfo
import org.ossreviewtoolkit.model.config.PathExclude
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
import org.ossreviewtoolkit.model.config.ScopeExclude
import org.ossreviewtoolkit.model.licenses.ResolvedLicenseLocation
Expand Down Expand Up @@ -77,11 +76,7 @@ class StaticHtmlReporter(override val descriptor: PluginDescriptor = StaticHtmlR
private val css = javaClass.getResource("/static-html-reporter.css").readText()
private val licensesSha1 = mutableMapOf<String, String>()

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val tablesReport = TablesReportModelMapper.map(input)

val reportFileResult = runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToStream

import org.ossreviewtoolkit.model.DependencyNode
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.model.licenses.LicenseView
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand All @@ -46,11 +45,7 @@ class TrustSourceReporter(override val descriptor: PluginDescriptor = TrustSourc

private val reportFilename = "trustsource-report.json"

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val outputFile = outputDir.resolve(reportFilename)

val nav = input.ortResult.dependencyNavigator
Expand Down
7 changes: 1 addition & 6 deletions plugins/reporters/web-app/src/main/kotlin/WebAppReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import kotlin.io.encoding.encodingWith
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream
import org.apache.commons.compress.compressors.gzip.GzipParameters

import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.OrtPlugin
import org.ossreviewtoolkit.plugins.api.OrtPluginOption
import org.ossreviewtoolkit.plugins.api.PluginDescriptor
Expand Down Expand Up @@ -62,11 +61,7 @@ class WebAppReporter(
) : Reporter {
private val reportFilename = "scan-report-web-app.html"

override fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration
): List<Result<File>> {
override fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>> {
val template = javaClass.getResource("/scan-report-template.html").readText()
val evaluatedModel = EvaluatedModel.create(input, this.config.deduplicateDependencyTree)

Expand Down
13 changes: 4 additions & 9 deletions reporter/src/main/kotlin/Reporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package org.ossreviewtoolkit.reporter
import java.io.File

import org.ossreviewtoolkit.model.OrtResult
import org.ossreviewtoolkit.model.config.PluginConfiguration
import org.ossreviewtoolkit.plugins.api.Plugin

/**
Expand All @@ -31,13 +30,9 @@ import org.ossreviewtoolkit.plugins.api.Plugin
interface Reporter : Plugin {
/**
* Generate a report for the provided [input] and write the generated file(s) to the [outputDir]. If and how the
* [input] data is used depends on the specific reporter implementation, taking into account any format-specific
* [config]. Return a list of [Result]s that wrap the generated report file on success, or a file specific failure
* if something went wrong.
* [input] data is used depends on the specific reporter implementation.
* Return a list of [Result]s that wrap the generated report file on success, or a file specific failure if
* something went wrong.
*/
fun generateReport(
input: ReporterInput,
outputDir: File,
config: PluginConfiguration = PluginConfiguration.EMPTY
): List<Result<File>>
fun generateReport(input: ReporterInput, outputDir: File): List<Result<File>>
}

0 comments on commit c02be70

Please sign in to comment.