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(cargo): Treat projects outside the analyer root as packages #8574

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

sschuberth
Copy link
Member

E.g. when analyzing a single Cargo project in a sub-directory with a cargo.toml file that points to "path dependencies" in a parent directory, these dependencies should not be seen as projects but as packages. This restores the behavior from before 7522a0c.

Resolves #8571.

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.70%. Comparing base (7c74524) to head (83c7d62).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8574   +/-   ##
=========================================
  Coverage     67.70%   67.70%           
  Complexity     1007     1007           
=========================================
  Files           246      246           
  Lines          7924     7924           
  Branches        883      883           
=========================================
  Hits           5365     5365           
  Misses         2176     2176           
  Partials        383      383           
Flag Coverage Δ
funTest-docker 66.49% <ø> (ø)
funTest-non-docker 34.71% <ø> (ø)
test 37.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.

@sschuberth sschuberth requested review from fviernau and a team April 26, 2024 09:16
@sschuberth sschuberth force-pushed the cargo-oot-packages branch 2 times, most recently from a18952e to 92a8819 Compare April 26, 2024 10:42
@sschuberth sschuberth requested review from fviernau and a team April 26, 2024 10:43
}

return listOf(ProjectAnalyzerResult(project, nonProjectPackages))
}
}

private fun CargoMetadata.Package.isProject() = source == null
/**
* Return the local path for this Cargo package if applicable, or null if the Cargo package is not local.
Copy link
Member

Choose a reason for hiding this comment

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

Is this always an absolute path and should it be mentioned in the docs or even checked with an assertion?
(I'm asking this because the startWith() check within isProject() seems to rely on that)

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this always an absolute path

Yes, because it's derived from definitionFile which is guaranteed to be absolute.

should it be mentioned in the docs or even checked with an assertion?

I'm simply calling absoluteFile now to make it work in any case.

Copy link
Member

@fviernau fviernau Apr 26, 2024

Choose a reason for hiding this comment

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

Yes, because it's derived from definitionFile which is guaranteed to be absolute.

My question was about the File returned by getLocalPath() not about the parent of the definitionFile.
So, should the absoluteFile call be moved into getLocalPath() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's also guaranteed to be absolute (as it's derived from a URI).

Copy link
Member

@fviernau fviernau Apr 26, 2024

Choose a reason for hiding this comment

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

Would a require check make sense / mention in the function docs of getLocalPath() ? ..ort rather .also {checkState(it.isAbsolute) } ?

plugins/package-managers/cargo/src/main/kotlin/Cargo.kt Outdated Show resolved Hide resolved
@sschuberth sschuberth requested review from fviernau and a team April 26, 2024 13:52
E.g. when analyzing a single Cargo project in a sub-directory with a
`cargo.toml` file that points to "path dependencies" in a parent
directory, these dependencies should not be seen as projects but as
packages. This restores the behavior from before 7522a0c.

Resolves #8571.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth merged commit 4dd1612 into main Apr 26, 2024
22 checks passed
@sschuberth sschuberth deleted the cargo-oot-packages branch April 26, 2024 17:01
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.

[BUG] Cargo: submodules and local packages are being skipped
2 participants