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

Various FossID refactorings #9728

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

mnonnenmacher
Copy link
Member

Various FossID refactorings to prepare for simplifying the configuration. See the commit messages for details.

@mnonnenmacher mnonnenmacher requested a review from a team as a code owner January 12, 2025 19:31
Copy link

codecov bot commented Jan 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.09%. Comparing base (b85af8b) to head (59f559e).

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           
Flag Coverage Δ
test-ubuntu-24.04 35.89% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -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
Copy link
Member

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?

Copy link
Member

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-].

Copy link
Member Author

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
Copy link
Member

@sschuberth sschuberth Jan 12, 2025

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 -?

Copy link
Member Author

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.

@sschuberth sschuberth requested a review from nnobelis January 12, 2025 19:59
Copy link
Member

@nnobelis nnobelis left a 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
Copy link
Member

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.

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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.

@sschuberth
Copy link
Member

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>
@mnonnenmacher mnonnenmacher force-pushed the simplify-fossid-config branch from 2196bf4 to 59f559e Compare January 13, 2025 17:05
@mnonnenmacher mnonnenmacher enabled auto-merge (rebase) January 13, 2025 17:06
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.

3 participants