mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 08:23:24 +01:00
Setup global cargo
lint configuration (#13691)
# Description `cargo` somewhat recently gained the capability to store `lints` settings for the crate and workspace, that can override the defaults from `rustc` and `clippy` lints. This means we can enforce some lints without having to actively pass them to clippy via `cargo clippy -- -W ...`. So users just forking the repo have an easier time to follow similar requirements like our CI. ## Limitation An exception that remains is that those lints apply to both the primary code base and the tests. Thus we can't include e.g. `unwrap_used` without generating noise in the tests. Here the setup in the CI remains the most helpful. ## Included lints - Add `clippy::unchecked_duration_subtraction` (added by #12549) # User-Facing Changes Running `cargo clippy --workspace` should be closer to the CI. This has benefits for editor configured runs of clippy and saves you from having to use `toolkit` to be close to CI in more cases.
This commit is contained in:
parent
644bebf4c6
commit
84e1ac27e5
@ -180,6 +180,14 @@ windows = "0.54"
|
|||||||
windows-sys = "0.48"
|
windows-sys = "0.48"
|
||||||
winreg = "0.52"
|
winreg = "0.52"
|
||||||
|
|
||||||
|
[workspace.lints.clippy]
|
||||||
|
# Warning: workspace lints affect library code as well as tests, so don't enable lints that would be too noisy in tests like that.
|
||||||
|
# todo = "warn"
|
||||||
|
unchecked_duration_subtraction = "warn"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-cli = { path = "./crates/nu-cli", version = "0.97.2" }
|
nu-cli = { path = "./crates/nu-cli", version = "0.97.2" }
|
||||||
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.97.2" }
|
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.97.2" }
|
||||||
|
@ -47,3 +47,6 @@ which = { workspace = true }
|
|||||||
[features]
|
[features]
|
||||||
plugin = ["nu-plugin-engine"]
|
plugin = ["nu-plugin-engine"]
|
||||||
system-clipboard = ["reedline/system_clipboard"]
|
system-clipboard = ["reedline/system_clipboard"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -9,6 +9,9 @@ version = "0.97.2"
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
nu-parser = { path = "../nu-parser", version = "0.97.2" }
|
nu-parser = { path = "../nu-parser", version = "0.97.2" }
|
||||||
|
@ -12,6 +12,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.97.2" }
|
nu-cmd-base = { path = "../nu-cmd-base", version = "0.97.2" }
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
|
@ -11,6 +11,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
nu-parser = { path = "../nu-parser", version = "0.97.2" }
|
nu-parser = { path = "../nu-parser", version = "0.97.2" }
|
||||||
|
@ -9,6 +9,9 @@ version = "0.97.2"
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
nu-path = { path = "../nu-path", version = "0.97.2" }
|
nu-path = { path = "../nu-path", version = "0.97.2" }
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
|
@ -12,6 +12,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-cmd-base = { path = "../nu-cmd-base", version = "0.97.2" }
|
nu-cmd-base = { path = "../nu-cmd-base", version = "0.97.2" }
|
||||||
nu-color-config = { path = "../nu-color-config", version = "0.97.2" }
|
nu-color-config = { path = "../nu-color-config", version = "0.97.2" }
|
||||||
|
@ -13,6 +13,9 @@ proc-macro = true
|
|||||||
# so we cannot test anything useful in a doctest
|
# so we cannot test anything useful in a doctest
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = { workspace = true }
|
proc-macro2 = { workspace = true }
|
||||||
syn = { workspace = true }
|
syn = { workspace = true }
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.97.2" }
|
||||||
nu-path = { path = "../nu-path", version = "0.97.2" }
|
nu-path = { path = "../nu-path", version = "0.97.2" }
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
||||||
nu-parser = { path = "../nu-parser", version = "0.97.2" }
|
nu-parser = { path = "../nu-parser", version = "0.97.2" }
|
||||||
|
@ -15,3 +15,6 @@ bench = false
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
doc-comment = "0.3"
|
doc-comment = "0.3"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -30,3 +30,6 @@ nu-test-support = { path = "../nu-test-support", version = "0.97.2" }
|
|||||||
nu-path = { path = "../nu-path", version = "0.97.2" }
|
nu-path = { path = "../nu-path", version = "0.97.2" }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
fancy-regex = "0.13.0"
|
fancy-regex = "0.13.0"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -28,3 +28,6 @@ nu-command = { path = "../nu-command", version = "0.97.2" }
|
|||||||
nu-test-support = { path = "../nu-test-support", version = "0.97.2" }
|
nu-test-support = { path = "../nu-test-support", version = "0.97.2" }
|
||||||
|
|
||||||
assert-json-diff = "2.0"
|
assert-json-diff = "2.0"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -11,6 +11,9 @@ exclude = ["/fuzz"]
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
nu-path = { path = "../nu-path", version = "0.97.2" }
|
nu-path = { path = "../nu-path", version = "0.97.2" }
|
||||||
|
@ -19,3 +19,6 @@ omnipath = { workspace = true }
|
|||||||
|
|
||||||
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android")))'.dependencies]
|
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android")))'.dependencies]
|
||||||
pwd = { workspace = true }
|
pwd = { workspace = true }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
||||||
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.97.2", default-features = false }
|
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.97.2", default-features = false }
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
||||||
|
@ -244,7 +244,7 @@ mod tests {
|
|||||||
let mut state = test_state();
|
let mut state = test_state();
|
||||||
state.config.enabled = true;
|
state.config.enabled = true;
|
||||||
state.config.stop_after = Duration::from_secs(1).as_nanos() as i64;
|
state.config.stop_after = Duration::from_secs(1).as_nanos() as i64;
|
||||||
state.last_update = Some(now - Duration::from_secs(2));
|
state.last_update = Some(now.checked_sub(Duration::from_secs(2)).unwrap());
|
||||||
|
|
||||||
assert_eq!(Some(Duration::ZERO), state.next_timeout(now));
|
assert_eq!(Some(Duration::ZERO), state.next_timeout(now));
|
||||||
}
|
}
|
||||||
@ -295,7 +295,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn adding_locks_changes_last_update() {
|
fn adding_locks_changes_last_update() {
|
||||||
let mut state = test_state();
|
let mut state = test_state();
|
||||||
let original_last_update = Some(Instant::now() - Duration::from_secs(1));
|
let original_last_update =
|
||||||
|
Some(Instant::now().checked_sub(Duration::from_secs(1)).unwrap());
|
||||||
state.last_update = original_last_update;
|
state.last_update = original_last_update;
|
||||||
state.handle_message(PluginGcMsg::AddLocks(1));
|
state.handle_message(PluginGcMsg::AddLocks(1));
|
||||||
assert_ne!(original_last_update, state.last_update, "not updated");
|
assert_ne!(original_last_update, state.last_update, "not updated");
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2", features = ["plugin"] }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2", features = ["plugin"] }
|
||||||
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
||||||
|
@ -9,6 +9,9 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-test
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
nu-engine = { path = "../nu-engine", version = "0.97.2" }
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
||||||
|
@ -13,6 +13,9 @@ name = "nu_pretty_hex"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-ansi-term = { workspace = true }
|
nu-ansi-term = { workspace = true }
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
||||||
nu-path = { path = "../nu-path", version = "0.97.2" }
|
nu-path = { path = "../nu-path", version = "0.97.2" }
|
||||||
|
@ -14,3 +14,6 @@ nu-engine = { version = "0.97.2", path = "../nu-engine" }
|
|||||||
miette = { workspace = true, features = ["fancy-no-backtrace"] }
|
miette = { workspace = true, features = ["fancy-no-backtrace"] }
|
||||||
|
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -12,6 +12,9 @@ license = "MIT"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
nu-protocol = { path = "../nu-protocol", version = "0.97.2" }
|
||||||
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
||||||
|
@ -10,6 +10,9 @@ version = "0.97.2"
|
|||||||
[lib]
|
[lib]
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
nu-utils = { path = "../nu-utils", version = "0.97.2" }
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ version = "0.97.2"
|
|||||||
doctest = false
|
doctest = false
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-path = { path = "../nu-path", version = "0.97.2" }
|
nu-path = { path = "../nu-path", version = "0.97.2" }
|
||||||
nu-glob = { path = "../nu-glob", version = "0.97.2" }
|
nu-glob = { path = "../nu-glob", version = "0.97.2" }
|
||||||
|
@ -30,3 +30,6 @@ crossterm_winapi = "0.9"
|
|||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
nix = { workspace = true, default-features = false, features = ["user", "fs"] }
|
nix = { workspace = true, default-features = false, features = ["user", "fs"] }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
@ -18,3 +18,6 @@ fancy-regex = { workspace = true }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
chrono = { workspace = true }
|
chrono = { workspace = true }
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
Loading…
Reference in New Issue
Block a user