Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 8c9bf53

Browse files
committed
chore: fix clippy warnings
1 parent d627770 commit 8c9bf53

File tree

17 files changed

+29
-29
lines changed

17 files changed

+29
-29
lines changed

src/commands.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::entities::FetchError;
4141
pub fn expect_token() -> String {
4242
if crate::auth::validate_token() {
4343
log("Your token is valid!");
44-
return crate::auth::get_token().unwrap();
44+
crate::auth::get_token().unwrap()
4545
} else {
4646
err("Your token is invalid!");
4747
std::process::exit(1);
@@ -81,21 +81,21 @@ mod tests {
8181

8282
#[test]
8383
fn log() {
84-
let mut out = String::from("✔".green().bold().to_string());
84+
let mut out = "✔".green().bold().to_string();
8585
out.push_str(" Some logs");
8686
assert_eq!(super::format_log("Some logs"), out)
8787
}
8888

8989
#[test]
9090
fn err() {
91-
let mut out = String::from("✘".red().bold().to_string());
91+
let mut out = "X".red().bold().to_string();
9292
out.push_str(" Some errors");
9393
assert_eq!(super::format_err("Some errors"), out)
9494
}
9595

9696
#[test]
9797
fn warn() {
98-
let mut out = String::from("!".yellow().bold().to_string());
98+
let mut out = "!".yellow().bold().to_string();
9999
out.push_str(" Some warnings");
100100
assert_eq!(super::format_warn("Some warnings"), out)
101101
}

src/commands/aboutme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use colored::Colorize;
44
#[tracing::instrument]
55
pub fn aboutme() {
66
let token = super::expect_token();
7-
match crate::entities::user::fetch_user(token.clone()) {
7+
match crate::entities::user::fetch_user(token) {
88
Ok(user) => {
99
println!("ID: {}", user.user_id.bright_black());
1010
println!("Plan: {}", color_plan(user.plan));

src/commands/apps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::entities::FetchError;
44
#[tracing::instrument]
55
pub fn apps() {
66
let token = super::expect_token();
7-
match crate::entities::app::App::fetch_all(token.clone()) {
7+
match crate::entities::app::App::fetch_all(token) {
88
Ok(apps) => {
99
println!("Your apps:");
1010
for app in apps {

src/commands/commit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ where
6666
let mut f = File::open(path)?;
6767

6868
f.read_to_end(&mut buffer)?;
69-
zip.write_all(&*buffer)?;
69+
zip.write_all(&buffer)?;
7070
buffer.clear();
7171
println!("{}", "✔".green().bold());
72-
} else if name.as_os_str().len() != 0 {
72+
} else if !name.as_os_str().is_empty() {
7373
zip.add_directory(name.to_str().unwrap(), options)?;
7474
}
7575
}
@@ -88,7 +88,7 @@ fn zip_dir_to_file(
8888
}
8989
let writer = File::create(dst_file).unwrap();
9090

91-
let walkdir = WalkDir::new(src_dir.to_string());
91+
let walkdir = WalkDir::new(src_dir);
9292
let it = walkdir.into_iter();
9393

9494
zip_dir(

src/commands/init.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use dialoguer::{theme::ColorfulTheme, Select};
22

33
fn vec_from_str(s: String) -> Vec<String> {
4-
s.split(",").map(|s| s.trim().into()).collect()
4+
s.split(',').map(|s| s.trim().into()).collect()
55
}
66

77
#[derive(Default)]
@@ -25,7 +25,7 @@ impl App {
2525
fn get_config(&self) -> String {
2626
match &self.typ {
2727
AppTyp::Site => {
28-
if self.apt.len() > 0 {
28+
if !self.apt.is_empty() {
2929
format!(
3030
"ID={}\nMAIN={}\nAUTORESTART={}\nRAM={}\nAPT={}\nTYPE=site\nVERSION=latest",
3131
self.subdomain,
@@ -42,7 +42,7 @@ impl App {
4242
}
4343
}
4444
AppTyp::Bot => {
45-
if self.apt.len() > 0 {
45+
if !self.apt.is_empty() {
4646
format!("NAME={}\nAVATAR={}\nMAIN={}\nAUTORESTART={}\nRAM={}\nAPT={}\nTYPE=bot\nVERSION=latest", self.name, self.avatar, self.main, self.autorestart, self.ram, self.apt.join(","))
4747
} else {
4848
format!("NAME={}\nAVATAR={}\nMAIN={}\nAUTORESTART={}\nRAM={}\nTYPE=bot\nVERSION=latest", self.name,self.avatar, self.main, self.autorestart, self.ram)
@@ -60,7 +60,7 @@ pub fn init() -> std::io::Result<()> {
6060
let typ = Select::with_theme(&ColorfulTheme::default())
6161
.with_prompt("Type")
6262
.default(0)
63-
.items(&vec!["Bot", "Site"])
63+
.items(&["Bot", "Site"])
6464
.interact()?;
6565
let mut app: App = Default::default();
6666
match typ {
@@ -96,7 +96,7 @@ pub fn init() -> std::io::Result<()> {
9696
.with_prompt("APT Packages")
9797
.allow_empty(true)
9898
.interact_text()?;
99-
if apt.len() > 0 {
99+
if !apt.is_empty() {
100100
app.apt = vec_from_str(apt);
101101
}
102102
std::fs::write("discloud.config", app.get_config())?;

src/commands/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clap::*;
33
pub fn login(matches: &ArgMatches) -> std::io::Result<()> {
44
let token = matches.get_one::<String>("token").unwrap().clone();
55
if let Err(err) = crate::auth::login(token) {
6-
super::err(format!("Couldn't save the token: {}", err.kind().to_string()).as_str());
6+
super::err(format!("Couldn't save the token: {}", err.kind()).as_str());
77
Err(err)
88
} else {
99
super::log("Token saved successfully");

src/commands/logs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn logs() {
66
match super::ask_for_app(token.clone(), "show the logs") {
77
Ok(app_id) => {
88
let mut spinner = Spinner::new(Spinners::Bounce, "Downloading the logs".into());
9-
match crate::entities::app::App::get_logs(token.clone(), app_id) {
9+
match crate::entities::app::App::get_logs(token, app_id) {
1010
Ok(logs) => {
1111
spinner.stop_with_message(logs);
1212
}

src/commands/mods/add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn add(id: u128) {
1616

1717
let moderator = crate::handle_result!(
1818
Mod::new(
19-
token.clone(),
19+
token,
2020
id,
2121
app_id,
2222
vec![Feature::SeeLogs, Feature::Status]

src/commands/mods/allow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn allow(id: u128, features: Vec<Feature>) {
1616
Some(mut moderator) => {
1717
let mut feats = moderator.get_features();
1818
feats.append(&mut features.clone());
19-
crate::handle_result!(moderator.set_features(feats, token.clone()), spinner);
19+
crate::handle_result!(moderator.set_features(feats, token), spinner);
2020
spinner.stop_with_message(super::format_log(&format!(
2121
"{:?} were added successfully!",
2222
features

src/commands/mods/deny.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::entities::moderator::Feature;
22
use spinners::*;
3-
fn subtract_vecs<T>(v1: &Vec<T>, v2: &Vec<T>) -> Vec<T>
3+
fn subtract_vecs<T>(v1: &[T], v2: &[T]) -> Vec<T>
44
where
55
T: Eq + Clone,
66
{
@@ -23,7 +23,7 @@ pub fn deny(id: u128, features: Vec<Feature>) {
2323
crate::handle_result!(
2424
moderator.set_features(
2525
subtract_vecs(&moderator.get_features(), &features),
26-
token.clone()
26+
token
2727
),
2828
spinner
2929
);

0 commit comments

Comments
 (0)