Skip to content

Commit 0369e36

Browse files
authored
refactor: address cargo check warnings and apply cargo fmt (#26)
* refactor: apply cargo fix * refactor: apply cargo fmt * refactor: remove or suppress unused * refactor(ext_deps): remove redundant return
1 parent 3f17180 commit 0369e36

File tree

7 files changed

+15
-42
lines changed

7 files changed

+15
-42
lines changed

src/command/self_update.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::github::api::GithubApi;
22
use crate::updater::constants::{GH_REPO, GH_USER};
33
use crate::updater::release;
4-
use crate::updater::release::{ReleaseVersion, ReleaseVersionCompareResult};
4+
use crate::updater::release::ReleaseVersionCompareResult;
55
use crate::{ERROR, INFO, SUCCESS};
66
use console::Term;
77
use futures::StreamExt;

src/config/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::config::constants::{
2-
CONFIG_FILE_NAME, CONFIG_PATH, HOME_ENV, PROJECT_NAME, WINDOWS_APPDATA_ENV,
3-
WINDOWS_HOMEDRIVE_ENV, WINDOWS_HOMEPATH_ENV, WINDOWS_USERPROFILE_ENV, XDG_CONFIG_ENV,
2+
CONFIG_FILE_NAME, CONFIG_PATH, HOME_ENV, PROJECT_NAME, WINDOWS_APPDATA_ENV, XDG_CONFIG_ENV,
43
};
54
use crate::config::models::RedOxideConfig;
65
use crate::redacted::models::ReleaseType::{Flac, Mp3320, Mp3V0};

src/config/constants.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub const CONFIG_FILE_NAME: &str = "red_oxide.config.json";
2+
23
pub const PROJECT_NAME: &str = "red_oxide";
34

45
pub const CONFIG_PATH: &str = ".config";
@@ -8,6 +9,3 @@ pub const XDG_CONFIG_ENV: &str = "XDG_CONFIG_HOME";
89
pub const HOME_ENV: &str = "HOME";
910

1011
pub const WINDOWS_APPDATA_ENV: &str = "APPDATA";
11-
pub const WINDOWS_USERPROFILE_ENV: &str = "USERPROFILE";
12-
pub const WINDOWS_HOMEDRIVE_ENV: &str = "HOMEDRIVE";
13-
pub const WINDOWS_HOMEPATH_ENV: &str = "HOMEPATH";

src/ext_deps/util.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
// Windows
22
#[cfg(target_os = "windows")]
33
pub fn get_flac_executable() -> String {
4-
return "flac.exe".to_string()
4+
"flac.exe".to_string()
55
}
66

77
#[cfg(target_os = "windows")]
88
pub fn get_sox_executable() -> String {
9-
return "sox.exe".to_string()
9+
"sox.exe".to_string()
1010
}
1111

1212
#[cfg(target_os = "windows")]
13-
pub fn get_lame_executable() -> String{
14-
return "lame.exe".to_string()
13+
pub fn get_lame_executable() -> String {
14+
"lame.exe".to_string()
1515
}
1616

1717
#[cfg(target_os = "windows")]
1818
pub fn get_imdl_executable_name() -> String {
19-
return "imdl.exe".to_string()
19+
"imdl.exe".to_string()
2020
}
2121

2222
// Linux or Mac
2323
#[cfg(not(target_os = "windows"))]
2424
pub fn get_flac_executable() -> String {
25-
return "flac".to_string()
25+
"flac".to_string()
2626
}
2727

2828
#[cfg(not(target_os = "windows"))]
2929
pub fn get_sox_executable() -> String {
30-
return "sox".to_string()
30+
"sox".to_string()
3131
}
3232

3333
#[cfg(not(target_os = "windows"))]
3434
pub fn get_lame_executable() -> String {
35-
return "lame".to_string()
35+
"lame".to_string()
3636
}
3737

3838
#[cfg(not(target_os = "windows"))]
3939
pub fn get_imdl_executable_name() -> String {
40-
return "imdl".to_string()
41-
}
40+
"imdl".to_string()
41+
}

src/fs/util.rs

-25
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,3 @@ pub async fn get_all_files_with_extension(
2727

2828
return Ok(files);
2929
}
30-
31-
#[async_recursion]
32-
pub async fn count_files_with_extension(
33-
dir_path: &PathBuf,
34-
extension: &str,
35-
) -> Result<u64, anyhow::Error> {
36-
let mut dir = fs::read_dir(dir_path).await?;
37-
let mut count = 0;
38-
39-
while let Some(entry) = dir.next_entry().await? {
40-
let path = entry.path();
41-
42-
if path.is_dir() {
43-
count += count_files_with_extension(&path, extension).await?;
44-
} else {
45-
let file_name = path.file_name().unwrap().to_str().unwrap();
46-
47-
if file_name.ends_with(extension) {
48-
count += 1;
49-
}
50-
}
51-
}
52-
53-
return Ok(count);
54-
}

src/redacted/api/client.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl RedactedApi {
4949
.await;
5050
}
5151

52+
#[allow(dead_code)]
5253
pub async fn get_torrent_info(
5354
&mut self,
5455
torrent_id: i64,

src/tags/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn validate_tags_of_file(path: PathBuf, media: &Media) -> anyhow::Result<(bo
5959
return Ok((false, false));
6060
}
6161

62-
let (track_number, total_tracks) = tag.track();
62+
let (track_number, _total_tracks) = tag.track();
6363

6464
if track_number.is_none() {
6565
return Ok((false, media == &Vinyl));

0 commit comments

Comments
 (0)