Cleanup clippy warnings

warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
 --> src/output/escape.rs:4:1
  |
4 | pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, bad: Style) {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |

warning: this lifetime isn't used in the function definition
 --> src/output/escape.rs:4:15
  |
4 | pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'_>>, good: Style, bad: Style) {
  |               ^^
  |

warning: single-character string constant used as pattern
   --> src/output/table.rs:310:41
    |
310 |                     if file.starts_with(":") {
    |                                         ^^^ help: try using a `char` instead: `':'`
    |

warning: single-character string constant used as pattern
   --> src/output/table.rs:310:41
    |
310 |                     if file.starts_with(":") {
    |                                         ^^^ help: try using a `char` instead: `':'`
    |

warning: methods called `new` usually return `Self`
  --> src/output/render/git.rs:38:5
   |
38 |     fn new(&self) -> Style;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   |

warning: this lifetime isn't used in the function definition
  --> src/output/icons.rs:40:22
   |
40 | pub fn iconify_style<'a>(style: Style) -> Style {
   |                      ^^
   |

warning: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint
  --> src/main.rs:11:10
   |
11 | #![allow(clippy::find_map)]
   |          ^^^^^^^^^^^^^^^^
   |

warning: redundant else block
   --> src/fs/dir.rs:124:18
    |
124 |               else {
    |  __________________^
125 | |                 return None
126 | |             }
    | |_____________^
    |

warning: redundant else block
  --> src/options/view.rs:60:18
   |
60 |               else {
   |  __________________^
61 | |                 // the --tree case is handled by the DirAction parser later
62 | |                 return Ok(Self::Details(details));
63 | |             }
   | |_____________^
   |

warning: all variants have the same postfix: `Bytes`
   --> src/output/table.rs:170:1
    |
170 | / pub enum SizeFormat {
171 | |
172 | |     /// Format the file size using **decimal** prefixes, such as “kilo”,
173 | |     /// “mega”, or “giga”.
...   |
181 | |     JustBytes,
182 | | }
    | |_^
    |

warning: all variants have the same postfix: `Bytes`
   --> src/output/table.rs:171:1
    |
171 | / pub enum SizeFormat {
172 | |
173 | |     /// Format the file size using **decimal** prefixes, such as “kilo”,
174 | |     /// “mega”, or “giga”.
...   |
182 | |     JustBytes,
183 | | }
    | |_^
    |

warning: useless use of `format!`
   --> src/options/mod.rs:181:50
    |
181 |               return Err(OptionsError::Unsupported(format!(
    |  __________________________________________________^
182 | |                 "Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa"
183 | |             )));
    | |_____________^ help: consider using `.to_string()`: `"Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa".to_string()`
    |

warning: stripping a prefix manually
   --> src/fs/filter.rs:287:33
    |
287 |         if n.starts_with('.') { &n[1..] }
    |                                 ^^^^^^^
    |

warning: case-sensitive file extension comparison
  --> src/info/filetype.rs:24:19
   |
24 |         file.name.ends_with(".ninja") ||
   |                   ^^^^^^^^^^^^^^^^^^^
   |
This commit is contained in:
Christian Göttsche 2021-04-30 15:37:31 +02:00
parent 95682f5674
commit 61ec153bcd
10 changed files with 19 additions and 15 deletions

View File

@ -121,9 +121,8 @@ impl<'dir, 'ig> Files<'dir, 'ig> {
return Some(File::from_args(path.clone(), self.dir, filename)
.map_err(|e| (path.clone(), e)))
}
else {
return None
}
return None
}
}
}

View File

@ -284,8 +284,10 @@ impl SortField {
}
fn strip_dot(n: &str) -> &str {
if n.starts_with('.') { &n[1..] }
else { n }
match n.strip_prefix('.') {
Some(s) => s,
None => n,
}
}
}

View File

@ -19,6 +19,7 @@ impl FileExtensions {
/// An “immediate” file is something that can be run or activated somehow
/// in order to kick off the build of a project. Its usually only present
/// in directories full of source code.
#[allow(clippy::case_sensitive_file_extension_comparisons)]
fn is_immediate(&self, file: &File<'_>) -> bool {
file.name.to_lowercase().starts_with("readme") ||
file.name.ends_with(".ninja") ||

View File

@ -8,7 +8,6 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::enum_glob_use)]
#![allow(clippy::find_map)]
#![allow(clippy::map_unwrap_or)]
#![allow(clippy::match_same_arms)]
#![allow(clippy::missing_const_for_fn)]
@ -19,6 +18,7 @@
#![allow(clippy::option_if_let_else)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::unused_self)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::wildcard_imports)]
use std::env;

View File

@ -178,7 +178,7 @@ impl Options {
fn deduce<V: Vars>(matches: &MatchedFlags<'_>, vars: &V) -> Result<Self, OptionsError> {
if cfg!(not(feature = "git")) &&
matches.has_where_any(|f| f.matches(&flags::GIT) || f.matches(&flags::GIT_IGNORE)).is_some() {
return Err(OptionsError::Unsupported(format!(
return Err(OptionsError::Unsupported(String::from(
"Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa"
)));
}

View File

@ -57,10 +57,9 @@ impl Mode {
let grid_details = grid_details::Options { grid, details, row_threshold };
return Ok(Self::GridDetails(grid_details));
}
else {
// the --tree case is handled by the DirAction parser later
return Ok(Self::Details(details));
}
// the --tree case is handled by the DirAction parser later
return Ok(Self::Details(details));
}
Self::strict_check_long_flags(matches)?;

View File

@ -1,7 +1,7 @@
use ansi_term::{ANSIString, Style};
pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, bad: Style) {
pub fn escape(string: String, bits: &mut Vec<ANSIString<'_>>, good: Style, bad: Style) {
if string.chars().all(|c| c >= 0x20 as char && c != 0x7f as char) {
bits.push(good.paint(string));
return;

View File

@ -37,7 +37,7 @@ impl Icons {
/// - If neither is set, just use the default style.
/// - Attributes such as bold or underline should not be used to paint the
/// icon, as they can make it look weird.
pub fn iconify_style<'a>(style: Style) -> Style {
pub fn iconify_style(style: Style) -> Style {
style.background.or(style.foreground)
.map(Style::from)
.unwrap_or_default()

View File

@ -35,6 +35,7 @@ impl f::GitStatus {
pub trait Colours {
fn not_modified(&self) -> Style;
#[allow(clippy::new_ret_no_self)]
fn new(&self) -> Style;
fn modified(&self) -> Style;
fn deleted(&self) -> Style;

View File

@ -28,6 +28,7 @@ pub struct Options {
}
/// Extra columns to display in the table.
#[allow(clippy::struct_excessive_bools)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub struct Columns {
@ -166,6 +167,7 @@ impl Column {
/// Formatting options for file sizes.
#[allow(clippy::pub_enum_variant_names)]
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum SizeFormat {
@ -303,11 +305,11 @@ impl Environment {
fn determine_time_zone() -> TZResult<TimeZone> {
if let Ok(file) = env::var("TZ") {
TimeZone::from_file({
if file.starts_with("/") {
if file.starts_with('/') {
file
} else {
format!("/usr/share/zoneinfo/{}", {
if file.starts_with(":") {
if file.starts_with(':') {
file.replacen(":", "", 1)
} else {
file