Skip to content

Commit

Permalink
refactor: lint using params_first_multi
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Sep 2, 2024
1 parent 80ef65c commit 8c6f035
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bracket_spacing = false
int_types = 'long'
quote_style = 'single'
number_underscore = 'thousands'
multiline_func_header = 'params_first'
multiline_func_header = 'params_first_multi'
sort_imports = true

[profile.default]
Expand Down
4 changes: 1 addition & 3 deletions src/contracts/Greeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ contract Greeter is IGreeter {
}

/// @inheritdoc IGreeter
function setGreeting(
string memory _greeting
) public onlyOwner {
function setGreeting(string memory _greeting) public onlyOwner {
if (keccak256(bytes(_greeting)) == _EMPTY_STRING) {
revert Greeter_InvalidGreeting();
}
Expand Down
4 changes: 1 addition & 3 deletions src/interfaces/IGreeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ interface IGreeter {
* @dev Only callable by the owner
* @param _newGreeting The new greeting to be set
*/
function setGreeting(
string memory _newGreeting
) external;
function setGreeting(string memory _newGreeting) external;

Check warning on line 66 in src/interfaces/IGreeter.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Function order is incorrect, external function can not go after external view function (line 56)

/**
* @notice Greets the caller
Expand Down
12 changes: 3 additions & 9 deletions test/invariants/fuzz/Greeter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ pragma solidity 0.8.23;
import {Greeter, IERC20} from 'contracts/Greeter.sol';

interface IHevm {
function prank(
address
) external;
function prank(address) external;
}

contract InvariantGreeter {
Expand All @@ -18,19 +16,15 @@ contract InvariantGreeter {
_targetContract = new Greeter('a', IERC20(address(1)));
}

function checkGreeterNeverEmpty(
string memory _newGreeting
) public {
function checkGreeterNeverEmpty(string memory _newGreeting) public {
// Execution
(bool _success,) = address(_targetContract).call(abi.encodeCall(Greeter.setGreeting, _newGreeting));

// Check output condition
assert((_success && keccak256(bytes(_targetContract.greeting())) != keccak256(bytes(''))) || !_success);
}

function checkOnlyOwnerSetsGreeting(
address _caller
) public {
function checkOnlyOwnerSetsGreeting(address _caller) public {
// Input conditions
_hevm.prank(_caller);

Expand Down
8 changes: 2 additions & 6 deletions test/invariants/symbolic/Greeter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ contract SymbolicGreeter is SymTest, Test {
targetContract = new Greeter(_initialGreeting, IERC20(_token));
}

function check_validState_greeterNeverEmpty(
address _caller
) public {
function check_validState_greeterNeverEmpty(address _caller) public {
// Input conditions: any caller
vm.prank(_caller);

Expand All @@ -41,9 +39,7 @@ contract SymbolicGreeter is SymTest, Test {
assert(keccak256(bytes(targetContract.greeting())) != keccak256(bytes('')));
}

function check_setGreeting_onlyOwnerSetsGreeting(
address _caller
) public {
function check_setGreeting_onlyOwnerSetsGreeting(address _caller) public {
// Input conditions
string memory _newGreeting = svm.createString(64, 'new greeting');

Expand Down
4 changes: 1 addition & 3 deletions test/unit/Greeter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ contract UnitGreeter is Test {
_greeter.setGreeting('');
}

function test_SetGreetingWhenCalledByANon_owner(
address _caller
) external {
function test_SetGreetingWhenCalledByANon_owner(address _caller) external {
vm.assume(_caller != _owner);
vm.prank(_caller);

Expand Down

0 comments on commit 8c6f035

Please sign in to comment.