Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
fix(solidity/linter/core): now run foundry naming rule on public and …
Browse files Browse the repository at this point in the history
…external functions only
  • Loading branch information
0xmemorygrinder committed Oct 9, 2023
1 parent dc71afd commit 8742a7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ impl RuleType for FoundryFuncName {

for contract in contracts {
for function in ast_extractor::retriever::retrieve_functions_nodes(&contract) {
let visibility = function.attributes.iter().find(|attr| matches!(attr, ast_extractor::FunctionAttribute::Visibility(_)));
let visibility = match visibility {
Some(ast_extractor::FunctionAttribute::Visibility(visibility)) => visibility,
_ => continue,
};

if !matches!(visibility, ast_extractor::Visibility::Public(_)) && !matches!(visibility, ast_extractor::Visibility::External(_)) {
continue;
}
if let Some(name) = function.name {
if !re.is_match(&name.as_string()) && !self.excluded.contains(&name.as_string()) {
let span = name.span();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ contract Test {
function testFuzz_FuzzyTest() public {} // should pass

function numberIs42() public {} // should fail

function YoloNamingBecauseSkipped() internal {} // should pass
}

0 comments on commit 8742a7c

Please sign in to comment.