Skip to content
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

fix(fossid-webapp): Replace version comparison with Semver #8353

Conversation

nnobelis
Copy link
Member

coerce needs to be used because FossID versions are not valid semantic versions e.g. "23.3".

This follows discussion on #8352.

@nnobelis nnobelis requested a review from a team as a code owner February 28, 2024 13:34
@@ -700,7 +702,9 @@ class FossId internal constructor(
// Scans that were added to the queue are interpreted as an error by FossID before version 2021.2.
// For older versions, `waitScanComplete()` is able to deal with queued scans. Therefore, not checking the
// response of queued scans.
if (version >= "2021.2" || scanResult.error != "Scan was added to queue.") {
if (Semver.coerce(version)?.isGreaterThan("2021.2.0") == true ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both comparisons should use isGreaterThanOrEqualTo() to match the original code. As that's quite long, consider doing something like

        val currentVersion = checkNotNull(Semver.coerce(version))
        val minVersion = checkNotNull(Semver.coerce("2021.2"))
        if (currentVersion >= minVersion || scanResult.error != "Scan was added to queue.") {

Similar below, and probably also in the test.

Copy link
Member Author

@nnobelis nnobelis Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done but I am not too sure about the checkNotNull though: If FossID does sometimes exotic one day in the future, e.g. 25.6-patch6, the integration will be broken ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, coerce turns "25.6-patch6" into "25.6.0", i.e. it's not null. So I thing we should be good.

@nnobelis nnobelis force-pushed the nnobelis/use_semver_4j_for_fossid branch from 50fd8a7 to 10fa5ed Compare February 29, 2024 07:02
@nnobelis nnobelis requested a review from sschuberth February 29, 2024 07:05
`coerce` needs to be used because FossID versions are not valid semantic
versions e.g. "23.3".

Signed-off-by: Nicolas Nobelis <[email protected]>
@nnobelis nnobelis force-pushed the nnobelis/use_semver_4j_for_fossid branch from 10fa5ed to bd4d853 Compare February 29, 2024 07:09
@sschuberth sschuberth merged commit eed25cf into oss-review-toolkit:main Feb 29, 2024
19 of 20 checks passed
@nnobelis nnobelis deleted the nnobelis/use_semver_4j_for_fossid branch November 20, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants