Skip to content

Commit

Permalink
fix: clippy warning v1.80
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Jul 26, 2024
1 parent efeadc5 commit 8a7d047
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 52 deletions.
8 changes: 0 additions & 8 deletions components/clarinet-cli/src/deployments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ use clarinet_deployments::types::{DeploymentGenerationArtifacts, DeploymentSpeci
use clarinet_files::chainhook_types::StacksNetwork;
use clarinet_files::{FileLocation, ProjectManifest};

#[derive(Deserialize, Debug)]
pub struct Balance {
pub balance: String,
pub nonce: u64,
pub balance_proof: String,
pub nonce_proof: String,
}

pub fn get_absolute_deployment_path(
manifest: &ProjectManifest,
relative_deployment_path: &str,
Expand Down
5 changes: 1 addition & 4 deletions components/clarinet-cli/src/frontend/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,10 +1600,7 @@ fn execute_changes(changes: Vec<Changes>) -> bool {
}
};

let mut requirements = match config.project.requirements.take() {
Some(requirements) => requirements,
None => vec![],
};
let mut requirements = config.project.requirements.take().unwrap_or_default();
for requirement in options.requirements_to_add.drain(..) {
if !requirements.contains(&requirement) {
requirements.push(requirement);
Expand Down
3 changes: 0 additions & 3 deletions components/clarinet-cli/src/generate/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@ use std::collections::HashMap;
#[derive(Clone, Debug)]
pub struct FileCreation {
pub comment: String,
pub name: String,
pub content: String,
pub path: String,
}

#[derive(Clone, Debug)]
pub struct FileDeletion {
pub comment: String,
pub name: String,
pub path: String,
}

#[derive(Clone, Debug)]
pub struct DirectoryCreation {
pub comment: String,
pub name: String,
pub path: String,
}

Expand Down
4 changes: 0 additions & 4 deletions components/clarinet-cli/src/generate/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ impl GetChangesForRmContract {
}
let change = FileDeletion {
comment: format!("{} tests/{}", red!("Deleted file"), name),
name,
path: f.to_string(),
};
self.changes.push(Changes::RemoveFile(change));
Expand All @@ -56,7 +55,6 @@ impl GetChangesForRmContract {
}
let change = FileDeletion {
comment: format!("{} contracts/{}", red!("Deleted file"), name),
name,
path: f.to_string(),
};
self.changes.push(Changes::RemoveFile(change));
Expand Down Expand Up @@ -159,7 +157,6 @@ impl GetChangesForNewContract {
}
let change = FileCreation {
comment: format!("{} contracts/{}", green!("Created file"), name),
name,
content,
path: new_file.to_string(),
};
Expand Down Expand Up @@ -201,7 +198,6 @@ describe("example tests", () => {
}
let change = FileCreation {
comment: format!("{} tests/{}", green!("Created file"), name),
name,
content,
path: new_file.to_string(),
};
Expand Down
3 changes: 0 additions & 3 deletions components/clarinet-cli/src/generate/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ impl GetChangesForNewProject {
fn create_root_directory(&mut self) {
let change = DirectoryCreation {
comment: format!("{} {}", green!("Created directory"), self.project_name),
name: self.project_name.clone(),
path: self.project_path.clone(),
};
self.changes.push(Changes::AddDirectory(change));
Expand Down Expand Up @@ -522,7 +521,6 @@ export default defineConfig({
let dir = format!("{}/{}", self.project_path, name);
Changes::AddDirectory(DirectoryCreation {
comment: format!("{} {}", green!("Created directory"), name),
name,
path: dir,
})
}
Expand All @@ -532,7 +530,6 @@ export default defineConfig({

Changes::AddFile(FileCreation {
comment: format!("{} {}", green!("Created file"), name),
name,
content,
path,
})
Expand Down
29 changes: 16 additions & 13 deletions components/clarinet-files/src/network_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,7 @@ impl NetworkManifest {
};

let devnet = if networks.1.is_devnet() {
let mut devnet_config = match network_manifest_file.devnet.take() {
Some(conf) => conf,
_ => DevnetConfigFile::default(),
};
let mut devnet_config = network_manifest_file.devnet.take().unwrap_or_default();

if let Some(ref devnet_override) = devnet_override {
if let Some(ref val) = devnet_override.name {
Expand Down Expand Up @@ -764,7 +761,7 @@ impl NetworkManifest {
let stacks_node_events_observers = devnet_config
.stacks_node_events_observers
.take()
.unwrap_or(vec![]);
.unwrap_or_default();

let subnet_contract_id = devnet_config
.subnet_contract_id
Expand Down Expand Up @@ -877,7 +874,7 @@ impl NetworkManifest {
.subnet_api_postgres_database
.take()
.unwrap_or("subnet_api".to_string()),
execute_script: devnet_config.execute_script.take().unwrap_or(vec![]),
execute_script: devnet_config.execute_script.take().unwrap_or_default(),
bitcoin_node_image_url: devnet_config
.bitcoin_node_image_url
.take()
Expand Down Expand Up @@ -906,7 +903,7 @@ impl NetworkManifest {
.bitcoin_explorer_image_url
.take()
.unwrap_or(DEFAULT_BITCOIN_EXPLORER_IMAGE.to_string()),
pox_stacking_orders: devnet_config.pox_stacking_orders.take().unwrap_or(vec![]),
pox_stacking_orders: devnet_config.pox_stacking_orders.take().unwrap_or_default(),
disable_bitcoin_explorer: devnet_config.disable_bitcoin_explorer.unwrap_or(false),
disable_stacks_api: devnet_config.disable_stacks_api.unwrap_or(false),
disable_stacks_explorer: devnet_config.disable_stacks_explorer.unwrap_or(false),
Expand All @@ -927,7 +924,7 @@ impl NetworkManifest {
subnet_node_events_observers: devnet_config
.subnet_node_events_observers
.take()
.unwrap_or(vec![]),
.unwrap_or_default(),
subnet_contract_id,
remapped_subnet_contract_id,
subnet_api_image_url: devnet_config
Expand All @@ -951,14 +948,20 @@ impl NetworkManifest {
epoch_2_4: devnet_config.epoch_2_4.unwrap_or(DEFAULT_EPOCH_2_4),
epoch_2_5: devnet_config.epoch_2_5.unwrap_or(DEFAULT_EPOCH_2_5),
epoch_3_0: devnet_config.epoch_3_0.unwrap_or(DEFAULT_EPOCH_3_0),
stacks_node_env_vars: devnet_config.stacks_node_env_vars.take().unwrap_or(vec![]),
stacks_api_env_vars: devnet_config.stacks_api_env_vars.take().unwrap_or(vec![]),
stacks_node_env_vars: devnet_config
.stacks_node_env_vars
.take()
.unwrap_or_default(),
stacks_api_env_vars: devnet_config.stacks_api_env_vars.take().unwrap_or_default(),
stacks_explorer_env_vars: devnet_config
.stacks_explorer_env_vars
.take()
.unwrap_or(vec![]),
subnet_node_env_vars: devnet_config.subnet_node_env_vars.take().unwrap_or(vec![]),
subnet_api_env_vars: devnet_config.subnet_api_env_vars.take().unwrap_or(vec![]),
.unwrap_or_default(),
subnet_node_env_vars: devnet_config
.subnet_node_env_vars
.take()
.unwrap_or_default(),
subnet_api_env_vars: devnet_config.subnet_api_env_vars.take().unwrap_or_default(),
use_docker_gateway_routing: devnet_config
.use_docker_gateway_routing
.unwrap_or(false),
Expand Down
15 changes: 3 additions & 12 deletions components/clarity-lsp/src/common/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,22 +578,13 @@ impl ProtocolState {
Some(deps) => deps,
None => DependencySet::new(),
};
let diags = match diags.remove(&contract_id) {
Some(diags) => diags,
None => vec![],
};
let analysis = match analyses.remove(&contract_id) {
Some(analysis) => analysis,
None => None,
};
let diags = diags.remove(&contract_id).unwrap_or_default();
let analysis = analyses.remove(&contract_id).unwrap_or_default();
let clarity_version = match clarity_versions.remove(&contract_id) {
Some(analysis) => analysis,
None => DEFAULT_CLARITY_VERSION,
};
let definitions = match definitions.remove(&contract_id) {
Some(definitions) => definitions,
None => HashMap::new(),
};
let definitions = definitions.remove(&contract_id).unwrap_or_default();

let contract_state = ContractState::new(
contract_id.clone(),
Expand Down
5 changes: 1 addition & 4 deletions components/clarity-repl/src/analysis/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,7 @@ impl EvalHook for TestCoverageReport {
expr: &SymbolicExpression,
) {
let contract = &env.contract_context.contract_identifier;
let mut contract_report = match self.contracts_coverage.remove(contract) {
Some(e) => e,
_ => HashMap::new(),
};
let mut contract_report = self.contracts_coverage.remove(contract).unwrap_or_default();
report_eval(&mut contract_report, expr);
self.contracts_coverage
.insert(contract.clone(), contract_report);
Expand Down
2 changes: 1 addition & 1 deletion components/stacks-codec/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ macro_rules! impl_array_newtype {
}
}

#[cfg_attr(feature = "clippy", allow(expl_impl_clone_on_copy))] // we don't define the `struct`, we have to explicitly impl
// #[cfg_attr(allow(expl_impl_clone_on_copy))] // we don't define the `struct`, we have to explicitly impl
impl Clone for $thing {
#[inline]
fn clone(&self) -> $thing {
Expand Down

0 comments on commit 8a7d047

Please sign in to comment.