Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace solhint with solhint-community #59

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
{
"extends": "solhint:recommended",
"plugins": ["defi-wonderland"],
"rules": {
"compiler-version": ["off"],
"constructor-syntax": "warn",
"quotes": ["error", "single"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"not-rely-on-time": "off",
"func-name-mixedcase": "off",
"var-name-mixedcase": "off",
"const-name-snakecase": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"private-vars-leading-underscore": ["warn", { "strict": false }],
"defi-wonderland/non-state-vars-leading-underscore": ["warn"],
"defi-wonderland/contract-data-order": ["warn"],
"defi-wonderland/enum-name-camelcase": ["warn"],
"defi-wonderland/immutable-name-snakecase": ["warn"],
"defi-wonderland/import-statement-format": ["warn"],
"defi-wonderland/interface-member-order": ["warn"],
"defi-wonderland/interface-starts-with-i": ["warn"],
"defi-wonderland/named-return-values": ["warn"],
"defi-wonderland/struct-name-camelcase": ["warn"],
"defi-wonderland/wonder-var-name-mixedcase": ["warn"],
"ordering": "warn",
"immutable-name-snakecase": "warn",
"avoid-low-level-calls": "off",
"no-console": "off"
}
Expand Down
23 changes: 23 additions & 0 deletions .solhint.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "solhint:recommended",
"rules": {
"compiler-version": ["off"],
"constructor-syntax": "warn",
"quotes": ["error", "single"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"not-rely-on-time": "off",
"func-name-mixedcase": "off",
"var-name-mixedcase": "off",
"const-name-snakecase": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "off",
"definition-name-capwords": "off",
"named-parameters-function": "off",
"no-global-import": "off",
"max-states-count": "off",
"private-vars-leading-underscore": ["warn", { "strict": false }],
"ordering": "warn",
"immutable-name-snakecase": "warn",
"avoid-low-level-calls": "off"
}
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix",
"lint:sol-logic": "solhint -c .solhint.json 'solidity/contracts/**/*.sol' 'solidity/interfaces/**/*.sol'",
"lint:sol-tests": "solhint 'solidity/test/**/*.sol'",
"lint:sol-tests": "solhint -c .solhint.tests.json 'solidity/test/**/*.sol'",
"prepare": "husky install",
"test": "forge test -vvv",
"test:integration": "forge test --match-contract Integration -vvv",
Expand All @@ -42,8 +42,7 @@
"forge-std": "github:foundry-rs/forge-std#v1.7.3",
"husky": ">=8",
"lint-staged": ">=10",
"solhint": "3.6.2",
"solhint-plugin-defi-wonderland": "1.1.0",
"solhint": "github:solhint-community/solhint-community#v4.0.0-rc01",
"sort-package-json": "1.53.1"
}
}
32 changes: 16 additions & 16 deletions solidity/contracts/Greeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ contract Greeter is IGreeter {
/// @inheritdoc IGreeter
IERC20 public token;

/**
* @notice Reverts in case the function was not called by the owner of the contract
*/
modifier onlyOwner() {
if (msg.sender != OWNER) {
revert Greeter_OnlyOwner();
}
_;
}

/**
* @notice Defines the owner to the msg.sender and sets the initial greeting
* @param _greeting Initial greeting
Expand All @@ -31,6 +41,12 @@ contract Greeter is IGreeter {
setGreeting(_greeting);
}

/// @inheritdoc IGreeter
function greet() external view returns (string memory _greeting, uint256 _balance) {
_greeting = greeting;
_balance = token.balanceOf(msg.sender);
}

/// @inheritdoc IGreeter
function setGreeting(string memory _greeting) public onlyOwner {
if (keccak256(bytes(_greeting)) == _EMPTY_STRING) {
Expand All @@ -40,20 +56,4 @@ contract Greeter is IGreeter {
greeting = _greeting;
emit GreetingSet(_greeting);
}

/// @inheritdoc IGreeter
function greet() external view returns (string memory _greeting, uint256 _balance) {
_greeting = greeting;
_balance = token.balanceOf(msg.sender);
}

/**
* @notice Reverts in case the function was not called by the owner of the contract
*/
modifier onlyOwner() {
if (msg.sender != OWNER) {
revert Greeter_OnlyOwner();
}
_;
}
}
20 changes: 10 additions & 10 deletions solidity/interfaces/IGreeter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
*/
error Greeter_InvalidGreeting();

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/
/**
* @notice Sets a new greeting
* @dev Only callable by the owner
* @param _newGreeting The new greeting to be set
*/
function setGreeting(string memory _newGreeting) external;

/*///////////////////////////////////////////////////////////////
VARIABLES
//////////////////////////////////////////////////////////////*/
Expand All @@ -41,7 +51,7 @@
* @dev The owner will always be the deployer of the contract
* @return _owner The owner of the contract
*/
function OWNER() external view returns (address _owner);

Check warning on line 54 in solidity/interfaces/IGreeter.sol

View workflow job for this annotation

GitHub Actions / Lint Commit Messages

Function name must be in mixedCase

/**
* @notice Returns the previously set greeting
Expand All @@ -62,14 +72,4 @@
* @return _balance Current token balance of the caller
*/
function greet() external view returns (string memory _greeting, uint256 _balance);

/*///////////////////////////////////////////////////////////////
LOGIC
//////////////////////////////////////////////////////////////*/
/**
* @notice Sets a new greeting
* @dev Only callable by the owner
* @param _newGreeting The new greeting to be set
*/
function setGreeting(string memory _newGreeting) external;
}
Loading
Loading