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> {
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn is_digit(c: &char) -> bool {
|
||||
match c {
|
||||
'0'..='9' | '.' => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(c, '0'..='9' | '.')
|
||||
}
|
||||
|
||||
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 {
|
||||
pub(crate) fn main() -> Self {
|
||||
let dir = match env::current_dir() {
|
||||
Ok(dir) => dir,
|
||||
Err(error) => panic!("Failed to get current directory: {}", error),
|
||||
};
|
||||
pub(crate) fn main() -> Result<Self> {
|
||||
let dir = env::current_dir().context(error::CurrentDirectoryGet)?;
|
||||
|
||||
let style = env::var_os("NO_COLOR").is_none()
|
||||
&& env::var_os("TERM").as_deref() != Some(OsStr::new("dumb"));
|
||||
|
@ -21,30 +18,32 @@ impl Env {
|
|||
let out_stream = OutputStream::stdout(style);
|
||||
let err_stream = OutputStream::stderr(style);
|
||||
|
||||
Self::new(
|
||||
Ok(Self::new(
|
||||
dir,
|
||||
env::args(),
|
||||
Box::new(io::stdin()),
|
||||
out_stream,
|
||||
err_stream,
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn run(&mut self) -> Result<(), Error> {
|
||||
pub(crate) fn run(&mut self) -> Result<()> {
|
||||
#[cfg(windows)]
|
||||
ansi_term::enable_ansi_support().ok();
|
||||
|
||||
Self::initialize_logging();
|
||||
|
||||
let app = Arguments::clap();
|
||||
let app = {
|
||||
let mut app = Arguments::clap();
|
||||
|
||||
let width = env::var("IMDL_TERM_WIDTH")
|
||||
.ok()
|
||||
.and_then(|width| width.parse::<usize>().ok());
|
||||
let width = env::var("IMDL_TERM_WIDTH")
|
||||
.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
|
||||
};
|
||||
|
||||
|
|
|
@ -14,10 +14,12 @@ pub(crate) enum Error {
|
|||
ByteSuffix { text: String, suffix: String },
|
||||
#[snafu(display("{}", source))]
|
||||
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 },
|
||||
#[snafu(display("Command `{}` returned bad exit status: {}", command, status))]
|
||||
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()))]
|
||||
FilenameDecode { filename: PathBuf },
|
||||
#[snafu(display("Path had no file name: `{}`", path.display()))]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![deny(clippy::all, clippy::pedantic, clippy::restriction)]
|
||||
#![allow(
|
||||
clippy::blanket_clippy_restriction_lints,
|
||||
clippy::else_if_without_else,
|
||||
clippy::enum_glob_use,
|
||||
clippy::float_arithmetic,
|
||||
|
@ -14,6 +15,7 @@
|
|||
clippy::missing_inline_in_public_items,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::non_ascii_literal,
|
||||
clippy::pattern_type_mismatch,
|
||||
clippy::shadow_reuse,
|
||||
clippy::struct_excessive_bools,
|
||||
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
|
||||
/// failure to the system.
|
||||
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 content = if let Some(content) = &self.content {
|
||||
content.clone()
|
||||
} else {
|
||||
match target {
|
||||
let content = self.content.as_ref().map_or_else(
|
||||
|| match target {
|
||||
InputTarget::Path(path) => path.join("..").join(&metainfo.info.name).lexiclean(),
|
||||
InputTarget::Stdin => PathBuf::from(&metainfo.info.name),
|
||||
}
|
||||
};
|
||||
},
|
||||
PathBuf::clone,
|
||||
);
|
||||
|
||||
let progress_bar = if env.err().is_styled_term() && !options.quiet {
|
||||
let style = ProgressStyle::default_bar()
|
||||
|
|
Loading…
Reference in New Issue
Block a user