Skip to content

Commit

Permalink
chore: enable some more lints (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Aug 26, 2024
1 parent 8585a7e commit 4490551
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
19 changes: 19 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ readme = "./README.md"
repository = "https://github.com/mario-eth/soldeer"
version = "0.3.0"

[lints]
workspace = true

[workspace.lints.clippy]
dbg-macro = "warn"
manual-string-new = "warn"
# uninlined-format-args = "warn"
# use-self = "warn"
redundant-clone = "warn"

[workspace.lints.rust]
rust-2018-idioms = "warn"
# unreachable-pub = "warn"
unused-must-use = "warn"
redundant-lifetimes = "warn"

[workspace.lints.rustdoc]
all = "warn"

[dependencies]
chrono = { version = "0.4.38", default-features = false, features = [
"std",
Expand Down
32 changes: 11 additions & 21 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};
use serde::{Deserialize, Serialize};
use std::{
env,
env, fmt,
fs::{self, remove_dir_all, remove_file, File},
io::{self, Write},
path::{Path, PathBuf},
Expand Down Expand Up @@ -72,8 +72,8 @@ pub struct GitDependency {
pub rev: Option<String>,
}

impl core::fmt::Display for GitDependency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
impl fmt::Display for GitDependency {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}~{}", self.name, self.version)
}
}
Expand All @@ -86,8 +86,8 @@ pub struct HttpDependency {
pub checksum: Option<String>,
}

impl core::fmt::Display for HttpDependency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
impl fmt::Display for HttpDependency {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}~{}", self.name, self.version)
}
}
Expand Down Expand Up @@ -208,8 +208,8 @@ impl Dependency {
}
}

impl core::fmt::Display for Dependency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
impl fmt::Display for Dependency {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Dependency::Http(dep) => write!(f, "{}", dep),
Dependency::Git(dep) => write!(f, "{}", dep),
Expand Down Expand Up @@ -352,7 +352,7 @@ pub async fn remappings_txt(
}
let contents = match remappings_path.exists() {
true => read_file_to_string(&remappings_path),
false => "".to_string(),
false => String::new(),
};
let existing_remappings = contents.lines().filter_map(|r| r.split_once('=')).collect();

Expand Down Expand Up @@ -516,27 +516,17 @@ fn parse_dependency(name: impl Into<String>, value: &Item) -> Result<Dependency>
}
None => None,
};
return Ok(Dependency::Git(GitDependency {
name: name.to_string(),
git: git.to_string(),
version,
rev,
}));
return Ok(Dependency::Git(GitDependency { name, git: git.to_string(), version, rev }));
}
None => {}
}

// we should have a HTTP dependency
match table.get("url").map(|v| v.as_str()) {
Some(None) => Err(ConfigError::InvalidField { field: "url".to_string(), dep: name }),
None => Ok(Dependency::Http(HttpDependency {
name: name.to_string(),
version,
url: None,
checksum: None,
})),
None => Ok(Dependency::Http(HttpDependency { name, version, url: None, checksum: None })),
Some(Some(url)) => Ok(Dependency::Http(HttpDependency {
name: name.to_string(),
name,
version,
url: Some(url.to_string()),
checksum: None,
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
//! # soldeer
//!
//! Solidity package manager.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use crate::{
auth::login,
config::{delete_config, read_config_deps, remappings_txt, Dependency},
Expand Down
2 changes: 1 addition & 1 deletion src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ integrity = "deadbeef"
url: Some( "https://github.com/mario-eth/soldeer-versions/raw/main/all_versions/@openzeppelin-contracts~2.5.0.zip".to_string()),
checksum: Some("5019418b1e9128185398870f77a42e51d624c44315bb1572e7545be51d707016".to_string())
});
let dependencies = vec![dependency.clone(), dependency2.clone()];
let dependencies = vec![dependency.clone(), dependency2];
write_lock(
&dependencies,
&[Some("deadbeef".into()), Some("deadbeef".into())],
Expand Down
2 changes: 0 additions & 2 deletions tests/ci/foundry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use std::{
process::Command,
};

extern crate soldeer;

#[test]
#[serial]
fn soldeer_install_valid_dependency() {
Expand Down

0 comments on commit 4490551

Please sign in to comment.