-
Notifications
You must be signed in to change notification settings - Fork 319
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 the Opossum reporter to KxS #9484
Migrate the Opossum reporter to KxS #9484
Conversation
7b1a948
to
b3aefdb
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9484 +/- ##
=========================================
Coverage 67.96% 67.96%
Complexity 1290 1290
=========================================
Files 249 249
Lines 8810 8810
Branches 915 915
=========================================
Hits 5988 5988
Misses 2433 2433
Partials 389 389
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
b3aefdb
to
98ee401
Compare
91b1609
to
4bf27e2
Compare
opossumInput.packageToRoot.values.forAll { levelForPath -> | ||
levelForPath.keys.forAll { path -> | ||
fileList shouldContain resolvePath(path) | ||
} | ||
} |
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.
Deleting this because otherwise I would have to write a separate test for OpossumInputCreator
(and make the property packageToRoot
non private, I guess).
But it seems like this test does not add much value. The same file paths are in resourcesToAttributions
, via addSignal
and later processing of pathToSignals
. And we have a test for paths in resourcesToAttributions
against the same list.
Hi @sschuberth, it is ready for review now. Let me know what you think. Removed the untyped maps. Serialization of the recursive data structure |
@@ -20,6 +20,9 @@ | |||
plugins { | |||
// Apply precompiled plugins. | |||
id("ort-plugin-conventions") | |||
|
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.
Commit message nits:
- We prefer imperative mood, i.e. "Migrates" should say "Migrate".
- We usually start capitalized after ":" in the title.
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 commit message body still uses simple present instead of imperative mood.
val followUp: Boolean = false, | ||
val excludeFromNotice: Boolean = false, | ||
val uuid: UUID = UUID.randomUUID() | ||
@Transient |
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.
Is this a left-over from not having an UUID serializer yet?
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.
No, but it can be solved differently, I realized. I removed the property and collect the signals in a map uuidToSignals
now. We could also collect them in a map signalsToUUID
but that would require to replace the current matches
method by overriding the equals
and hashCode
methods, I suppose. Would you prefer that? For now I didn't do it in the interest of keeping the diff smaller.
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.
but that would require to replace the current
matches
method by overriding theequals
andhashCode
methods, I suppose. Would you prefer that?
I guess not. In Kotlin, I try to avoid overriding equals
and hashCode
as much as possible in favor of auto-generate code.
But couldn't @Transient
then simply have been dropped and the original code be kept? Anyway, go for whatever causes less work for you.
preSelected = preSelected, | ||
followUp = OpossumFollowUp.FOLLOW_UP.takeIf { followUp }, | ||
excludeFromNotice = excludeFromNotice, | ||
comment = 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.
Nit: Please avoid trailing commas.
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.
Same in other places.
plugins/reporters/opossum/src/test/kotlin/OpossumReporterTest.kt
Outdated
Show resolved
Hide resolved
PS: @alexzurbonsen please also rebase to resolve conflicts. |
4bf27e2
to
abcdc42
Compare
3fe68ab
to
503fd35
Compare
Sorry for the detekt noise. Should be fixed now, I hope. |
503fd35
to
cba08df
Compare
Fixed the failing workflow. PR is ready for review again. |
Thanks a lot @alexzurbonsen! There are a bunch of more things I'd like to address, e.g. regarding the Git history as we do not allow catch-all "Add review feedback" commit but want the review comments address in the commit the review comments was made on. But I'll address these myself and take over your branch. Thanks again for all your work! |
@sschuberth Okay, thank you! If I can be of any help, let me know. I just saw that now detekt is failing on the functional test. May be it didn't get there before. But the fix is easy at least. |
Signed-off-by: Sebastian Schuberth <[email protected]>
Migrate the OpossumReporter plugin away from Jackson serialization to use kotlinx-serialization. To get properly typed data structures for serialization the previous untyped `Map<*, *>` are substituted by properly typed data classes. This leads to the creation of an `OpossumInputCreator` class that holds intermediate data structures needed for processing of the Reporter input. Signed-off-by: alexzurbonsen <[email protected]> Signed-off-by: Sebastian Schuberth <[email protected]>
cba08df
to
df473e8
Compare
@@ -20,6 +20,9 @@ | |||
plugins { | |||
// Apply precompiled plugins. | |||
id("ort-plugin-conventions") | |||
|
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 commit message body still uses simple present instead of imperative mood.
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.string.shouldContain | ||
import kotlinx.serialization.json.jsonArray |
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.
This needs an empty line before to group top-level imports. (Our custom Detekt rule would complain.)
val baseUrlsForSources: Map<String, String>, | ||
val externalAttributionSources: Map<String, OpossumExternalAttributionSource> | ||
) { | ||
fun getSignalsForFile(file: String): List<OpossumSignalFlat> = |
Check warning
Code scanning / QDJVMC
Unused symbol Warning
internal data class OpossumResources( | ||
val tree: MutableMap<String, OpossumResources> = mutableMapOf() | ||
) { | ||
fun addResource(pathPieces: List<String>) { |
Check notice
Code scanning / QDJVMC
Class member can have 'private' visibility Note
return isPathAFile(pathPieces) | ||
} | ||
|
||
fun isPathAFile(pathPieces: List<String>): Boolean { |
Check notice
Code scanning / QDJVMC
Class member can have 'private' visibility Note
return head !in tree || tree.getValue(head).isPathAFile(tail) | ||
} | ||
|
||
fun toFileList(): Set<String> = |
Check notice
Code scanning / QDJVMC
Class member can have 'private' visibility Note
return head !in tree || tree.getValue(head).isPathAFile(tail) | ||
} | ||
|
||
fun toFileList(): Set<String> = |
Check warning
Code scanning / QDJVMC
Unused symbol Warning
Thanks for finishing this. I like the idea of extracting the data model and creating a full functional test. |
[FOR REVIEW]: Best reviewed commit by commit. First commit of this PR contains the actual changes. Second commit just moves code around to improve readability.
Context
Closes #8839
Summary
Migrates the
OpossumReporter
plugin away from Jackson serialization to use kotlinx serialization.To get properly typed data structures for serialization the previous untyped
Map<*, *>
s are substituted by properly typed data classes. This leads to the creation of anOpossumInputCreator
class that holds intermediate data structures needed for processing of the Reporter input.Test Plan
OpossumReporterTest
OpossumReporterFunTest
repeat for each branch:
Unzip
report.opossum
files and validate the input.json s with this little python script:https://gist.github.com/alexzurbonsen/69e38586dcffbb6b988b010bbd096759