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

Implement new_struct_added lint #495

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

u9g
Copy link
Contributor

@u9g u9g commented Jul 13, 2023

No description provided.

@u9g u9g closed this Jul 13, 2023
@u9g u9g changed the title begin implementing new_struct_added Implement new_struct_added ling Jul 13, 2023
@u9g u9g changed the title Implement new_struct_added ling Implement new_struct_added lint Jul 13, 2023
@u9g u9g reopened this Jul 14, 2023
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Sorry, like I mentioned over Discord, this is blocked on having a more granular way to control the lint level (allow / warn / error / forbid): #58

Otherwise we'll end up having a bunch of upset users when we ship this.

Comment on lines +7 to +9
// TODO: Change the reference link to point to the cargo semver reference
// once it has a section on attribute #[must_use].
reference_link: Some("https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute"),
Copy link
Owner

Choose a reason for hiding this comment

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

This seems like copy-pasta, change it to None for now.

Comment on lines +14 to +34
item {
... on Struct {
name @tag(name: "new_crate_name") @output(name: "new_struct_added_name")
visibility_limit @filter(op: "=", value: ["$public"])

span_: span {
filename @output
begin_line @output
}
}
}
}

baseline {
item @fold @transform(op: "count") @filter(op: "=", value: ["$zero"]) {
... on Struct {
name @filter(op: "=", value: ["%new_crate_name"])
visibility_limit @filter(op: "=", value: ["$public"])
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

This will actually also fire on structs that are just moved, renamed, and re-exported in their original place under their new name, which is a false-positive unless there's a new name in the public API.

You'll need to use importable_path to avoid that.

"span_filename": String("src/structs.rs"),
},
],
}
Copy link
Owner

Choose a reason for hiding this comment

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

This is lacking a trailing newline, please configure your editor to add them automatically.

id: "new_struct_added",
human_readable_name: "new struct added",
description: "A new public struct has been exposed.",
required_update: Minor,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
required_update: Minor,
required_update: Minor,
lint_level: Allow,

or

Suggested change
required_update: Minor,
required_update: Minor,
lint_level: Warn,

With the new version of cargo-semver-checks, it is now possible to have allow-by-default and warn-by-default checks.

Copy link
Owner

Choose a reason for hiding this comment

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

I'd probably make this Allow by default. I'm sure many users will want to opt-in, but it might be a bit noisy to enable for everyone.

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