Update clippy restrictions
type: changed
This commit is contained in:
parent
fa78cba0a5
commit
a787d6a964
|
@ -66,10 +66,7 @@ impl FromStr for Bytes {
|
||||||
fn from_str(text: &str) -> Result<Self, Self::Err> {
|
fn from_str(text: &str) -> Result<Self, Self::Err> {
|
||||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||||
fn is_digit(c: &char) -> bool {
|
fn is_digit(c: &char) -> bool {
|
||||||
match c {
|
matches!(c, '0'..='9' | '.')
|
||||||
'0'..='9' | '.' => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let digits = text.chars().take_while(is_digit).collect::<String>();
|
let digits = text.chars().take_while(is_digit).collect::<String>();
|
||||||
|
|
29
src/env.rs
29
src/env.rs
|
@ -9,11 +9,8 @@ pub(crate) struct Env {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Env {
|
impl Env {
|
||||||
pub(crate) fn main() -> Self {
|
pub(crate) fn main() -> Result<Self> {
|
||||||
let dir = match env::current_dir() {
|
let dir = env::current_dir().context(error::CurrentDirectoryGet)?;
|
||||||
Ok(dir) => dir,
|
|
||||||
Err(error) => panic!("Failed to get current directory: {}", error),
|
|
||||||
};
|
|
||||||
|
|
||||||
let style = env::var_os("NO_COLOR").is_none()
|
let style = env::var_os("NO_COLOR").is_none()
|
||||||
&& env::var_os("TERM").as_deref() != Some(OsStr::new("dumb"));
|
&& env::var_os("TERM").as_deref() != Some(OsStr::new("dumb"));
|
||||||
|
@ -21,30 +18,32 @@ impl Env {
|
||||||
let out_stream = OutputStream::stdout(style);
|
let out_stream = OutputStream::stdout(style);
|
||||||
let err_stream = OutputStream::stderr(style);
|
let err_stream = OutputStream::stderr(style);
|
||||||
|
|
||||||
Self::new(
|
Ok(Self::new(
|
||||||
dir,
|
dir,
|
||||||
env::args(),
|
env::args(),
|
||||||
Box::new(io::stdin()),
|
Box::new(io::stdin()),
|
||||||
out_stream,
|
out_stream,
|
||||||
err_stream,
|
err_stream,
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn run(&mut self) -> Result<(), Error> {
|
pub(crate) fn run(&mut self) -> Result<()> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
ansi_term::enable_ansi_support().ok();
|
ansi_term::enable_ansi_support().ok();
|
||||||
|
|
||||||
Self::initialize_logging();
|
Self::initialize_logging();
|
||||||
|
|
||||||
let app = Arguments::clap();
|
let app = {
|
||||||
|
let mut app = Arguments::clap();
|
||||||
|
|
||||||
let width = env::var("IMDL_TERM_WIDTH")
|
let width = env::var("IMDL_TERM_WIDTH")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|width| width.parse::<usize>().ok());
|
.and_then(|width| width.parse::<usize>().ok());
|
||||||
|
|
||||||
|
if let Some(width) = width {
|
||||||
|
app = app.set_term_width(width)
|
||||||
|
}
|
||||||
|
|
||||||
let app = if let Some(width) = width {
|
|
||||||
app.set_term_width(width)
|
|
||||||
} else {
|
|
||||||
app
|
app
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,12 @@ pub(crate) enum Error {
|
||||||
ByteSuffix { text: String, suffix: String },
|
ByteSuffix { text: String, suffix: String },
|
||||||
#[snafu(display("{}", source))]
|
#[snafu(display("{}", source))]
|
||||||
Clap { source: clap::Error },
|
Clap { source: clap::Error },
|
||||||
#[snafu(display("Failed to invoke command `{}`: {}", command, source,))]
|
#[snafu(display("Failed to invoke command `{}`: {}", command, source))]
|
||||||
CommandInvoke { command: String, source: io::Error },
|
CommandInvoke { command: String, source: io::Error },
|
||||||
#[snafu(display("Command `{}` returned bad exit status: {}", command, status))]
|
#[snafu(display("Command `{}` returned bad exit status: {}", command, status))]
|
||||||
CommandStatus { command: String, status: ExitStatus },
|
CommandStatus { command: String, status: ExitStatus },
|
||||||
|
#[snafu(display("Failed to get current directory: {}", source))]
|
||||||
|
CurrentDirectoryGet { source: io::Error },
|
||||||
#[snafu(display("Filename was not valid unicode: `{}`", filename.display()))]
|
#[snafu(display("Filename was not valid unicode: `{}`", filename.display()))]
|
||||||
FilenameDecode { filename: PathBuf },
|
FilenameDecode { filename: PathBuf },
|
||||||
#[snafu(display("Path had no file name: `{}`", path.display()))]
|
#[snafu(display("Path had no file name: `{}`", path.display()))]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![deny(clippy::all, clippy::pedantic, clippy::restriction)]
|
#![deny(clippy::all, clippy::pedantic, clippy::restriction)]
|
||||||
#![allow(
|
#![allow(
|
||||||
|
clippy::blanket_clippy_restriction_lints,
|
||||||
clippy::else_if_without_else,
|
clippy::else_if_without_else,
|
||||||
clippy::enum_glob_use,
|
clippy::enum_glob_use,
|
||||||
clippy::float_arithmetic,
|
clippy::float_arithmetic,
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
clippy::missing_inline_in_public_items,
|
clippy::missing_inline_in_public_items,
|
||||||
clippy::needless_pass_by_value,
|
clippy::needless_pass_by_value,
|
||||||
clippy::non_ascii_literal,
|
clippy::non_ascii_literal,
|
||||||
|
clippy::pattern_type_mismatch,
|
||||||
clippy::shadow_reuse,
|
clippy::shadow_reuse,
|
||||||
clippy::struct_excessive_bools,
|
clippy::struct_excessive_bools,
|
||||||
clippy::too_many_lines,
|
clippy::too_many_lines,
|
||||||
|
|
10
src/run.rs
10
src/run.rs
|
@ -18,5 +18,13 @@ use crate::common::*;
|
||||||
/// be passed to `std::process::exit`, to exit the process and report its
|
/// be passed to `std::process::exit`, to exit the process and report its
|
||||||
/// failure to the system.
|
/// failure to the system.
|
||||||
pub fn run() -> Result<(), i32> {
|
pub fn run() -> Result<(), i32> {
|
||||||
Env::main().status()
|
let mut env = match Env::main() {
|
||||||
|
Ok(env) => env,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("{}", err);
|
||||||
|
return Err(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
env.status()
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,14 +64,13 @@ impl Verify {
|
||||||
|
|
||||||
let metainfo = Metainfo::from_input(&input)?;
|
let metainfo = Metainfo::from_input(&input)?;
|
||||||
|
|
||||||
let content = if let Some(content) = &self.content {
|
let content = self.content.as_ref().map_or_else(
|
||||||
content.clone()
|
|| match target {
|
||||||
} else {
|
|
||||||
match target {
|
|
||||||
InputTarget::Path(path) => path.join("..").join(&metainfo.info.name).lexiclean(),
|
InputTarget::Path(path) => path.join("..").join(&metainfo.info.name).lexiclean(),
|
||||||
InputTarget::Stdin => PathBuf::from(&metainfo.info.name),
|
InputTarget::Stdin => PathBuf::from(&metainfo.info.name),
|
||||||
}
|
},
|
||||||
};
|
PathBuf::clone,
|
||||||
|
);
|
||||||
|
|
||||||
let progress_bar = if env.err().is_styled_term() && !options.quiet {
|
let progress_bar = if env.err().is_styled_term() && !options.quiet {
|
||||||
let style = ProgressStyle::default_bar()
|
let style = ProgressStyle::default_bar()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user