-
Notifications
You must be signed in to change notification settings - Fork 316
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
Various FossID refactorings #9728
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9728 +/- ##
=========================================
Coverage 68.09% 68.09%
Complexity 1294 1294
=========================================
Files 249 249
Lines 8846 8846
Branches 923 923
=========================================
Hits 6024 6024
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. |
@@ -116,8 +116,8 @@ class FossIdNamingProvider( | |||
} | |||
|
|||
/** | |||
* Replaces non-standard characters in branch name and trims its length to one that will not exceed | |||
* maximum length of FossID scan ID, when combined with the rest of variables | |||
* Replace characters in [branch] not matching `[a-zA-Z0-9-_]` with underscores and trim its length so that the |
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.
Instead of repeating the regex here, how about extracting it to a constant (which anyway would be good to avoid recompiling it on each call), and referring to that constant here instead?
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.
While at it, the regex could be simplified to [^\w-]
.
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 have added a commit on top for that.
@@ -37,7 +37,8 @@ import org.apache.logging.log4j.kotlin.logger | |||
* * **currentTimestamp**: The current time. | |||
* * **deltaTag** (scan code only): If delta scans are enabled, this qualifies the scan as an *origin* scan or a *delta* | |||
* scan. | |||
* * **branch**: The branch name (revision) to scan. | |||
* * **branch**: The branch name (revision) to scan. Characters not matching `[a-zA-Z0-9-_]` are replaced with |
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.
Also here, I wonder whether hard-coding the regex really makes sense. Maybe just say a bit lax "non-word characters", even if it does not exactly match \w
only, but also excludes -
?
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 have reworded the sentence to also explain the reason.
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.
LGTM
namingProjectPattern?.let { | ||
val builtins = mapOf( | ||
"#projectName" to projectName | ||
"#repositoryName" to repositoryName |
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.
Should we put the "breaking change" label on the PR ?
I don't remember ORT's policy.
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 should only be a breaking change if users are required to change their configuration. But my understanding is they don't, or?
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.
Yes they do (and I guess that's why @mnonnenmacher marked is as breaking in the commit message).
One of the builtin naming variable has been renamed. If ORT users are using it, they need to adapt their naming pattern with the new name.
For instance at Bosch we do.
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.
Should we put the "breaking change" label on the PR ?
Didn't we stop doing this when we started publishing release notes?
There will be more breaking changes in a follow-up, I just didn't include them here because I could not yet get the tests to work, but my hope is that I can get them in before the next release.
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.
Didn't we stop doing this when we started publishing release notes?
That's why I was asking, I was unsure.
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.
Ah, sorry, I was somehow missing the "label on the PR" part. No, we don't do that anymore.
a7bff56
to
2196bf4
Compare
There are real test failures now. |
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Rename the `projectName` variable used by the `FossIdNamingProvider` to `repositoryName` to make clear where it is coming from and to better distinguish it from the `namingProjectPattern`. 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>
This simplifies calling the function. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
This simplifies an upcoming change. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Calculating the values is cheap, so add them always to simplify the code. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
With the recent refactorings, the `createScanCodeForDefaultPattern` and `createScanCodeForCustomPattern` are almost identical, so inline them into `createScanCode` to reduce duplication. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
The function is only used internally and from tests. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Rename `convertGitUrlToProjectName` to `extractRepositoryName` to better describe what the function does. While at it, also improve the function docs and optimize the code a bit. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
While at it, also simplify the expression by using `\w`. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
2196bf4
to
59f559e
Compare
Various FossID refactorings to prepare for simplifying the configuration. See the commit messages for details.