Skip to content

Commit

Permalink
feat: replace solhint with solhint-community (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
dristpunk authored Feb 2, 2024
1 parent 6cb3eb0 commit 85943db
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 679 deletions.
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 @@ interface IGreeter {
*/
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 Down Expand Up @@ -62,14 +72,4 @@ interface IGreeter {
* @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

0 comments on commit 85943db

Please sign in to comment.