diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-04-30 15:37:31 +0200 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2021-04-30 15:37:31 +0200 |
commit | 61ec153bcd543ad320c418ad81af5aba89fecffa (patch) | |
tree | 1eb32d5fe6706dfc650840c5e2ebe664a3b0ec69 | |
parent | 95682f567461beca22198b29a7abf9411f41189f (diff) |
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") ||
| ^^^^^^^^^^^^^^^^^^^
|
-rw-r--r-- | src/fs/dir.rs | 5 | ||||
-rw-r--r-- | src/fs/filter.rs | 6 | ||||
-rw-r--r-- | src/info/filetype.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/options/mod.rs | 2 | ||||
-rw-r--r-- | src/options/view.rs | 7 | ||||
-rw-r--r-- | src/output/escape.rs | 2 | ||||
-rw-r--r-- | src/output/icons.rs | 2 | ||||
-rw-r--r-- | src/output/render/git.rs | 1 | ||||
-rw-r--r-- | src/output/table.rs | 6 |
10 files changed, 19 insertions, 15 deletions
diff --git a/src/fs/dir.rs b/src/fs/dir.rs index 7f7b067..1a6ce01 100644 --- a/src/fs/dir.rs +++ b/src/fs/dir.rs @@ -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 } } } diff --git a/src/fs/filter.rs b/src/fs/filter.rs index 4cd6ad2..08770e6 100644 --- a/src/fs/filter.rs +++ b/src/fs/filter.rs @@ -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, + } } } diff --git a/src/info/filetype.rs b/src/info/filetype.rs index 8f54281..1def7a2 100644 --- a/src/info/filetype.rs +++ b/src/info/filetype.rs @@ -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. It’s 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") || diff --git a/src/main.rs b/src/main.rs index 84f36b7..4d762b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; diff --git a/src/options/mod.rs b/src/options/mod.rs index 747213b..528ba43 100644 --- a/src/options/mod.rs +++ b/src/options/mod.rs @@ -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" ))); } diff --git a/src/options/view.rs b/src/options/view.rs index 6d7abac..fe42838 100644 --- a/src/options/view.rs +++ b/src/options/view.rs @@ -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)?; diff --git a/src/output/escape.rs b/src/output/escape.rs index b4e801d..4c9f86c 100644 --- a/src/output/escape.rs +++ b/src/output/escape.rs @@ -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; diff --git a/src/output/icons.rs b/src/output/icons.rs index 8c024dc..eea0286 100644 --- a/src/output/icons.rs +++ b/src/output/icons.rs @@ -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() diff --git a/src/output/render/git.rs b/src/output/render/git.rs index 7ec9589..3740d40 100644 --- a/src/output/render/git.rs +++ b/src/output/render/git.rs @@ -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; diff --git a/src/output/table.rs b/src/output/table.rs index fbe716c..1680ec7 100644 --- a/src/output/table.rs +++ b/src/output/table.rs @@ -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 |