Skip to content

Commit

Permalink
style: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Mar 9, 2023
1 parent 1aec736 commit 9630013
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/meta/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mod test {
Command::new("touch")
.arg("-t")
.arg(date.format("%Y%m%d%H%M.%S").to_string())
.arg(&path)
.arg(path)
.status()
}

Expand Down
2 changes: 1 addition & 1 deletion src/meta/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod tests {
use std::process::{Command, ExitStatus};

fn cross_platform_touch(path: &Path) -> io::Result<ExitStatus> {
Command::new("touch").arg(&path).status()
Command::new("touch").arg(path).status()
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/meta/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mod tests {
use std::process::{Command, ExitStatus};

fn cross_platform_touch(path: &Path) -> io::Result<ExitStatus> {
Command::new("touch").arg(&path).status()
Command::new("touch").arg(path).status()
}

#[test]
Expand Down
11 changes: 5 additions & 6 deletions src/meta/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ use chrono::Locale;
use once_cell::sync::OnceCell;
use sys_locale::get_locale;

fn locale_str() -> String {
get_locale().unwrap_or_default().replace('-', "_")
}

/// Finds current locale
pub fn current_locale() -> Locale {
const DEFAULT: Locale = Locale::en_US;
static CACHE: OnceCell<Locale> = OnceCell::new();

fn locale_str() -> String {
get_locale().unwrap_or("".to_string()).replace('-', "_")
}

*CACHE
.get_or_init(|| Locale::try_from(locale_str().as_str()).unwrap_or(DEFAULT))
*CACHE.get_or_init(|| Locale::try_from(locale_str().as_str()).unwrap_or(DEFAULT))
}
2 changes: 1 addition & 1 deletion src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ mod tests {
let path_c = tmp_dir.path().join("ccc.cc");

#[cfg(unix)]
std::os::unix::fs::symlink(&path_c, &path_b).expect("failed to create broken symlink");
std::os::unix::fs::symlink(path_c, &path_b).expect("failed to create broken symlink");

// this needs to be tested on Windows
// likely to fail because of permission issue
Expand Down
4 changes: 2 additions & 2 deletions src/meta/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Name {
// HyperlinkOption::Auto gets converted to None or Always in core.rs based on tty_available
match std::fs::canonicalize(&self.path) {
Ok(rp) => {
if let Ok(url) = Url::from_file_path(&rp) {
if let Ok(url) = Url::from_file_path(rp) {
// Crossterm does not support hyperlinks as of now
// https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
format!("\x1B]8;;{}\x1B\x5C{}\x1B]8;;\x1B\x5C", url, name)
Expand Down Expand Up @@ -426,7 +426,7 @@ mod test {
let colors = Colors::new(color::ThemeOption::NoColor);

let real_path = std::fs::canonicalize(&file_path).expect("canonicalize");
let expected_url = Url::from_file_path(&real_path).expect("absolute path");
let expected_url = Url::from_file_path(real_path).expect("absolute path");
let expected_text = format!(
"\x1B]8;;{}\x1B\x5C{}\x1B]8;;\x1B\x5C",
expected_url, "file.txt"
Expand Down
2 changes: 1 addition & 1 deletion src/meta/symlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct SymLink {
impl From<&Path> for SymLink {
fn from(path: &Path) -> Self {
if let Ok(target) = read_link(path) {
if target.is_absolute() || path.parent() == None {
if target.is_absolute() || path.parent().is_none() {
return Self {
valid: target.exists(),
target: Some(
Expand Down
2 changes: 1 addition & 1 deletion src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ mod tests {
let path_d = tmp_dir.path().join("ddd.dd");

#[cfg(unix)]
std::os::unix::fs::symlink(&path_d, &path_c).expect("failed to create broken symlink");
std::os::unix::fs::symlink(path_d, &path_c).expect("failed to create broken symlink");

// this needs to be tested on Windows
// likely to fail because of permission issue
Expand Down
8 changes: 4 additions & 4 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn test_dereference_link_broken_link_output() {
let target = dir.path().join("target");

#[cfg(unix)]
fs::symlink(&target, &link).unwrap();
fs::symlink(target, &link).unwrap();

// this needs to be tested on Windows
// likely to fail because of permission issue
Expand Down Expand Up @@ -369,7 +369,7 @@ fn test_show_folder_of_symlink_for_long_multi() {
let dir = tempdir();
dir.child("target").child("inside").touch().unwrap();
let link = dir.path().join("link");
fs::symlink("target", &link).unwrap();
fs::symlink("target", link).unwrap();

cmd()
.arg("-l")
Expand Down Expand Up @@ -552,7 +552,7 @@ fn test_tree_no_dereference() {
tmp.child("one.d").create_dir_all().unwrap();
tmp.child("one.d/samplefile").touch().unwrap();
let link = tmp.path().join("link");
fs::symlink("one.d", &link).unwrap();
fs::symlink("one.d", link).unwrap();

cmd()
.arg("--tree")
Expand All @@ -571,7 +571,7 @@ fn test_tree_dereference() {
tmp.child("one.d").create_dir_all().unwrap();
tmp.child("one.d/samplefile").touch().unwrap();
let link = tmp.path().join("link");
fs::symlink("one.d", &link).unwrap();
fs::symlink("one.d", link).unwrap();

cmd()
.arg("--ignore-config")
Expand Down

0 comments on commit 9630013

Please sign in to comment.