Skip to content

Commit

Permalink
solved some clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-eth committed Feb 11, 2024
1 parent 414eee7 commit 0987a3a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "soldeer"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
authors = ["m4rio"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This project was started to solve the following issues:
- github versioning of the releases is a pain and not all the projects are using it correctly


## Version 0.2.0
## Version 0.2.1

### WARNING

Expand Down
12 changes: 6 additions & 6 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ pub async fn login() {
print!("ℹ️ If you do not have an account, please go to soldeer.xyz to create one.\n📧 Please enter your email: ");
std::io::stdout().flush().unwrap();
let mut email = String::new();
match io::stdin().read_line(&mut email) {
Ok(_) => {}
Err(_) => {}
if io::stdin().read_line(&mut email).is_err() {
println!("Invalid email");
exit(500);
}
email = email.trim().to_string().to_ascii_lowercase();

Expand All @@ -55,7 +55,7 @@ pub async fn login() {

let login: Login = Login {
email: email.unwrap().to_string(),
password: password,
password,
};

let url = format!("{}/api/v1/auth/login", crate::BASE_URL);
Expand Down Expand Up @@ -85,12 +85,12 @@ pub async fn login() {
println!("Authentication failed. Invalid email or password");
exit(500);
}
println!("Authentication failed. {}", response.status().to_string());
println!("Authentication failed. {}", response.status());
exit(500);
}
}
Err(error) => {
println!("Login failed with error {}", error.to_string());
println!("Login failed {}", error);
exit(500);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct Login {}

#[derive(Debug, Clone, Parser)]
#[clap(
about = "Push a dependency to the central repository. The PATH_TO_DEPENDENCY is optional and if not provided, the current directory will be used.",
about = "Push a dependency to the repository. The PATH_TO_DEPENDENCY is optional and if not provided, the current directory will be used. \nExample: If the directory is /home/soldeer/my_project and you do not specify the PATH_TO_DEPENDENCY, \nthe files inside the /home/soldeer/my_project will be pushed to the repository. \nIf you specify the PATH_TO_DEPENDENCY, the files inside the specified directory will be pushed to the repository. \nExample: soldeer push dependency~version /home/soldeer/my_project",
after_help = "For more information, read the README.md",
override_usage = "soldeer push <DEPENDENCY>~<VERSION> [PATH_TO_DEPENDENCY]"
)]
Expand Down
2 changes: 1 addition & 1 deletion src/dependency_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ mod tests {
assert!(result.is_ok());
let result: Result<(), MissingDependencies> =
healthcheck_dependency("@openzeppelin-contracts", "2.3.0");
assert!(!result.is_err());
assert!(result.is_ok());
}
}
6 changes: 3 additions & 3 deletions src/janitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mod tests {
let _ = unzip_dependency(&dependencies[0].name, &dependencies[0].version);
let result: Result<(), MissingDependencies> =
healthcheck_dependency("@openzeppelin-contracts", "2.3.0");
assert!(!result.is_err());
assert!(result.is_ok());

clean_dependency_directory();
}
Expand All @@ -146,7 +146,7 @@ mod tests {
let _ = unzip_dependency(&dependencies[0].name, &dependencies[0].version);
let result: Result<(), MissingDependencies> =
cleanup_dependency("@openzeppelin-contracts", "2.3.0");
assert!(!result.is_err());
assert!(result.is_ok());
clean_dependency_directory();
}

Expand Down Expand Up @@ -183,7 +183,7 @@ mod tests {
let _ = aw!(download_dependencies(&dependencies, false));
let _ = unzip_dependency(&dependencies[0].name, &dependencies[0].version);
let result: Result<(), MissingDependencies> = cleanup_after(&dependencies);
assert!(!result.is_err());
assert!(result.is_ok());
clean_dependency_directory();
}

Expand Down
8 changes: 4 additions & 4 deletions src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fn sha256_digest(dependency_name: &str, dependency_version: &str) -> String {

#[cfg(test)]
fn sha256_digest(_dependency_name: &str, _dependency_version: &str) -> String {
return "5019418b1e9128185398870f77a42e51d624c44315bb1572e7545be51d707016".to_string();
"5019418b1e9128185398870f77a42e51d624c44315bb1572e7545be51d707016".to_string()
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -177,7 +177,7 @@ version = "0.6.5"
source = "registry+https://github.com/mario-eth/soldeer-versions/raw/main/all_versions/@prb-test~0.6.5.zip"
checksum = "5019418b1e9128185398870f77a42e51d624c44315bb1572e7545be51d707016"
"#;
File::create(&lock_file)
File::create(lock_file)
.unwrap()
.write_all(lock_contents.as_bytes())
.unwrap();
Expand All @@ -194,7 +194,7 @@ checksum = "5019418b1e9128185398870f77a42e51d624c44315bb1572e7545be51d707016"
url: "https://github.com/mario-eth/soldeer-versions/raw/main/all_versions/@openzeppelin-contracts~2.3.0.zip".to_string(),
});
let _result: Vec<Dependency> = lock_check(&dependencies).unwrap();
assert_eq!(lock_file.exists(), false);
assert!(!lock_file.exists());
}

#[test]
Expand Down Expand Up @@ -234,7 +234,7 @@ checksum = "5019418b1e9128185398870f77a42e51d624c44315bb1572e7545be51d707016"
assert_eq!(result.len(), 1);
assert_eq!(result[0].name, "@openzeppelin-contracts");
assert_eq!(result[0].version, "2.4.0");
fs::remove_file(&lock_file).unwrap();
fs::remove_file(lock_file).unwrap();
}

#[test]
Expand Down
16 changes: 8 additions & 8 deletions src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ pub async fn get_dependency_url_remote(
match revision {
Ok(revision) => {
if revision.data.is_empty() {
println!("Dependency not found, please check the dependency name");
println!("Dependency not found, please check the dependency name and version");
exit(500);
}
return revision.data[0].clone().url;
revision.data[0].clone().url
}
Err(error) => {
println!("Error getting dependency {}", error.to_string());
println!("Error getting dependency {}", error);
exit(500);
}
}
} else {
println!("Dependency not found, please check the dependency name");
println!("Dependency not found, please check the dependency name and version");
exit(500);
}
}
Err(error) => {
println!("Error getting dependency {}", error.to_string());
println!("Error getting dependency {}", error);
exit(500);
}
}
Expand All @@ -69,10 +69,10 @@ pub async fn get_project_id(dependency_name: &String) -> String {
println!("Project not found, please check the dependency name (project name) or create a new project on https://soldeer.xyz");
exit(500);
}
return project.data[0].id.to_string();
project.data[0].id.to_string()
}
Err(error) => {
println!("Error getting dependency {}", error.to_string());
println!("Error getting dependency {}", error);
exit(500);
}
}
Expand All @@ -82,7 +82,7 @@ pub async fn get_project_id(dependency_name: &String) -> String {
}
}
Err(error) => {
println!("Error getting dependency {}", error.to_string());
println!("Error getting dependency {}", error);
exit(500);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ pub fn read_file(path: String) -> Result<Vec<u8>, std::io::Error> {
pub fn define_security_file_location() -> String {
let custom_security_file = option_env!("SOLDEER_LOGIN_FILE");
if custom_security_file.is_some()
&& custom_security_file.unwrap().len() > 0
&& !custom_security_file.unwrap().is_empty()
&& Path::new(custom_security_file.unwrap()).exists()
{
#[allow(clippy::unnecessary_unwrap)]
return String::from(custom_security_file.unwrap());
}
let home = home_dir();
Expand Down
8 changes: 4 additions & 4 deletions src/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ pub async fn push_version(
}

fn zip_file(
root_directory_path: &PathBuf,
root_directory_path: &Path,
files_to_copy: &Vec<FilePair>,
file_name: &String,
) -> Result<PathBuf, PushError> {
let zip_file_path = root_directory_path.join(file_name.to_owned() + ".zip");
let file = File::create(&zip_file_path.to_str().unwrap()).unwrap();
let file = File::create(zip_file_path.to_str().unwrap()).unwrap();

let mut zip = ZipWriter::new(file);
let options = FileOptions::default().compression_method(CompressionMethod::DEFLATE);
Expand Down Expand Up @@ -114,7 +114,7 @@ fn zip_file(
Ok(zip_file_path)
}

fn filter_filles_to_copy(root_directory_path: &PathBuf) -> Vec<FilePair> {
fn filter_filles_to_copy(root_directory_path: &Path) -> Vec<FilePair> {
let ignore_files: Vec<String> = read_ignore_file();

let root_directory: &str = &(root_directory_path.to_str().unwrap().to_owned() + "/");
Expand Down Expand Up @@ -167,7 +167,7 @@ fn read_ignore_file() -> Vec<String> {
}

async fn push_to_repo(
zip_file: &PathBuf,
zip_file: &Path,
dependency_name: String,
dependency_version: String,
) -> Result<(), PushError> {
Expand Down

0 comments on commit 0987a3a

Please sign in to comment.