Selaa lähdekoodia

refactor: clippy lints

Signed-off-by: Christina Sørensen <ces@fem.gg>
Christina Sørensen 8 kuukautta sitten
vanhempi
sitoutus
718d0f7898

+ 2 - 2
benches/my_benchmark.rs

@@ -9,8 +9,8 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
 pub fn criterion_benchmark(c: &mut Criterion) {
     c.bench_function("logger", |b| {
         b.iter(|| {
-            eza::logger::configure(black_box(std::env::var_os(eza::options::vars::EZA_DEBUG)))
-        })
+            eza::logger::configure(black_box(std::env::var_os(eza::options::vars::EZA_DEBUG)));
+        });
     });
 }
 

+ 4 - 4
build.rs

@@ -9,12 +9,12 @@
 /// just the version for *release* versions so the builds are reproducible.
 ///
 /// This script generates the string from the environment variables that Cargo
-/// adds (http://doc.crates.io/environment-variables.html) and runs `git` to
+/// adds (<http://doc.crates.io/environment-variables.html>) and runs `git` to
 /// get the SHA1 hash. It then writes the string into a file, which exa then
 /// includes at build-time.
 ///
-/// - https://stackoverflow.com/q/43753491/3484614
-/// - https://crates.io/crates/vergen
+/// - <https://stackoverflow.com/q/43753491/3484614>
+/// - <https://crates.io/crates/vergen>
 use std::env;
 use std::fs::File;
 use std::io::{self, Write};
@@ -116,7 +116,7 @@ fn version_string() -> String {
 
 /// Finds whether a feature is enabled by examining the Cargo variable.
 fn feature_enabled(name: &str) -> bool {
-    env::var(format!("CARGO_FEATURE_{}", name))
+    env::var(format!("CARGO_FEATURE_{name}"))
         .map(|e| !e.is_empty())
         .unwrap_or(false)
 }

+ 4 - 4
src/fs/dir.rs

@@ -12,7 +12,7 @@ use std::io;
 use std::path::{Path, PathBuf};
 use std::slice::Iter as SliceIter;
 
-use log::*;
+use log::info;
 
 use crate::fs::File;
 
@@ -50,7 +50,7 @@ impl Dir {
 
     /// Produce an iterator of IO results of trying to read all the files in
     /// this directory.
-    pub fn files<'dir, 'ig>(
+    #[must_use] pub fn files<'dir, 'ig>(
         &'dir self,
         dots: DotFilter,
         git: Option<&'ig GitCache>,
@@ -71,12 +71,12 @@ impl Dir {
     }
 
     /// Whether this directory contains a file with the given path.
-    pub fn contains(&self, path: &Path) -> bool {
+    #[must_use] pub fn contains(&self, path: &Path) -> bool {
         self.contents.iter().any(|p| p.path().as_path() == path)
     }
 
     /// Append a path onto the path specified by this directory.
-    pub fn join(&self, child: &Path) -> PathBuf {
+    #[must_use] pub fn join(&self, child: &Path) -> PathBuf {
         self.path.join(child)
     }
 }

+ 3 - 3
src/fs/dir_action.rs

@@ -43,7 +43,7 @@ pub enum DirAction {
 
 impl DirAction {
     /// Gets the recurse options, if this dir action has any.
-    pub fn recurse_options(self) -> Option<RecurseOptions> {
+    #[must_use] pub fn recurse_options(self) -> Option<RecurseOptions> {
         match self {
             Self::Recurse(o) => Some(o),
             _ => None,
@@ -51,7 +51,7 @@ impl DirAction {
     }
 
     /// Whether to treat directories as regular files or not.
-    pub fn treat_dirs_as_files(self) -> bool {
+    #[must_use] pub fn treat_dirs_as_files(self) -> bool {
         match self {
             Self::AsFile => true,
             Self::Recurse(o) => o.tree,
@@ -74,7 +74,7 @@ pub struct RecurseOptions {
 
 impl RecurseOptions {
     /// Returns whether a directory of the given depth would be too deep.
-    pub fn is_too_deep(self, depth: usize) -> bool {
+    #[must_use] pub fn is_too_deep(self, depth: usize) -> bool {
         match self.max_depth {
             None => false,
             Some(d) => d <= depth,

+ 4 - 4
src/fs/feature/git.rs

@@ -14,7 +14,7 @@ use std::path::{Path, PathBuf};
 use std::sync::Mutex;
 
 use git2::StatusEntry;
-use log::*;
+use log::{debug, error, info, warn};
 
 use crate::fs::fields as f;
 
@@ -31,11 +31,11 @@ pub struct GitCache {
 }
 
 impl GitCache {
-    pub fn has_anything_for(&self, index: &Path) -> bool {
+    #[must_use] pub fn has_anything_for(&self, index: &Path) -> bool {
         self.repos.iter().any(|e| e.has_path(index))
     }
 
-    pub fn get(&self, index: &Path, prefix_lookup: bool) -> f::Git {
+    #[must_use] pub fn get(&self, index: &Path, prefix_lookup: bool) -> f::Git {
         self.repos
             .iter()
             .find(|repo| repo.has_path(index))
@@ -410,7 +410,7 @@ fn current_branch(repo: &git2::Repository) -> Option<String> {
 }
 
 impl f::SubdirGitRepo {
-    pub fn from_path(dir: &Path, status: bool) -> Self {
+    #[must_use] pub fn from_path(dir: &Path, status: bool) -> Self {
         let path = &reorient(dir);
 
         if let Ok(repo) = git2::Repository::open(path) {

+ 1 - 1
src/fs/fields.rs

@@ -62,7 +62,7 @@ pub enum Type {
 }
 
 impl Type {
-    pub fn is_regular_file(self) -> bool {
+    #[must_use] pub fn is_regular_file(self) -> bool {
         matches!(self, Self::File)
     }
 }

+ 5 - 5
src/fs/file.rs

@@ -24,7 +24,7 @@ use std::time::SystemTime;
 
 use chrono::prelude::*;
 
-use log::*;
+use log::{debug, error, trace};
 #[cfg(unix)]
 use std::sync::LazyLock;
 
@@ -209,18 +209,18 @@ impl<'dir> File<'dir> {
         file
     }
 
-    pub fn new_aa_current(parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
+    #[must_use] pub fn new_aa_current(parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
         File::new_aa(parent_dir.path.clone(), parent_dir, ".", total_size)
     }
 
-    pub fn new_aa_parent(path: PathBuf, parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
+    #[must_use] pub fn new_aa_parent(path: PathBuf, parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
         File::new_aa(path, parent_dir, "..", total_size)
     }
 
     /// A file’s name is derived from its string. This needs to handle directories
     /// such as `/` or `..`, which have no `file_name` component. So instead, just
     /// use the last component as the name.
-    pub fn filename(path: &Path) -> String {
+    #[must_use] pub fn filename(path: &Path) -> String {
         if let Some(back) = path.components().next_back() {
             back.as_os_str().to_string_lossy().to_string()
         } else {
@@ -1016,7 +1016,7 @@ pub enum FileTarget<'dir> {
 impl<'dir> FileTarget<'dir> {
     /// Whether this link doesn’t lead to a file, for whatever reason. This
     /// gets used to determine how to highlight the link in grid views.
-    pub fn is_broken(&self) -> bool {
+    #[must_use] pub fn is_broken(&self) -> bool {
         matches!(self, Self::Broken(_) | Self::Err(_))
     }
 }

+ 1 - 1
src/fs/filter.rs

@@ -365,7 +365,7 @@ impl IgnorePatterns {
     }
 
     /// Create a new empty set of patterns that matches nothing.
-    pub fn empty() -> Self {
+    #[must_use] pub fn empty() -> Self {
         Self {
             patterns: Vec::new(),
         }

+ 2 - 2
src/fs/recursive_size.rs

@@ -37,7 +37,7 @@ impl RecursiveSize {
     /// assert_eq!(x.is_none(), false);
     /// ```
     #[inline]
-    pub const fn is_none(&self) -> bool {
+    #[must_use] pub const fn is_none(&self) -> bool {
         matches!(*self, Self::None)
     }
 
@@ -53,7 +53,7 @@ impl RecursiveSize {
     /// assert_eq!(RecursiveSize::Some(2, 3).unwrap_bytes_or(1), 2);
     /// ```
     #[inline]
-    pub const fn unwrap_bytes_or(self, default: u64) -> u64 {
+    #[must_use] pub const fn unwrap_bytes_or(self, default: u64) -> u64 {
         match self {
             Self::Some(bytes, _blocks) => bytes,
             _ => default,

+ 5 - 5
src/options/config.rs

@@ -5,7 +5,7 @@
 // SPDX-FileCopyrightText: 2014 Benjamin Sago
 // SPDX-License-Identifier: MIT
 use crate::theme::ThemeFileType as FileType;
-use crate::theme::*;
+use crate::theme::{FileKinds, FileNameStyle, Git, GitRepo, IconStyle, Links, Permissions, SELinuxContext, SecurityContext, Size, UiStyles, Users};
 use nu_ansi_term::{Color, Style};
 use serde::{Deserialize, Deserializer, Serialize};
 use serde_norway;
@@ -49,7 +49,7 @@ where
 
 #[rustfmt::skip]
 fn color_from_str(s: &str) -> Option<Color> {
-    use Color::*;
+    use Color::{Black, Blue, Cyan, DarkGray, Default, Fixed, Green, LightBlue, LightCyan, LightGray, LightGreen, LightMagenta, LightPurple, LightRed, LightYellow, Magenta, Purple, Red, Rgb, White, Yellow};
     match s {
         // nothing
         "" | "none"    | "None"         => None,
@@ -604,10 +604,10 @@ impl FromOverride<UiStylesOverride> for UiStyles {
     }
 }
 impl ThemeConfig {
-    pub fn from_path(path: PathBuf) -> Self {
+    #[must_use] pub fn from_path(path: PathBuf) -> Self {
         ThemeConfig { location: path }
     }
-    pub fn to_theme(&self) -> Option<UiStyles> {
+    #[must_use] pub fn to_theme(&self) -> Option<UiStyles> {
         let ui_styles_override: Option<UiStylesOverride> = {
             let file = std::fs::File::open(&self.location).ok()?;
             serde_norway::from_reader(&file).ok()
@@ -650,7 +650,7 @@ mod tests {
 
     #[test]
     fn parse_short_hex_color_from_string() {
-        for case in ["#f0f", "#F0F"].iter() {
+        for case in &["#f0f", "#F0F"] {
             assert_eq!(color_from_str(case), Some(Color::Rgb(255, 0, 255)));
         }
     }

+ 1 - 1
src/options/error.rs

@@ -109,7 +109,7 @@ impl fmt::Display for OptionsError {
 impl OptionsError {
     /// Try to second-guess what the user was trying to do, depending on what
     /// went wrong.
-    pub fn suggestion(&self) -> Option<&'static str> {
+    #[must_use] pub fn suggestion(&self) -> Option<&'static str> {
         // ‘ls -lt’ and ‘ls -ltr’ are common combinations
         match self {
             Self::BadArgument(time, r) if *time == &flags::TIME && r == "r" => {

+ 1 - 1
src/options/mod.rs

@@ -173,7 +173,7 @@ impl Options {
     /// Whether the View specified in this set of options includes a Git
     /// status column. It’s only worth trying to discover a repository if the
     /// results will end up being displayed.
-    pub fn should_scan_for_git(&self) -> bool {
+    #[must_use] pub fn should_scan_for_git(&self) -> bool {
         if self.filter.git_ignore == GitIgnore::CheckAndIgnore {
             return true;
         }

+ 1 - 1
src/output/color_scale.rs

@@ -85,7 +85,7 @@ impl ColorScaleInformation {
         }
     }
 
-    pub fn adjust_style(&self, mut style: Style, value: f32, range: Option<Extremes>) -> Style {
+    #[must_use] pub fn adjust_style(&self, mut style: Style, value: f32, range: Option<Extremes>) -> Style {
         if let (Some(fg), Some(range)) = (style.foreground, range) {
             let mut ratio = ((value - range.min) / (range.max - range.min)).clamp(0.0, 1.0);
             if ratio.is_nan() {

+ 4 - 4
src/output/details.rs

@@ -72,7 +72,7 @@ use std::vec::IntoIter as VecIntoIter;
 use nu_ansi_term::Style;
 use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
 
-use log::*;
+use log::{debug, trace};
 
 use crate::fs::dir_action::RecurseOptions;
 use crate::fs::feature::git::GitCache;
@@ -403,7 +403,7 @@ impl<'a> Render<'a> {
         }
     }
 
-    pub fn render_header(&self, header: TableRow) -> Row {
+    #[must_use] pub fn render_header(&self, header: TableRow) -> Row {
         Row {
             tree: TreeParams::new(TreeDepth::root(), false),
             cells: Some(header),
@@ -442,7 +442,7 @@ impl<'a> Render<'a> {
         }
     }
 
-    pub fn iterate_with_table(&'a self, table: Table<'a>, rows: Vec<Row>) -> TableIter<'a> {
+    #[must_use] pub fn iterate_with_table(&'a self, table: Table<'a>, rows: Vec<Row>) -> TableIter<'a> {
         TableIter {
             tree_trunk: TreeTrunk::default(),
             total_width: table.widths().total(),
@@ -452,7 +452,7 @@ impl<'a> Render<'a> {
         }
     }
 
-    pub fn iterate(&'a self, rows: Vec<Row>) -> Iter {
+    #[must_use] pub fn iterate(&'a self, rows: Vec<Row>) -> Iter {
         Iter {
             tree_trunk: TreeTrunk::default(),
             inner: rows.into_iter(),

+ 5 - 5
src/output/file_name.rs

@@ -168,7 +168,7 @@ pub struct FileName<'a, 'dir, C> {
 impl<'a, 'dir, C> FileName<'a, 'dir, C> {
     /// Sets the flag on this file name to display link targets with an
     /// arrow followed by their path.
-    pub fn with_link_paths(mut self) -> Self {
+    #[must_use] pub fn with_link_paths(mut self) -> Self {
         if !self.file.deref_links {
             self.link_style = LinkStyle::FullLinkPaths;
         }
@@ -177,7 +177,7 @@ impl<'a, 'dir, C> FileName<'a, 'dir, C> {
 
     /// Sets the flag on this file name to display mounted filesystem
     ///details.
-    pub fn with_mount_details(mut self, enable: bool) -> Self {
+    #[must_use] pub fn with_mount_details(mut self, enable: bool) -> Self {
         self.mount_style = if enable {
             MountStyle::MountInfo
         } else {
@@ -194,7 +194,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
     /// This method returns some `TextCellContents`, rather than a `TextCell`,
     /// because for the last cell in a table, it doesn’t need to have its
     /// width calculated.
-    pub fn paint(&self) -> TextCellContents {
+    #[must_use] pub fn paint(&self) -> TextCellContents {
         let mut bits = Vec::new();
         let (icon_override, filename_style_override) = match self.colours.style_override(self.file)
         {
@@ -461,7 +461,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
     /// depending on which “type” of file it appears to be — either from the
     /// class on the filesystem or from its name. (Or the broken link colour,
     /// if there’s nowhere else for that fact to be shown.)
-    pub fn style(&self) -> Style {
+    #[must_use] pub fn style(&self) -> Style {
         if let LinkStyle::JustFilenames = self.link_style {
             if let Some(ref target) = self.target {
                 if target.is_broken() {
@@ -491,7 +491,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
     }
 
     /// For grid's use, to cover the case of hyperlink escape sequences
-    pub fn bare_utf8_width(&self) -> usize {
+    #[must_use] pub fn bare_utf8_width(&self) -> usize {
         UnicodeWidthStr::width(self.file.name.as_str())
     }
 }

+ 1 - 1
src/output/grid.rs

@@ -19,7 +19,7 @@ pub struct Options {
 }
 
 impl Options {
-    pub fn direction(self) -> Direction {
+    #[must_use] pub fn direction(self) -> Direction {
         if self.across {
             Direction::LeftToRight
         } else {

+ 1 - 1
src/output/grid_details.rs

@@ -29,7 +29,7 @@ pub struct Options {
 }
 
 impl Options {
-    pub fn to_details_options(&self) -> &DetailsOptions {
+    #[must_use] pub fn to_details_options(&self) -> &DetailsOptions {
         &self.details
     }
 }

+ 1 - 1
src/output/mod.rs

@@ -55,7 +55,7 @@ pub enum TerminalWidth {
 }
 
 impl TerminalWidth {
-    pub fn actual_terminal_width(self) -> Option<usize> {
+    #[must_use] pub fn actual_terminal_width(self) -> Option<usize> {
         // All of stdin, stdout, and stderr could not be connected to a
         // terminal, but we’re only interested in stdout because it’s
         // where the output goes.

+ 1 - 1
src/output/render/flags.rs

@@ -11,7 +11,7 @@ use crate::output::cell::TextCell;
 use crate::output::table::FlagsFormat;
 
 impl f::Flags {
-    pub fn render(self, style: Style, _format: FlagsFormat) -> TextCell {
+    #[must_use] pub fn render(self, style: Style, _format: FlagsFormat) -> TextCell {
         TextCell::paint(style, "-".to_string())
     }
 }

+ 1 - 1
src/output/render/inode.rs

@@ -10,7 +10,7 @@ use crate::fs::fields as f;
 use crate::output::cell::TextCell;
 
 impl f::Inode {
-    pub fn render(self, style: Style) -> TextCell {
+    #[must_use] pub fn render(self, style: Style) -> TextCell {
         TextCell::paint(style, self.0.to_string())
     }
 }

+ 18 - 21
src/output/render/permissions.rs

@@ -19,30 +19,27 @@ pub trait PermissionsPlusRender {
 impl PermissionsPlusRender for Option<f::PermissionsPlus> {
     #[cfg(unix)]
     fn render<C: Colours + FiletypeColours>(&self, colours: &C) -> TextCell {
-        match self {
-            Some(p) => {
-                let mut chars = vec![p.file_type.render(colours)];
-                let permissions = p.permissions;
-                chars.extend(Some(permissions).render(colours, p.file_type.is_regular_file()));
+        if let Some(p) = self {
+            let mut chars = vec![p.file_type.render(colours)];
+            let permissions = p.permissions;
+            chars.extend(Some(permissions).render(colours, p.file_type.is_regular_file()));
 
-                if p.xattrs {
-                    chars.push(colours.attribute().paint("@"));
-                }
+            if p.xattrs {
+                chars.push(colours.attribute().paint("@"));
+            }
 
-                // As these are all ASCII characters, we can guarantee that they’re
-                // all going to be one character wide, and don’t need to compute the
-                // cell’s display width.
-                TextCell {
-                    width: DisplayWidth::from(chars.len()),
-                    contents: chars.into(),
-                }
+            // As these are all ASCII characters, we can guarantee that they’re
+            // all going to be one character wide, and don’t need to compute the
+            // cell’s display width.
+            TextCell {
+                width: DisplayWidth::from(chars.len()),
+                contents: chars.into(),
             }
-            None => {
-                let chars: Vec<_> = iter::repeat(colours.dash().paint("-")).take(10).collect();
-                TextCell {
-                    width: DisplayWidth::from(chars.len()),
-                    contents: chars.into(),
-                }
+        } else {
+            let chars: Vec<_> = iter::repeat(colours.dash().paint("-")).take(10).collect();
+            TextCell {
+                width: DisplayWidth::from(chars.len()),
+                contents: chars.into(),
             }
         }
     }

+ 11 - 11
src/output/table.rs

@@ -11,7 +11,7 @@ use std::sync::{Mutex, MutexGuard};
 
 use chrono::prelude::*;
 
-use log::*;
+use log::debug;
 use std::sync::LazyLock;
 #[cfg(unix)]
 use uzers::UsersCache;
@@ -67,7 +67,7 @@ pub struct Columns {
 }
 
 impl Columns {
-    pub fn collect(&self, actually_enable_git: bool, git_repos: bool) -> Vec<Column> {
+    #[must_use] pub fn collect(&self, actually_enable_git: bool, git_repos: bool) -> Vec<Column> {
         let mut columns = Vec::with_capacity(4);
 
         if self.inode {
@@ -185,7 +185,7 @@ pub enum Alignment {
 impl Column {
     /// Get the alignment this column should use.
     #[cfg(unix)]
-    pub fn alignment(self) -> Alignment {
+    #[must_use] pub fn alignment(self) -> Alignment {
         #[allow(clippy::wildcard_in_or_patterns)]
         match self {
             Self::FileSize | Self::HardLinks | Self::Inode | Self::Blocksize | Self::GitStatus => {
@@ -205,7 +205,7 @@ impl Column {
 
     /// Get the text that should be printed at the top, when the user elects
     /// to have a header row printed.
-    pub fn header(self) -> &'static str {
+    #[must_use] pub fn header(self) -> &'static str {
         match self {
             #[cfg(unix)]
             Self::Permissions => "Permissions",
@@ -288,7 +288,7 @@ pub enum TimeType {
 
 impl TimeType {
     /// Returns the text to use for a column’s heading in the columns output.
-    pub fn header(self) -> &'static str {
+    #[must_use] pub fn header(self) -> &'static str {
         match self {
             Self::Modified => "Date Modified",
             Self::Changed => "Date Changed",
@@ -421,7 +421,7 @@ pub struct Row {
 }
 
 impl<'a> Table<'a> {
-    pub fn new(
+    #[must_use] pub fn new(
         options: &'a Options,
         git: Option<&'a GitCache>,
         theme: &'a Theme,
@@ -449,11 +449,11 @@ impl<'a> Table<'a> {
         }
     }
 
-    pub fn widths(&self) -> &TableWidths {
+    #[must_use] pub fn widths(&self) -> &TableWidths {
         &self.widths
     }
 
-    pub fn header_row(&self) -> Row {
+    #[must_use] pub fn header_row(&self) -> Row {
         let cells = self
             .columns
             .iter()
@@ -591,7 +591,7 @@ impl<'a> Table<'a> {
         f::SubdirGitRepo::default()
     }
 
-    pub fn render(&self, row: Row) -> TextCell {
+    #[must_use] pub fn render(&self, row: Row) -> TextCell {
         let mut cell = TextCell::default();
 
         let iter = row.cells.into_iter().zip(self.widths.iter()).enumerate();
@@ -628,7 +628,7 @@ impl Deref for TableWidths {
 }
 
 impl TableWidths {
-    pub fn zero(count: usize) -> Self {
+    #[must_use] pub fn zero(count: usize) -> Self {
         Self(vec![0; count])
     }
 
@@ -638,7 +638,7 @@ impl TableWidths {
         }
     }
 
-    pub fn total(&self) -> usize {
+    #[must_use] pub fn total(&self) -> usize {
         self.0.len() + self.0.iter().sum::<usize>()
     }
 }

+ 3 - 4
src/output/time.rs

@@ -62,7 +62,7 @@ pub enum TimeFormat {
 }
 
 impl TimeFormat {
-    pub fn format(self, time: &DateTime<FixedOffset>) -> String {
+    #[must_use] pub fn format(self, time: &DateTime<FixedOffset>) -> String {
         #[rustfmt::skip]
         return match self {
             Self::DefaultFormat                 => default(time),
@@ -164,15 +164,14 @@ mod test {
         let max_month_width = 4;
         let month = "1\u{2F49}"; // 1月
         let padding = short_month_padding(max_month_width, month);
-        let final_str = format!("{:<width$}", month, width = padding);
+        let final_str = format!("{month:<padding$}");
         assert_eq!(max_month_width, UnicodeWidthStr::width(final_str.as_str()));
     }
 
     #[test]
     fn short_month_width_hindi() {
         let max_month_width = 4;
-        assert_eq!(
-            true,
+        assert!(
             [
                 "\u{091C}\u{0928}\u{0970}",                         // जन॰
                 "\u{092B}\u{093C}\u{0930}\u{0970}",                 // फ़र॰

+ 3 - 3
src/theme/default_theme.rs

@@ -4,14 +4,14 @@
 // SPDX-FileCopyrightText: 2023-2024 Christina Sørensen, eza contributors
 // SPDX-FileCopyrightText: 2014 Benjamin Sago
 // SPDX-License-Identifier: MIT
-use nu_ansi_term::Color::*;
+use nu_ansi_term::Color::{Blue, Cyan, DarkGray, Green, Purple, Red, Yellow};
 use nu_ansi_term::Style;
 use std::default::Default;
 
 use crate::output::color_scale::{ColorScaleMode, ColorScaleOptions};
-use crate::theme::ui_styles::*;
+use crate::theme::ui_styles::{FileKinds, FileType, Git, GitRepo, Links, Permissions, SELinuxContext, SecurityContext, Size, UiStyles, Users};
 impl UiStyles {
-    pub fn default_theme(scale: ColorScaleOptions) -> Self {
+    #[must_use] pub fn default_theme(scale: ColorScaleOptions) -> Self {
         Self {
             size: Some(Size::colourful(scale)),
             ..Self::default()

+ 1 - 1
src/theme/lsc.rs

@@ -7,7 +7,7 @@
 use std::iter::Peekable;
 use std::ops::FnMut;
 
-use nu_ansi_term::Color::*;
+use nu_ansi_term::Color::{Black, Blue, Cyan, DarkGray, Fixed, Green, LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, LightYellow, Purple, Red, Rgb, White, Yellow};
 use nu_ansi_term::{Color as Colour, Style};
 
 // Parsing the LS_COLORS environment variable into a map of names to Style values.

+ 7 - 7
src/theme/mod.rs

@@ -67,7 +67,7 @@ pub struct Theme {
 }
 
 impl Options {
-    pub fn to_theme(&self, isatty: bool) -> Theme {
+    #[must_use] pub fn to_theme(&self, isatty: bool) -> Theme {
         if self.use_colours == UseColours::Never
             || (self.use_colours == UseColours::Automatic && !isatty)
         {
@@ -128,7 +128,7 @@ impl Definitions {
     /// Also returns if the `EZA_COLORS` variable should reset the existing file
     /// type mappings or not. The `reset` code needs to be the first one.
     fn parse_color_vars(&self, colours: &mut UiStyles) -> (ExtensionMappings, bool) {
-        use log::*;
+        use log::warn;
 
         let mut exts = ExtensionMappings::default();
 
@@ -315,7 +315,7 @@ impl FileStyle for FileTypes {
 #[cfg(unix)]
 impl render::BlocksColours for Theme {
     fn blocksize(&self, prefix: Option<number_prefix::Prefix>) -> Style {
-        use number_prefix::Prefix::*;
+        use number_prefix::Prefix::{Gibi, Giga, Kibi, Kilo, Mebi, Mega};
 
         #[rustfmt::skip]
         let style = match prefix {
@@ -329,7 +329,7 @@ impl render::BlocksColours for Theme {
     }
 
     fn unit(&self, prefix: Option<number_prefix::Prefix>) -> Style {
-        use number_prefix::Prefix::*;
+        use number_prefix::Prefix::{Gibi, Giga, Kibi, Kilo, Mebi, Mega};
 
         #[rustfmt::skip]
            let style = match prefix {
@@ -416,7 +416,7 @@ impl render::PermissionsColours for Theme {
 
 impl render::SizeColours for Theme {
     fn size(&self, prefix: Option<number_prefix::Prefix>) -> Style {
-        use number_prefix::Prefix::*;
+        use number_prefix::Prefix::{Gibi, Giga, Kibi, Kilo, Mebi, Mega};
 
         #[rustfmt::skip]
         return match prefix {
@@ -429,7 +429,7 @@ impl render::SizeColours for Theme {
     }
 
     fn unit(&self, prefix: Option<number_prefix::Prefix>) -> Style {
-        use number_prefix::Prefix::*;
+        use number_prefix::Prefix::{Gibi, Giga, Kibi, Kilo, Mebi, Mega};
 
         #[rustfmt::skip]
         return match prefix {
@@ -554,7 +554,7 @@ mod customs_test {
                     GlobPattern::Simple(h) => {
                         let mut simple_pats = h
                             .iter()
-                            .map(|(k, v)| (glob::Pattern::new(&format!("*.{}", k)).unwrap(), *v))
+                            .map(|(k, v)| (glob::Pattern::new(&format!("*.{k}")).unwrap(), *v))
                             .collect::<Vec<(glob::Pattern, Style)>>();
 
                         simple_pats.sort_by_key(|x| x.0.clone());

+ 3 - 3
src/theme/ui_styles.rs

@@ -5,7 +5,7 @@
 // SPDX-FileCopyrightText: 2014 Benjamin Sago
 // SPDX-License-Identifier: MIT
 use crate::theme::lsc::Pair;
-use nu_ansi_term::{Color::*, Style};
+use nu_ansi_term::{Color::{Blue, Cyan, Green, Purple, Red, Yellow}, Style};
 use serde::{Deserialize, Serialize};
 use std::collections::HashMap;
 use std::default::Default;
@@ -59,7 +59,7 @@ macro_rules! field_accessors {
         impl $struct_name {
             $(
                 #[allow(clippy::wrong_self_convention, clippy::new_ret_no_self)]
-                pub fn $field_name(&self) -> $type {
+                #[must_use] pub fn $field_name(&self) -> $type {
                     self.$field_name.unwrap_or_default()
                 }
             )*
@@ -382,7 +382,7 @@ pub struct FileType {
 }
 
 impl UiStyles {
-    pub fn plain() -> Self {
+    #[must_use] pub fn plain() -> Self {
         Self {
             colourful: Some(false),