Skip to content

Commit

Permalink
Fix clippy nits
Browse files Browse the repository at this point in the history
  • Loading branch information
garyghayrat committed Jun 19, 2024
1 parent 4db45d5 commit 3e03cbe
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# ScopeLint
# `ScopeLint`

A simple and opinionated tool designed for basic formatting/linting of Solidity and TOML code in foundry projects.

- [Installation](#installation)
- [Usage](#usage)
- [`scopelint fmt`](#scopelint-fmt)
- [`scopelint check`](#scopelint-check)
- [`scopelint spec`](#scopelint-spec)

- [`ScopeLint`](#scopelint)
- [Installation](#installation)
- [Usage](#usage)
- [`scopelint fmt`](#scopelint-fmt)
- [`scopelint check`](#scopelint-check)
- [`scopelint spec`](#scopelint-spec)

## Installation

Expand Down
2 changes: 1 addition & 1 deletion src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub fn parse(file: &Path) -> Result<Parsed, Box<dyn Error>> {
let src = &fs::read_to_string(file)?;

let (pt, comments) = solang_parser::parse(src, 0).map_err(|d| {
eprintln!("{:?}", d);
eprintln!("{d:?}");
"Failed to parse file".to_string()
})?;

Expand Down
8 changes: 4 additions & 4 deletions src/check/validators/constant_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod tests {

#[test]
fn test_validate() {
let content = r#"
let content = r"
contract MyContract {
// These have the constant or immutable keyword and should be valid.
uint256 constant MAX_UINT256 = type(uint256).max;
Expand All @@ -90,7 +90,7 @@ mod tests {
address alice = address(123);
uint256 aliceBalance = 500;
}
"#;
";

let expected_findings = ExpectedFindings::new(2);
expected_findings.assert_eq(content, &validate);
Expand Down Expand Up @@ -135,11 +135,11 @@ mod tests {
];

for name in allowed_names {
assert_eq!(is_valid_constant_name(name), true, "{name}");
assert!(is_valid_constant_name(name), "{name}");
}

for name in disallowed_names {
assert_eq!(is_valid_constant_name(name), false, "{name}");
assert!(!is_valid_constant_name(name), "{name}");
}
}
}
4 changes: 2 additions & 2 deletions src/check/validators/src_names_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod tests {

#[test]
fn test_validate() {
let content = r#"
let content = r"
contract MyContract {
// Valid names for internal or private src methods.
function _myInternalMethod() internal {}
Expand All @@ -76,7 +76,7 @@ mod tests {
function myPublicMethod() public {}
function myExternalMethod() external {}
}
"#;
";

let expected_findings = ExpectedFindings { src: 2, ..ExpectedFindings::default() };
expected_findings.assert_eq(content, &validate);
Expand Down
8 changes: 4 additions & 4 deletions src/check/validators/test_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mod tests {

#[test]
fn test_validate() {
let content = r#"
let content = r"
contract MyContract {
// Good test names.
function test_Description() public {}
Expand All @@ -117,7 +117,7 @@ mod tests {
function _testDescription() public {}
function _testDescriptionMoreInfo() public {}
}
"#;
";

let expected_findings = ExpectedFindings { test: 3, ..ExpectedFindings::default() };
expected_findings.assert_eq(content, &validate);
Expand Down Expand Up @@ -172,11 +172,11 @@ mod tests {
];

for name in allowed_names {
assert_eq!(is_valid_test_name(name), true, "{name}");
assert!(is_valid_test_name(name), "{name}");
}

for name in disallowed_names {
assert_eq!(is_valid_test_name(name), false, "{name}");
assert!(!is_valid_test_name(name), "{name}");
}
}
}
3 changes: 1 addition & 2 deletions src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ fn trimmed_fn_name_to_requirement(trimmed_fn_name: &str) -> String {
trimmed_fn_name
.replace('_', ":")
.chars()
.enumerate()
.map(|(_i, c)| if c.is_uppercase() { format!(" {c}") } else { c.to_string() })
.map(|c| if c.is_uppercase() { format!(" {c}") } else { c.to_string() })
.collect::<String>()
}

0 comments on commit 3e03cbe

Please sign in to comment.