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

refactor(poetry): Improve the definition file paths #7624

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

fviernau
Copy link
Member

@fviernau fviernau commented Oct 4, 2023

In order to do it's job, Poetry.kt generates a requirements file and then relies on Pip.kt to do the analysis. The resulting ProjectAnalyzerResults uses the paths to these generated requirements files as definiton file paths. This does not make sense, because:

  1. The generation of the files is an implementation detail.
  2. The generated files do not exist in the code repository which can lead to confusion, in particular also these get referenced from ORT configuration / path excludes.

Fix that by patching up the ProjectAnalyzerResults to recover the original definition file name.

@fviernau fviernau requested a review from a team as a code owner October 4, 2023 09:43
@fviernau fviernau force-pushed the poetry-definition-file-name branch from a11f3b1 to c2a6eba Compare October 4, 2023 09:44
In order to do it's job, `Poetry.kt` generates a requirements file and
then relies on `Pip.kt` to do the analysis. The resulting
`ProjectAnalyzerResult`s uses the paths to these generated requirements
files as definiton file paths. This does not make sense, because:

1. The generation of the files is an implementation detail.
2. The generated files do not exist in the code repository which can
   lead to confusion, in particular also these get referenced from
   ORT configuration / path excludes.

Fix that by patching up the `ProjectAnalyzerResult`s to recover the
original definition file name.

Signed-off-by: Frank Viernau <[email protected]>
@fviernau fviernau force-pushed the poetry-definition-file-name branch from c2a6eba to 8882bf0 Compare October 4, 2023 09:44
@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (13a4714) 68.03% compared to head (8882bf0) 68.03%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7624   +/-   ##
=========================================
  Coverage     68.03%   68.03%           
  Complexity     2022     2022           
=========================================
  Files           344      344           
  Lines         16725    16725           
  Branches       2371     2371           
=========================================
  Hits          11379    11379           
  Misses         4363     4363           
  Partials        983      983           
Flag Coverage Δ
funTest-non-docker 36.44% <ø> (ø)
test 35.55% <ø> (ø)

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.

.map { projectAnalyzerResult ->
projectAnalyzerResult.copy(
project = projectAnalyzerResult.project.copy(
definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path
Copy link
Member

Choose a reason for hiding this comment

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

I propose definitionFile.relativeTo(analysisRoot) instead to avoid adding more code that relies on the project to be version controlled.

Copy link
Member Author

Choose a reason for hiding this comment

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

This does not introduce the requirement, because code which computes the value for definitionFilePath already relies on that prior to this change. Furthermore, relativeTo(analysisRoot) seems wrong because the definition file path is not meant to be relative to the analysis root, but the repository root.

Copy link
Member

Choose a reason for hiding this comment

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

This does not introduce the requirement

And I didn't say that. I was talking about adding more code with that requirement.

Furthermore, relativeTo(analysisRoot) seems wrong because the definition file path is not meant to be relative to the analysis root, but the repository root.

Indeed Project.definitionFilePath is documented like that 😞 IMO that's a mistake already, and it will make our lives harder in order to address #2896.

Anyway, we already have a bunch of code like that, so we can bulk-address this later, I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I didn't say that. I was talking about adding more code with that requirement.

I know, I didn't mean to say that you said that. I only intended to clarify that both, the old and the new code path depend on that same logic.

@fviernau fviernau enabled auto-merge (rebase) October 4, 2023 10:47
@fviernau fviernau merged commit f833fee into main Oct 4, 2023
@fviernau fviernau deleted the poetry-definition-file-name branch October 4, 2023 10:49
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