Skip to content

Commit

Permalink
reafactor: clippy (#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard authored Feb 8, 2024
1 parent bc74e5a commit 2497b4c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ use clarity::vm::types::{
};
use clarity::vm::{ClarityName, ClarityVersion, SymbolicExpressionType};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::convert::TryFrom;
use std::iter::FromIterator;
use std::ops::{Deref, DerefMut};

use super::ast_visitor::TypedVar;

lazy_static! {
pub static ref DEFAULT_NAME: ClarityName = ClarityName::try_from("placeholder").unwrap();
pub static ref DEFAULT_NAME: ClarityName = ClarityName::from("placeholder");
}

pub struct ASTDependencyDetector<'a> {
Expand Down Expand Up @@ -119,7 +118,7 @@ fn deep_check_callee_type(
for key_value in tuple.iter().skip(1) {
if let Some((arg_type, expr)) = key_value
.match_list()
.and_then(|kv| Some((type_map.get(kv.get(0)?.match_atom()?)?, kv.get(1)?)))
.and_then(|kv| Some((type_map.get(kv.first()?.match_atom()?)?, kv.get(1)?)))
{
deep_check_callee_type(arg_type, expr, dependencies);
}
Expand Down
1 change: 1 addition & 0 deletions components/clarity-repl/src/analysis/ast_visitor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(unused_variables)]
#![allow(clippy::get_first)]

use clarity::vm::functions::define::DefineFunctions;
use clarity::vm::functions::NativeFunctions;
Expand Down
2 changes: 1 addition & 1 deletion components/clarity-repl/src/analysis/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl CoverageReporter {
DefineFunctionsParsed::PrivateFunction { signature, body: _ }
| DefineFunctionsParsed::PublicFunction { signature, body: _ }
| DefineFunctionsParsed::ReadOnlyFunction { signature, body: _ } => {
let expr = signature.get(0).expect("Invalid function signature");
let expr = signature.first().expect("Invalid function signature");
let function_name = expr.match_atom().expect("Invalid function signature");

functions.push((
Expand Down
6 changes: 2 additions & 4 deletions components/clarity-repl/src/repl/debug/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::convert::TryFrom;

use crate::repl::debug::extract_watch_variable;
use clarity::vm::contexts::{Environment, LocalContext};
use clarity::vm::errors::Error;
Expand Down Expand Up @@ -279,7 +277,7 @@ impl CLIDebugger {
if contract_parts[0].is_empty() {
QualifiedContractIdentifier::new(
env.contract_context.contract_identifier.issuer.clone(),
ContractName::try_from(contract_parts[1]).unwrap(),
ContractName::from(contract_parts[1]),
)
} else {
match QualifiedContractIdentifier::parse(parts[0]) {
Expand Down Expand Up @@ -345,7 +343,7 @@ impl CLIDebugger {
let contract_id = if parts[0].is_empty() {
QualifiedContractIdentifier::new(
env.contract_context.contract_identifier.issuer.clone(),
ContractName::try_from(parts[1]).unwrap(),
ContractName::from(parts[1]),
)
} else {
match QualifiedContractIdentifier::parse(
Expand Down
8 changes: 2 additions & 6 deletions components/clarity-repl/src/repl/debug/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::{BTreeMap, HashMap, HashSet};
use std::convert::TryFrom;
use std::fmt::Display;

use crate::repl::diagnostic::output_diagnostic;
Expand Down Expand Up @@ -568,14 +567,11 @@ pub fn extract_watch_variable<'a>(
3 => {
let contract_id = if parts[0].is_empty() {
if let Some(sender) = default_sender {
QualifiedContractIdentifier::new(
sender.clone(),
ContractName::try_from(parts[1]).unwrap(),
)
QualifiedContractIdentifier::new(sender.clone(), ContractName::from(parts[1]))
} else {
QualifiedContractIdentifier::new(
env.contract_context.contract_identifier.issuer.clone(),
ContractName::try_from(parts[1]).unwrap(),
ContractName::from(parts[1]),
)
}
} else {
Expand Down

0 comments on commit 2497b4c

Please sign in to comment.