@@ -11,7 +11,8 @@ Exceptions can (and sometimes should) be made, however:
11
11
* [ Toolchain] ( #toolchain )
12
12
* [ Basic Rules] ( #basic-rules )
13
13
* [ Creating a new crate] ( #creating-a-new-crate )
14
- * [ Exceptions for clippy] ( #exceptions-for-clippy )
14
+ * [ Motivation for enabling lints] ( #motivation-for-enabling-lints )
15
+ * [ Exceptions for clippy] ( #exceptions-for-clippy )
15
16
* [ Guidelines] ( #guidelines )
16
17
* [ Prefer references over generics] ( #prefer-references-over-generics )
17
18
* [ Abbreviations and naming things] ( #abbreviations-and-naming-things )
@@ -59,25 +60,26 @@ before submitting a PR
59
60
60
61
### Creating a new crate
61
62
62
- We add the following preamble to all crates' ` lib.rs ` :
63
+ All rust projects must have the same ` Cargo.toml ` , ` clippy.toml ` , ` deny.toml ` , ` nextest.toml ` , ` rust-toolchain.toml `
64
+ and ` rustfmt.toml ` configurations as defined in the ` catalyst-ci ` repository in the [ ` stdcfgs ` folder] [ rust-stdcfgs ] .
65
+ See also [ examples] [ rust-examples ] in the same repository.
63
66
64
- ``` rust
65
- #![warn(clippy:: pedantic)]
66
- #![forbid(clippy:: integer_arithmetic)]
67
- #![forbid(missing_docs)]
68
- #![forbid(unsafe_code)]
69
- #![allow(/* known bad lints outlined below */ )]
70
- ```
67
+ [ rust-stdcfgs ] : https://github.com/input-output-hk/catalyst-ci/tree/master/earthly/rust/stdcfgs
68
+ [ rust-examples ] : https://github.com/input-output-hk/catalyst-ci/tree/master/examples/rust
69
+
70
+ #### Motivation for enabling lints
71
71
72
- We enable ` #![forbid(missing_docs)] ` for a couple of reasons:
72
+ Generally we prefer to enable all meaningful lints to prevent as many potential errors as possible.
73
+
74
+ We enable ` #![deny(missing_docs)] ` for a couple of reasons:
73
75
74
76
* it forces developers to write doc comments for publicly exported items
75
77
* it serves as a reminder that the item you're working on is part of your ** public API**
76
78
77
- We enable ` #![forbid (unsafe_code)] ` to reinforce the fact that ** unsafe code should not be mixed in with the rest of our code** .
79
+ We enable ` #![deny (unsafe_code)] ` to reinforce the fact that ** unsafe code should not be mixed in with the rest of our code** .
78
80
More details are below.
79
81
80
- We enable ` #![forbid(integer_arithmetic )] ` to prevent you from writing code like:
82
+ We enable ` #![deny(arithmetic_side_effects )] ` to prevent you from writing code like:
81
83
82
84
``` rust
83
85
let x = 1 ;
@@ -100,20 +102,11 @@ By forbidding integer arithmetic, you have to choose a behaviour, by writing eit
100
102
By being explicit, we prevent the developer from "simply not considering" how their code behaves in the presence of overflows.
101
103
In a ledger application, silently wrapping could be catastrophic, so we really want to be explicit about what behaviour we expect.
102
104
103
- ### Exceptions for ` clippy `
104
-
105
- These lints are disabled:
105
+ #### Exceptions for ` clippy `
106
106
107
- * ` clippy::match_bool ` - sometimes a ` match ` statement with ` true => ` and ` false => ` arms is sometimes more concise and equally readable
108
- * ` clippy::module_name_repetition ` - warns when creating an item with a name than ends with the name of the module it's in
109
- * ` clippy::derive_partial_eq_without_eq ` - warns when deriving ` PartialEq ` and not ` Eq ` .
110
- This is a semver hazard. Deriving ` Eq ` is a stronger semver guarantee than just ` PartialEq ` , and shouldn't be the default.
111
- * ` clippy::missing_panics_doc ` - this lint warns when a function might panic, but the docs don't have a ` panics ` section.
112
- This lint is buggy, and doesn't correctly identify all panics.
113
- Code should be written to explicitly avoid intentional panics.
114
- You should still add panic docs if a function is ** intended to panic** under some conditions.
115
- If a panic may occur, but you'd consider it a bug if it did, don't document it.
116
- We disable this lint because it creates a false sense of security.
107
+ While all lints are enabled by default, there are some cases when it is acceptable to suppress a lint locally. Still
108
+ one shouldn't do that without good reasons. For example, it is often ok to allow ` clippy::module_name_repetitions `
109
+ especially if the type is reexported.
117
110
118
111
## Guidelines
119
112
0 commit comments