Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions content/wiki/canonical_lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All Linebender projects should include the following set of lints:
# This one may vary depending on the project.
rust.unsafe_code = "forbid"

# LINEBENDER LINT SET - Cargo.toml - v6.1
# LINEBENDER LINT SET - Cargo.toml - v7
# See https://linebender.org/wiki/canonical-lints/
rust.keyword_idents_2024 = "forbid"
rust.non_ascii_idents = "forbid"
Expand All @@ -27,12 +27,14 @@ rust.unreachable_pub = "warn"
rust.unused_import_braces = "warn"
rust.unused_lifetimes = "warn"
rust.unused_macro_rules = "warn"
rust.unused_qualifications = "warn"

clippy.too_many_arguments = "allow"

clippy.allow_attributes_without_reason = "warn"
clippy.cast_possible_truncation = "warn"
clippy.collection_is_never_read = "warn"
clippy.default_trait_access = "warn"
clippy.dbg_macro = "warn"
clippy.debug_assert_with_mut_call = "warn"
clippy.doc_markdown = "warn"
Expand Down Expand Up @@ -104,34 +106,22 @@ These lints can be run occasionally, such as when releases are near, to improve
let_underscore_drop
single_use_lifetimes
unit_bindings
unused_qualifications
variant_size_differences

clippy::allow_attributes
clippy::large_include_file
clippy::match_same_arms
clippy::partial_pub_fields
clippy::default_trait_access
clippy::return_self_not_must_use
clippy::shadow_unrelated
```

As a runnable command, there are:

```sh
cargo clippy -- -W let_underscore_drop -W single_use_lifetimes -W unit_bindings -W unused_qualifications -W variant_size_differences -W clippy::large_include_file -W clippy::match_same_arms -W clippy::partial_pub_fields -W clippy::default_trait_access -W clippy::return_self_not_must_use -W clippy::shadow_unrelated
cargo clippy -- -W let_underscore_drop -W single_use_lifetimes -W unit_bindings -W variant_size_differences -W clippy::large_include_file -W clippy::match_same_arms -W clippy::partial_pub_fields -W clippy::return_self_not_must_use -W clippy::shadow_unrelated
```

You may also wish to enable some of these lints specifically in your editor, to improve as you go.
The ones which are trivial to do this for are below (as the changes it will propose are always very small):

```sh
cargo clippy -- -W single_use_lifetimes -W unit_bindings -W unused_qualifications -W clippy::allow_attributes -W clippy::default_trait_access
```

If there are many failures of one of these lints across the project, a separate PR would be recommended.
Otherwise, resolving these in a drive-by manner is fine.

### Pedantic

You may occasionally want to run `cargo clippy` with `clippy::pedantic` on the codebase, which will cast a very wide net and catch a lot of very minor issues.
Expand Down