Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Dec 8, 2024
1 parent e4d28c5 commit 65bc6d3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "geode"
version = "3.2.2"
version = "3.3.0"
authors = [
"HJfod <[email protected]>",
"Camila314 <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn read_dir_recursive(src: &PathBuf) -> Result<Vec<PathBuf>, io::Error> {
Ok(res)
}

#[allow(unused)]
pub fn copy_dir_recursive(src: &PathBuf, dest: &PathBuf) -> Result<(), io::Error> {
fs::create_dir_all(dest)?;
for item in fs::read_dir(src)? {
Expand Down
8 changes: 4 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use crate::config::Config;
use crate::server::{ApiResponse, PaginatedData};
use crate::util::logging::ask_value;
use crate::util::mod_file::parse_mod_info;
use crate::{done, fatal, index_admin, index_auth, index_dev, info, warn, NiceUnwrap};
use crate::{done, fatal, index_admin, index_auth, index_dev, info, NiceUnwrap};
use clap::Subcommand;
use reqwest::header::USER_AGENT;
use semver::VersionReq;
use serde::{Deserialize, Serialize};
use serde_json::json;
use sha3::{Digest, Sha3_256};
use std::fs;
use std::io::Cursor;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use zip::read::ZipFile;

#[derive(Deserialize)]
pub struct ServerModVersion {
#[allow(unused)]
pub name: String,
pub version: String,
pub download_link: String,
#[allow(unused)]
pub hash: String,
}

Expand Down
3 changes: 1 addition & 2 deletions src/info.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::config::{self, Config};
use crate::logging::ask_value;
use crate::util::config::Profile;
use crate::{done, fail, info, warn, NiceUnwrap};
use crate::{done, fail, warn, NiceUnwrap};
use clap::Subcommand;
use colored::Colorize;
use std::cell::RefCell;
use std::io::BufRead;

/**
* geode info
Expand Down
20 changes: 10 additions & 10 deletions src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn create_resources(
spritesheet::downscale(&mut sprite, 2);
sprite.save(output_dir.join(base.to_string() + ".png"))
})()
.nice_unwrap(&format!(
.nice_unwrap(format!(
"Unable to copy sprite at {}",
sprite_path.display()
));
Expand All @@ -203,7 +203,7 @@ fn create_resources(
// Move other resources
for file in &mod_info.resources.files {
std::fs::copy(file, output_dir.join(file.file_name().unwrap()))
.nice_unwrap(&format!("Unable to copy file at '{}'", file.display()));
.nice_unwrap(format!("Unable to copy file at '{}'", file.display()));
}

if !&mod_info.resources.libraries.is_empty() {
Expand All @@ -212,7 +212,7 @@ fn create_resources(
// Move other resources
for file in &mod_info.resources.libraries {
std::fs::copy(file, working_dir.join(file.file_name().unwrap()))
.nice_unwrap(&format!("Unable to copy file at '{}'", file.display()));
.nice_unwrap(format!("Unable to copy file at '{}'", file.display()));
}
}

Expand Down Expand Up @@ -282,7 +282,7 @@ fn create_package(
&mod_file_info,
&mut cache_bundle,
&mut new_cache,
&working_dir,
working_dir,
&working_dir.join("resources").join(&mod_file_info.id),
false,
);
Expand All @@ -292,7 +292,7 @@ fn create_package(
let path = root_path.join(file);
if path.exists() {
std::fs::copy(path, working_dir.join(file))
.nice_unwrap(&format!("Could not copy {file}"));
.nice_unwrap(format!("Could not copy {file}"));
}
}

Expand All @@ -301,7 +301,7 @@ fn create_package(
for header in &api.include {
let out = working_dir.join(header);
out.parent().map(fs::create_dir_all);
fs::copy(root_path.join(header), &out).nice_unwrap(&format!(
fs::copy(root_path.join(header), &out).nice_unwrap(format!(
"Unable to copy header {} to {}",
header.display(),
out.display()
Expand All @@ -328,7 +328,7 @@ fn create_package(
) {
let binary = name.to_string_lossy().to_string() + "." + ext.to_string_lossy().as_ref();
std::fs::copy(path, working_dir.join(&binary))
.nice_unwrap(&format!("Unable to copy binary '{}'", binary));
.nice_unwrap(format!("Unable to copy binary '{}'", binary));
binaries_added = true;
}
}
Expand All @@ -353,7 +353,7 @@ fn create_package(
}

std::fs::copy(binary, working_dir.join(binary_name))
.nice_unwrap(&format!("Unable to copy binary at '{}'", binary.display()));
.nice_unwrap(format!("Unable to copy binary at '{}'", binary.display()));
binaries_added = true;
}

Expand All @@ -363,9 +363,9 @@ fn create_package(
info!("Help: Add a binary with `--binary <bin_path>`");
}

new_cache.save(&working_dir);
new_cache.save(working_dir);

zip_folder(&working_dir, &output);
zip_folder(working_dir, &output);

if do_install {
let config = Config::new().assert_is_setup();
Expand Down
1 change: 0 additions & 1 deletion src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::config::{Config, Profile as CfgProfile};
use crate::{done, fail, info, warn, NiceUnwrap};
use clap::{Subcommand, ValueEnum};
use colored::Colorize;
use rustyline::config;
use std::cell::RefCell;
use std::process::Command;

Expand Down
4 changes: 3 additions & 1 deletion src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use reqwest::header::{AUTHORIZATION, USER_AGENT};
use semver::{Prerelease, Version};
use serde::Deserialize;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand All @@ -35,6 +34,7 @@ struct GithubReleaseResponse {
assets: Vec<GithubReleaseAsset>,
}

#[allow(unused)]
struct LinuxShellConfig {
profile: String,
profile_bak: String,
Expand Down Expand Up @@ -268,6 +268,7 @@ fn set_sdk_env(path: &Path) -> bool {
env_success
}

#[allow(unused)]
fn detect_user_shell() -> Option<UserShell> {
let shell = match env::var("SHELL") {
Err(_) => {
Expand All @@ -288,6 +289,7 @@ fn detect_user_shell() -> Option<UserShell> {
None
}

#[allow(unused)]
fn get_linux_shell_info(shell: UserShell, path: &Path) -> Option<LinuxShellConfig> {
let home = match env::var("HOME") {
Err(_) => return None,
Expand Down
4 changes: 2 additions & 2 deletions src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::path::PathBuf;

use crate::{done, fail, fatal, info, warn, NiceUnwrap};
use crate::{done, fail, fatal, warn, NiceUnwrap};

#[derive(Serialize, Deserialize, Clone)]
#[serde(rename_all = "kebab-case")]
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Config {
pub fn rename_profile(&mut self, old: &str, new: String) {
let profile = self
.get_profile(&Some(String::from(old)))
.nice_unwrap(&format!("Profile named '{}' does not exist", old));
.nice_unwrap(format!("Profile named '{}' does not exist", old));

if self.get_profile(&Some(new.to_owned())).is_some() {
fail!("The name '{}' is already taken!", new);
Expand Down
2 changes: 1 addition & 1 deletion src/util/spritesheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl SheetBundles {
}

pub fn read_to_image(path: &Path) -> RgbaImage {
image::io::Reader::open(path)
image::ImageReader::open(path)
.nice_unwrap(format!("Error reading sprite '{}'", path.display()))
.decode()
.nice_unwrap(format!("Error decoding sprite '{}'", path.display()))
Expand Down

0 comments on commit 65bc6d3

Please sign in to comment.