Skip to content

Commit

Permalink
lint: fix some noisy clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxt committed Oct 10, 2024
1 parent 7d29937 commit 730e185
Show file tree
Hide file tree
Showing 26 changed files with 173 additions and 167 deletions.
4 changes: 2 additions & 2 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl Action {
}
}

#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CopyTarget {
Line,
Commandline(SupportedShell),
Expand All @@ -89,7 +89,7 @@ pub enum CopyTarget {
EnvDiff,
}

#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SupportedShell {
Bash,
Sh,
Expand Down
6 changes: 3 additions & 3 deletions src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use cfg_if::cfg_if;
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
pub mod x86_64;
pub(crate) use x86_64::*;
pub use x86_64::*;
} else if #[cfg(target_arch = "aarch64")] {
pub mod aarch64;
pub(crate) use aarch64::*;
pub use aarch64::*;
} else if #[cfg(target_arch = "riscv64")] {
pub mod riscv64;
pub(crate) use riscv64::*;
pub use riscv64::*;
} else {
compile_error!("unsupported architecture");
}
Expand Down
2 changes: 1 addition & 1 deletion src/bpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl EbpfTracer {
.as_ref()
.map(|tx| filterable_event!(TraceeSpawn(child)).send_if_match(tx, self.filter))
.transpose()?;
if let TracerMode::Log { foreground: true } = &self.mode {
if matches!(&self.mode, TracerMode::Log { foreground: true }) {
match tcsetpgrp(stdin(), child) {
Ok(_) => {}
Err(Errno::ENOTTY) => {
Expand Down
2 changes: 1 addition & 1 deletion src/bpf/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use enumflags2::bitflags;

#[bitflags]
#[repr(u32)]
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[allow(non_camel_case_types)]
#[allow(clippy::upper_case_acronyms)]
pub enum BpfEventFlags {
Expand Down
4 changes: 2 additions & 2 deletions src/bpf/process_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ impl ProcessTracker {
}

#[allow(unused)]
pub fn associated_events(&mut self, pid: Pid) -> &[u64] {
pub fn associated_events(&self, pid: Pid) -> &[u64] {
&self.processes.get(&pid).unwrap().associated_events
}

pub fn maybe_associated_events(&mut self, pid: Pid) -> Option<&[u64]> {
pub fn maybe_associated_events(&self, pid: Pid) -> Option<&[u64]> {
self
.processes
.get(&pid)
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Cli {
}

pub fn generate_completions(shell: clap_complete::Shell) {
let mut cmd = Cli::command();
let mut cmd = Self::command();
clap_complete::generate(shell, &mut cmd, env!("CARGO_CRATE_NAME"), &mut stdout())
}

Expand Down
4 changes: 2 additions & 2 deletions src/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub enum ConfigLoadError {
}

impl Config {
pub fn load(path: Option<PathBuf>) -> Result<Config, ConfigLoadError> {
pub fn load(path: Option<PathBuf>) -> Result<Self, ConfigLoadError> {
let config_text = match path {
Some(path) => std::fs::read_to_string(path)?, // if manually specified config doesn't exist, return a hard error
None => {
Expand All @@ -47,7 +47,7 @@ impl Config {
}
};

let config: Config = toml::from_str(&config_text)?;
let config: Self = toml::from_str(&config_text)?;
Ok(config)
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/cli/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use clap::ValueEnum;
use serde::{Deserialize, Serialize};
use strum::Display;

#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Display)]
#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq, Display)]
#[strum(serialize_all = "kebab-case")]
pub enum Color {
Auto,
Always,
Never,
}

#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Display, Default, Deserialize, Serialize)]
#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq, Display, Default, Deserialize, Serialize)]
#[strum(serialize_all = "kebab-case")]
pub enum SeccompBpf {
#[default]
Expand All @@ -19,15 +19,17 @@ pub enum SeccompBpf {
Off,
}

#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Display, Default, Deserialize, Serialize)]
#[derive(
Debug, Clone, Copy, ValueEnum, PartialEq, Eq, Display, Default, Deserialize, Serialize,
)]
#[strum(serialize_all = "kebab-case")]
pub enum ActivePane {
#[default]
Terminal,
Events,
}

#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Display, Deserialize, Serialize)]
#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq, Display, Deserialize, Serialize)]
#[strum(serialize_all = "kebab-case")]
pub enum ExportFormat {
// https://jsonlines.org/
Expand Down
2 changes: 1 addition & 1 deletion src/cmdbuilder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn get_shell() -> String {

/// `CommandBuilder` is used to prepare a command to be spawned into a pty.
/// The interface is intentionally similar to that of `std::process::Command`.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CommandBuilder {
args: Vec<OsString>,
cwd: Option<OsString>,
Expand Down
Loading

0 comments on commit 730e185

Please sign in to comment.