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

Add canonical lint set #68

Merged
merged 4 commits into from
Oct 17, 2024
Merged

Add canonical lint set #68

merged 4 commits into from
Oct 17, 2024

Conversation

PoignardAzur
Copy link
Contributor

No description provided.

Comment on lines 63 to 65
# This catches duplicated dependencies in the tree, which we don't have much control over
# We should use cargo deny for this, anyway
clippy.cargo = { level = "warn", priority = -1 }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from Peniko, but I have no idea what priority does, and I think the comment is a little too vague.

This part should probably be fixed up.

PoignardAzur added a commit to linebender/peniko that referenced this pull request Oct 16, 2024
@PoignardAzur
Copy link
Contributor Author

I've applied the lint set to peniko in linebender/peniko#56 as an example.

It seems to compile without issue, so I'd say this PR is ready to merge.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

Looks good, just a few details to clean up.

It'll be good to get these documented!

@@ -9,7 +9,14 @@ All Linebender projects should include the following set of lints in their `Carg
# This one may vary depending on the project.
rust.unsafe_code = "forbid"

# These two should be added to projects with an MSRV of 1.81 or higher
Copy link
Member

Choose a reason for hiding this comment

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

Why special case these? The lints themselves already check the msrv to see if they should run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because actually addressing these lints requires features (expect annotations and allow reasons) that came out in 1.81.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I follow. These lints only trigger if your package's MSRV is above 1.81 anyway, so why does it matter if you need features from Rust 1.81 to address them? If you're getting this error, surely you have those features?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the lints are basically no-ops if rust-version = "1.80", even if the user has a Rust 1.81 compiler?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah.

clippy.allow_attributes = "warn"
# Combined with allow_attributes, this is expected to trigger on module-wide or crate-wide `#![allow(...)]` attributes.
clippy.allow_attributes_without_reason = "warn"

# LINEBENDER LINT SET
Copy link
Member

Choose a reason for hiding this comment

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

Can we have versioning here? Keeping up with updates otherwise isn't ideal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

And in their `lib.rs`:

```rust
// These two aren't included in Cargo.toml because they
Copy link
Member

@DJMcNab DJMcNab Oct 16, 2024

Choose a reason for hiding this comment

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

I'd probably lean towards having them in a "versioned"/tagged block as well, with a similar link as in Cargo.toml.
I might also want to have them in a single warn, but I can see the stylistic reason not to do so.

Also, there are three lints here. I'd just remove the word "two" here to make that slightly less confused


To keep this process simple, avoid modifying this list in individual projects.
If you want to add other per-project lints, add them besides the list.
If you want to remove a lint, `#![allow]` or `#![expect]` it at the project root.
Copy link
Member

Choose a reason for hiding this comment

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

How would this work for clippy::multiple_crate_versions. I don't think setting this in lib.rs does anything, and most of our projects are likely to fail this.

If you think a new lint should be added to Linebender projects, add it to this file in alphabetical order, then copy-paste the list across projects.

To keep this process simple, avoid modifying this list in individual projects.
If you want to add other per-project lints, add them besides the list.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If you want to add other per-project lints, add them besides the list.
If you want to add other per-project lints, add them above the list.


To keep this process simple, avoid modifying this list in individual projects.
If you want to add other per-project lints, add them besides the list.
If you want to remove a lint, `#![allow]` or `#![expect]` it at the project root.
Copy link
Member

Choose a reason for hiding this comment

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

The "project root" as you use it here doesn't exist for multi-crate projects (which is any with even an example, or a workspace). Can we say "crate root" here instead please?

@PoignardAzur
Copy link
Contributor Author

I removed clippy::multiple_crate_versions for now We can always run it in a separate pass, but I don't want this documentation to be a giant pile of caveats, so I'm just not mentioning it.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

Looks good. One small tweak, but I'm open to not including one or both parts of it

// shouldn't apply to examples and tests
#![warn(unused_crate_dependencies)]
#![warn(clippy::print_stdout, clippy::print_stderr)]
```
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
```
// END LINEBENDER LINT SET
// (crate specific exceptions go here, as needed)
```

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem with the // END comment is that rustfmt really wants line comments to be next to the following items.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// (crate specific exceptions go here, as needed)

I think that's too much detail.

@PoignardAzur PoignardAzur merged commit 302e80b into main Oct 17, 2024
1 check passed
@PoignardAzur PoignardAzur deleted the add_lint_set branch October 17, 2024 12:03
github-merge-queue bot pushed a commit to linebender/peniko that referenced this pull request Oct 21, 2024
Apply lint set defined in
linebender/linebender.github.io#68

---------

Co-authored-by: Daniel McNab <[email protected]>
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