Skip to content

Commit

Permalink
chore: update lints
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Jul 26, 2024
1 parent 9172a79 commit 47d76b0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
31 changes: 27 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,54 @@ serial_test = { version = "3.0.0", default-features = false }
tempfile = { version = "3.9.0", default-features = false }

[lints.rust]
# https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
explicit_outlives_requirements = "warn"
missing_docs = "warn"
# unreachable_pub = "warn"
unsafe_code = "forbid"
non_ascii_idents = "deny"
redundant-lifetimes = "warn"
single-use-lifetimes = "warn"
unit-bindings = "warn"
unused_crate_dependencies = "warn"
unused-lifetimes = "warn"
unused-qualifications = "warn"

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
too_many_lines = "allow"
# from clippy::restrictions
# below lints are from clippy::restriction, and assume clippy >= 1.80
# https://rust-lang.github.io/rust-clippy/master/index.html#/?levels=allow&groups=restriction
clone_on_ref_ptr = "warn"
dbg_macro = "warn"
empty_enum_variants_with_brackets = "warn"
expect_used = "warn"
fn_to_numeric_cast_any = "warn"
format_push_string = "warn"
if_then_some_else_none = "warn"
impl_trait_in_params = "warn"
infinite_loop = "warn"
lossy_float_literal = "warn"
missing_docs_in_private_items = "warn"
mixed_read_write_in_expression = "warn"
multiple_inherent_impl = "warn"
needless_raw_strings = "warn"
panic = "warn"
pub_without_shorthand = "warn"
redundant_type_annotations = "warn"
ref_patterns = "warn"
renamed_function_params = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_name_method = "warn"
self_named_module_files = "warn"
semicolon_inside_block = "warn"
shadow_unrelated = "warn"
str_to_string = "warn"
string_slice = "warn"
string_to_string = "warn"
tests_outside_test_module = "warn"
try_err = "warn"
undocumented_unsafe_blocks = "warn"
unnecessary_safety_comment = "warn"
unnecessary_safety_doc = "warn"
unneeded_field_pattern = "warn"
unseparated_literal_suffix = "warn"
unwrap_used = "warn"
verbose_file_reads = "warn"
4 changes: 4 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allow-expect-in-tests = true
allow-panic-in-tests = true
allow-unwrap-in-tests = true
avoid-breaking-exported-api = false
2 changes: 0 additions & 2 deletions src/device/drive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Block device drive

#![allow(dead_code)]

use std::{
fmt,
io::BufRead,
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn sleep(dur: Duration, exit_rx: &mpsc::Receiver<()>) {
let _ = exit_rx.recv_timeout(dur);
}

#[allow(clippy::too_many_lines)]
fn main() -> anyhow::Result<()> {
// Parse cl args
let args = cl::Args::parse();
Expand Down
4 changes: 2 additions & 2 deletions src/probe/smartctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mod tests {
fn test_sct_probe_temp() {
let _smartctl = BinaryMock::new(
"smartctl",
r"smartctl 7.0 2018-12-30 r4883 [x86_64-linux-4.19.36-1-lts] (local build)
"smartctl 7.0 2018-12-30 r4883 [x86_64-linux-4.19.36-1-lts] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
Expand Down Expand Up @@ -218,7 +218,7 @@ Vendor specific:
fn test_attrib_probe_temp() {
let _smartctl = BinaryMock::new(
"smartctl",
r"smartctl 7.0 2018-12-30 r4883 [x86_64-linux-4.19.36-1-lts] (local build)
"smartctl 7.0 2018-12-30 r4883 [x86_64-linux-4.19.36-1-lts] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
Expand Down
11 changes: 4 additions & 7 deletions src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

// See https://docs.kernel.org/hwmon/pwm-fan.html

#![allow(dead_code)]

use std::{
fmt,
io::{self, ErrorKind},
Expand Down Expand Up @@ -162,7 +160,6 @@ impl fmt::Display for Pwm {
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
pub mod tests {
use std::{
fs::{create_dir, File, OpenOptions},
Expand All @@ -178,11 +175,11 @@ pub mod tests {
use super::*;

pub struct FakePwm {
dir: TempDir,
_dir: TempDir,
pub pwm_path: PathBuf,
pub val_file_read: File,
val_file_write: File,
rpm_file_read: File,
_rpm_file_read: File,
rpm_file_write: File,
mode_file_read: File,
pub mode_file_write: File,
Expand Down Expand Up @@ -226,11 +223,11 @@ pub mod tests {
symlink(device_path, device_link).unwrap();

Self {
dir,
_dir: dir,
pwm_path,
val_file_read,
val_file_write,
rpm_file_read,
_rpm_file_read: rpm_file_read,
rpm_file_write,
mode_file_read,
mode_file_write,
Expand Down

0 comments on commit 47d76b0

Please sign in to comment.