Enable more clippy lints and fix some clippy issues
This commit is contained in:
parent
139d29cc9b
commit
0e3c0b922d
5 changed files with 32 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering::{Relaxed, SeqCst};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AtomicMin {
|
||||
val: AtomicUsize,
|
||||
}
|
||||
|
|
|
|||
19
src/lib.rs
19
src/lib.rs
|
|
@ -1,3 +1,17 @@
|
|||
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]
|
||||
#![deny(missing_debug_implementations, missing_copy_implementations)]
|
||||
#![warn(clippy::expl_impl_clone_on_copy)]
|
||||
#![warn(clippy::float_cmp_const)]
|
||||
#![warn(clippy::linkedlist)]
|
||||
#![warn(clippy::map_flatten)]
|
||||
#![warn(clippy::match_same_arms)]
|
||||
#![warn(clippy::mem_forget)]
|
||||
#![warn(clippy::mut_mut)]
|
||||
#![warn(clippy::mutex_integer)]
|
||||
#![warn(clippy::needless_continue)]
|
||||
#![warn(clippy::path_buf_push_overwrite)]
|
||||
#![warn(clippy::range_plus_one)]
|
||||
|
||||
use num_cpus;
|
||||
#[cfg(feature = "parallel")]
|
||||
extern crate rayon;
|
||||
|
|
@ -427,7 +441,7 @@ pub fn optimize_from_memory(data: &[u8], opts: &Options) -> PngResult<Vec<u8>> {
|
|||
|
||||
let deadline = Arc::new(Deadline::new(opts.timeout, opts.verbosity.is_some()));
|
||||
|
||||
let original_size = data.len() as usize;
|
||||
let original_size = data.len();
|
||||
let mut png = PngData::from_slice(data, opts.fix_errors)?;
|
||||
|
||||
// Run the optimizer on the decoded PNG.
|
||||
|
|
@ -882,11 +896,10 @@ fn perform_strip(png: &mut PngData, opts: &Options) {
|
|||
}
|
||||
|
||||
let may_replace_iccp = match opts.strip {
|
||||
Headers::None => false,
|
||||
Headers::Keep(ref hdrs) => hdrs.contains("sRGB"),
|
||||
Headers::Strip(ref hdrs) => !hdrs.iter().any(|v| v == "sRGB"),
|
||||
Headers::Safe => true,
|
||||
Headers::All => false,
|
||||
Headers::None | Headers::All => false,
|
||||
};
|
||||
|
||||
if may_replace_iccp {
|
||||
|
|
|
|||
13
src/main.rs
13
src/main.rs
|
|
@ -1,5 +1,16 @@
|
|||
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]
|
||||
#![deny(missing_debug_implementations, missing_copy_implementations)]
|
||||
#![warn(clippy::expl_impl_clone_on_copy)]
|
||||
#![warn(clippy::float_cmp_const)]
|
||||
#![warn(clippy::linkedlist)]
|
||||
#![warn(clippy::map_flatten)]
|
||||
#![warn(clippy::match_same_arms)]
|
||||
#![warn(clippy::mem_forget)]
|
||||
#![warn(clippy::mut_mut)]
|
||||
#![warn(clippy::mutex_integer)]
|
||||
#![warn(clippy::needless_continue)]
|
||||
#![warn(clippy::path_buf_push_overwrite)]
|
||||
#![warn(clippy::range_plus_one)]
|
||||
|
||||
use clap::{App, AppSettings, Arg, ArgMatches};
|
||||
use oxipng::AlphaOptim;
|
||||
|
|
@ -264,7 +275,7 @@ fn collect_files(
|
|||
let files = input
|
||||
.read_dir()
|
||||
.unwrap()
|
||||
.map(|x| x.unwrap().path().to_owned())
|
||||
.map(|x| x.unwrap().path())
|
||||
.collect();
|
||||
in_out_pairs.extend(collect_files(files, out_dir, out_file, recursive, false));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ impl Iterator for ScanLineRanges {
|
|||
7 => (1, 2),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let mut pixels_per_line = self.width / pixels_factor as u32;
|
||||
let mut pixels_per_line = self.width / pixels_factor;
|
||||
// Determine whether to add pixels if there is a final, incomplete 8x8 block
|
||||
let gap = self.width % pixels_factor;
|
||||
match pass.0 {
|
||||
|
|
|
|||
|
|
@ -215,9 +215,9 @@ pub fn reduced_alpha_channel(png: &PngImage) -> Option<PngImage> {
|
|||
for (i, &byte) in line.data.iter().enumerate() {
|
||||
if i as u8 & bpp_mask >= colored_bytes {
|
||||
continue;
|
||||
} else {
|
||||
raw_data.push(byte);
|
||||
}
|
||||
|
||||
raw_data.push(byte);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue