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

Allow configuring what dependencies may appear in public API #121

Open
djc opened this issue Sep 2, 2022 · 4 comments
Open

Allow configuring what dependencies may appear in public API #121

djc opened this issue Sep 2, 2022 · 4 comments
Labels
C-enhancement Category: raise the bar on expectations

Comments

@djc
Copy link

djc commented Sep 2, 2022

Describe your use case

There has long been an RFC for "private" dependencies, which would help crates ascertain that they don't depend on a (particular version of) a crate in public API. Unfortunately it seems like doing this is complex enough in Cargo that no one has gotten around to it.

From reading your blog post it seems like this tool would have access to all the relevant data to allow it to warn when a dependency’s type or trait appears in public API.

This is an important part of semver since bumping a public dependency across a semver-incompatible boundary of course means your own semver is affected, too.

Describe the solution you'd like

It would be great if there was a way to configure this tool to allow or deny dependencies from appearing in public API.

Alternatives, if applicable

No response

Additional Context

No response

@djc djc added the C-enhancement Category: raise the bar on expectations label Sep 2, 2022
@epage
Copy link
Collaborator

epage commented Sep 2, 2022

There has long been an RFC for "private" dependencies, which would help crates ascertain that they don't depend on a (particular version of) a crate in public API.

The RFC: https://rust-lang.github.io/rfcs/1977-public-private-dependencies.html

@obi1kenobi
Copy link
Owner

This is a good idea — thanks for opening this issue. The Trustfall query engine that cargo-semver-checks is built on can definitely pull this off, and I think what you describe would benefit users and should exist.

In my mind, this check is super valuable, but not quite semver: it prevents a semver hazard (deny dependencies from appearing in API) rather than finding and reporting a semver violation. Semver violation lints check some predicate across crate versions, like "struct field used to exist but is now gone." The query here would only need the current version of the crate, and would look for "types from crates not on approved list that leak through the public API."

In the interest of merging cargo-semver-checks into cargo as soon as possible (#61), @epage and I have decided to keep the cargo-semver-checks scope limited to only checking for semver issues. The best way forward for this issue would be through making the query interface available as a library (#67), and then running the custom query this issue describes (tangentially, #38).

When #67 is resolved, would you be interested in working together to build the functionality you described? I'd be more than happy to mentor.

That would help create this capability faster, because there are only so many things I can build at a time all by myself 😅

@epage
Copy link
Collaborator

epage commented Sep 2, 2022

I have decided to keep the cargo-semver-checks scope limited to only checking for semver issues

To add a little nuance, cargo-semver-checks would be for linting API changes which, in theory, can cover more than just semver, but would not be for linting a snapshot of an API.

@djc
Copy link
Author

djc commented Sep 5, 2022

I understand that this doesn't quite fit with the core problem this tool seeks to solve, but I think it's an important part in practice of solving the same problem; additionally, I don't think creating multiple tools that solve slightly different aspects of the same core issue (fearless upgrades) is a net benefit for downstream users, who would likely be better served by an integrated experience.

Also sorry, but I probably won't have time to write code for this in the near future -- I have too many obligations across the projects I maintain already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: raise the bar on expectations
Projects
None yet
Development

No branches or pull requests

3 participants