Skip to content

Commit 39802b4

Browse files
committed
Lint
1 parent 42e7847 commit 39802b4

File tree

12 files changed

+29
-54
lines changed

12 files changed

+29
-54
lines changed

crates/cheatnet/src/runtime_extensions/forge_runtime_extension/file_operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(super) fn read_json(path: String) -> Result<Vec<Felt>, EnhancedHintError> {
2626
let content = read_to_string(&path)?;
2727

2828
let json: Map<String, Value> = serde_json::from_str(&content)
29-
.map_err(|e| anyhow!("Parse JSON error: {} , in file {path}", e.to_string()))?;
29+
.map_err(|e| anyhow!("Parse JSON error: {e} , in file {path}"))?;
3030
let data = flatten(&json);
3131

3232
let mut result = vec![];

crates/configuration/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn get_profile(
4949
match get_with_ownership(tool_config, profile_name) {
5050
Some(profile_value) => Ok(profile_value),
5151
None if profile_name == "default" => Ok(serde_json::Value::Object(Map::default())),
52-
None => Err(anyhow!("Profile [{}] not found in config", profile_name)),
52+
None => Err(anyhow!("Profile [{profile_name}] not found in config")),
5353
}
5454
}
5555

crates/data-transformer/src/transformer/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ fn process(
5555

5656
ensure!(
5757
n_inputs == n_arguments,
58-
"Invalid number of arguments: passed {}, expected {}",
59-
n_arguments,
60-
n_inputs,
58+
"Invalid number of arguments: passed {n_arguments}, expected {n_inputs}",
6159
);
6260

6361
function

crates/data-transformer/src/transformer/sierra_abi/complex_types.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ fn validate_path_argument(
4949
if *path_argument.last().unwrap() != param_type.split("::").last().unwrap()
5050
&& path_argument_joined != param_type
5151
{
52-
bail!(
53-
r#"Invalid argument type, expected "{}", got "{}""#,
54-
param_type,
55-
path_argument_joined
56-
)
52+
bail!(r#"Invalid argument type, expected "{param_type}", got "{path_argument_joined}""#,)
5753
}
5854
Ok(())
5955
}
@@ -236,8 +232,7 @@ impl SupportedCalldataKind for ExprStructCtorCall {
236232
{
237233
// TODO add message which arguments are invalid (Issue #2549)
238234
bail!(
239-
r"Arguments in constructor invocation for struct {} do not match struct arguments in ABI",
240-
expected_type
235+
r"Arguments in constructor invocation for struct {expected_type} do not match struct arguments in ABI",
241236
)
242237
}
243238

@@ -281,11 +276,7 @@ impl SupportedCalldataKind for ExprPath {
281276
find_enum_variant_position(enum_variant_name, enum_path, abi)?;
282277

283278
if enum_variant.r#type != "()" {
284-
bail!(
285-
r#"Couldn't find variant "{}" in enum "{}""#,
286-
enum_variant_name,
287-
enum_path_joined
288-
)
279+
bail!(r#"Couldn't find variant "{enum_variant_name}" in enum "{enum_path_joined}""#,)
289280
}
290281

291282
Ok(AllowedCalldataArgument::Enum(CalldataEnum::new(
@@ -337,10 +328,7 @@ impl SupportedCalldataKind for ExprListParenthesized {
337328
db: &SimpleParserDatabase,
338329
) -> Result<AllowedCalldataArgument> {
339330
let Expr::Tuple(tuple) = parse_expression(expected_type, db)? else {
340-
bail!(
341-
r#"Invalid argument type, expected "{}", got tuple"#,
342-
expected_type
343-
);
331+
bail!(r#"Invalid argument type, expected "{expected_type}", got tuple"#,);
344332
};
345333

346334
let tuple_types = tuple

crates/data-transformer/src/transformer/sierra_abi/literals.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,18 @@ impl SupportedCalldataKind for ExprUnary {
5252
};
5353

5454
match self.op(db) {
55-
UnaryOperator::Not(_) => bail!(
56-
"Invalid unary operator in expression !{} , only - allowed, got !",
57-
value
58-
),
59-
UnaryOperator::Desnap(_) => bail!(
60-
"Invalid unary operator in expression *{} , only - allowed, got *",
61-
value
62-
),
63-
UnaryOperator::BitNot(_) => bail!(
64-
"Invalid unary operator in expression ~{} , only - allowed, got ~",
65-
value
66-
),
67-
UnaryOperator::At(_) => bail!(
68-
"Invalid unary operator in expression @{} , only - allowed, got @",
69-
value
70-
),
55+
UnaryOperator::Not(_) => {
56+
bail!("Invalid unary operator in expression !{value} , only - allowed, got !",)
57+
}
58+
UnaryOperator::Desnap(_) => {
59+
bail!("Invalid unary operator in expression *{value} , only - allowed, got *",)
60+
}
61+
UnaryOperator::BitNot(_) => {
62+
bail!("Invalid unary operator in expression ~{value} , only - allowed, got ~",)
63+
}
64+
UnaryOperator::At(_) => {
65+
bail!("Invalid unary operator in expression @{value} , only - allowed, got @",)
66+
}
7167
UnaryOperator::Minus(_) => {}
7268
}
7369

crates/data-transformer/src/transformer/sierra_abi/macros.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ impl SupportedCalldataKind for ExprInlineMacro {
2323

2424
// We do not expect any other expression in proper ABI
2525
let Expr::Path(path) = parse_expression(expected_type, db)? else {
26-
bail!(
27-
"Unexpected expression encountered in ABI: {}. ABI may be invalid",
28-
expected_type
29-
);
26+
bail!("Unexpected expression encountered in ABI: {expected_type}. ABI may be invalid",);
3027
};
3128

3229
let type_parameters_from_abi = path
@@ -68,7 +65,7 @@ impl SupportedCalldataKind for ExprInlineMacro {
6865

6966
// Check by string; A proper array type in ABI looks exactly like this
7067
if !expected_type.contains("core::array::Array") {
71-
bail!(r#"Expected "{}", got array"#, expected_type);
68+
bail!(r#"Expected "{expected_type}", got array"#);
7269
}
7370

7471
// Array should have exactly one type parameter. ABI is invalid otherwise

crates/data-transformer/src/transformer/sierra_abi/parsing.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ pub fn parse_inline_macro(
6868
Simple(simple) => {
6969
let macro_name = simple.ident(db).text(db);
7070
if macro_name != "array" {
71-
bail!(
72-
r#"Invalid macro name, expected "array![]", got "{}""#,
73-
macro_name
74-
)
71+
bail!(r#"Invalid macro name, expected "array![]", got "{macro_name}""#,)
7572
}
7673
}
7774
PathSegment::WithGenericArgs(_) => {

crates/docs/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ pub fn print_ignored_snippet_message(snippet: &Snippet) {
5353

5454
fn get_canonical_path(relative_path: &str) -> Result<String> {
5555
Ok(Utf8PathBuf::from_str(relative_path)
56-
.map_err(|e| anyhow!("Failed to create Utf8PathBuf: {}", e))?
56+
.map_err(|e| anyhow!("Failed to create Utf8PathBuf: {e}"))?
5757
.canonicalize_utf8()
58-
.map_err(|e| anyhow!("Failed to canonicalize path: {}", e))?
58+
.map_err(|e| anyhow!("Failed to canonicalize path: {e}"))?
5959
.to_string())
6060
}
6161

crates/sncast/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,8 @@ pub fn raise_if_empty(value: &str, value_name: &str) -> Result<()> {
682682

683683
pub fn check_account_file_exists(accounts_file_path: &Utf8PathBuf) -> Result<()> {
684684
if !accounts_file_path.exists() {
685-
bail! {"Accounts file = {} does not exist! If you do not have an account create one with `account create` command \
686-
or if you're using a custom accounts file, make sure to supply correct path to it with `--accounts-file` argument.", accounts_file_path}
685+
bail! {"Accounts file = {accounts_file_path} does not exist! If you do not have an account create one with `account create` command \
686+
or if you're using a custom accounts file, make sure to supply correct path to it with `--accounts-file` argument." }
687687
}
688688
Ok(())
689689
}

crates/sncast/src/starknet_commands/account/deploy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ where
322322
match result {
323323
Err(AccountFactoryError::Provider(error)) => match error {
324324
StarknetError(ClassHashNotFound) => Err(anyhow!(
325-
"Provided class hash {:#x} does not exist",
326-
class_hash,
325+
"Provided class hash {class_hash:#x} does not exist",
327326
)),
328327
_ => Err(handle_rpc_error(error)),
329328
},

0 commit comments

Comments
 (0)