-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate reporter to new plugin API #9182
Conversation
c658c37
to
aa85547
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9182 +/- ##
=========================================
Coverage 68.09% 68.09%
- Complexity 1291 1293 +2
=========================================
Files 250 250
Lines 8814 8814
Branches 916 916
=========================================
Hits 6002 6002
Misses 2427 2427
Partials 385 385
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
ef79cd6
to
63d352f
Compare
plugins/reporters/spdx/src/funTest/kotlin/SpdxDocumentReporterFunTest.kt
Fixed
Show fixed
Hide fixed
plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt
Dismissed
Show dismissed
Hide dismissed
63d352f
to
bd1d5e9
Compare
bd1d5e9
to
7a7227b
Compare
plugins/reporters/asciidoc/src/main/kotlin/DocBookTemplateReporter.kt
Dismissed
Show dismissed
Hide dismissed
plugins/reporters/asciidoc/src/main/kotlin/ManPageTemplateReporter.kt
Dismissed
Show dismissed
Hide dismissed
plugins/reporters/asciidoc/src/main/kotlin/PdfTemplateReporter.kt
Dismissed
Show dismissed
Hide dismissed
7a7227b
to
c02be70
Compare
PluginConfiguration(options) | ||
) | ||
fun generateReport(result: OrtResult, options: Options): List<Result<File>> = | ||
CycloneDxReporterFactory().create(PluginConfig(options)).generateReport(ReporterInput(result), outputDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using the factory now in several tests because it is the easiest way to create a reporter with the default configuration (the config class must not have default arguments). This is not nice and I will make a follow-up PR to simplify this.
c02be70
to
ce7814f
Compare
* A list of alternative names for the option. This can be used to make renaming options backward-compatible. | ||
* Aliases are tried in the order they are defined until a value is found. | ||
*/ | ||
val aliases: Array<String> = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says it's a list although it's an array... which we barely use so far in the code base. Just curious, what's the reason to use an array here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lists are not allowed in annotation classes, it's a language limitation. Updated the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually arrays could be more efficient if you can cope with their limitations. I wonder whether we should make more use of them anyway.
plugins/reporters/asciidoc/src/main/kotlin/AsciiDocTemplateReporter.kt
Outdated
Show resolved
Hide resolved
class DocBookTemplateReporter : AsciiDocTemplateReporter() { | ||
@OrtPlugin( | ||
displayName = "DocBook Template Reporter", | ||
description = "Generates DocBook files from Apache Freemarker templates.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I somehow feel that mentioning AsciiDoc is at least equally important to mentioning Freemarker. So should we say "Generates DocBook from AsciiDoc files with Freemarker templates."
Similar below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the double "from" in "from AsciiDoc files from Apache Freemarker" does not read so nice now (I found my proposal from above better 😁), but we could improve that later.
internal val DEFAULT = PlainTextTemplateReporterConfig( | ||
templateIds = listOf("NOTICE_DEFAULT"), | ||
templatePaths = null | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this to the top level instead of wrapping it in a companion object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like scoping such constants, to me PlainTextTemplateReporterConfig.DEFAULT
also reads much better than DEFAULT_PLAIN_TEXT_TEMPLATE_REPORTER_CONFIG
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The discussion we once had in the core team came to the conclusion that such scoping is only useful for public properties. Or maybe it was non-private properties? Then you would be right for the internal
case. Let's keep it as-is then.
plugins/reporters/freemarker/src/main/kotlin/FreemarkerTemplateProcessor.kt
Show resolved
Hide resolved
ce7814f
to
54e1ad8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, comments are optional to address.
Make the `defaultValue` property of the `OrtPluginOption` annotation optional. As annotation properties cannot be nullable, define a constant to mark if the default value should be ignored. This is a preparation for adding more properties to the annotation. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add the property `OrtPluginOption.aliases` to define optional aliases for configuration options. This can be used to rename options in a backward-compatible way. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Convert `AsciiDocTemplateReporter` to an abstract class. This allows to simplify the constructor by making `backend` an abstract property. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Migrate the reporters to the new plugin API. Reporter implementations get their configuration options via the `generateReport` function. With the new plugin API the configuration options are provided as a constructor parameter. With this change both ways are supported to allow for a step-by-step migration in the following commits. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the reporter and use it instead of the options passed to the `generateReport` function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the reporter and use it instead of the options passed to the `generateReport` function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the reporter and use it instead of the options passed to the `generateReport` function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the reporter and use it instead of the options passed to the `generateReport` function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the reporter and use it instead of the options passed to the `generateReport` function. While add it, also add missing configuration options to the tests. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the reporter and use it instead of the options passed to the `generateReport` function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Use dedicated function arguments for the template IDs and paths in `FreemarkerTemplateProcessor` to make the API typesafe and prepare for introducing configuration classes for the related reporters. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a config class for the `PlainTextTemplateReporter` and use it instead of the options passed to the `generateReport` function. While at it, improve the configuration option names to be plural but keep supporting the old names for compatibility. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add config classes for the reporters and use them instead of the options passed to the `generateReport` function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add config classes for the reporters and use them instead of the options passed to the `generateReport` function. Several tests that unsure the presence of configuration options can be removed, because this is now done by the generated plugin factory. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
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>
54e1ad8
to
d902e04
Compare
Migrate the reporter to the new plugin API, see the commit messages for details.