You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`named-return-values` rule was renamed to gas-named-return-values and now it is part of Gas Consumption ruleset [#552](https://github.com/protofire/solhint/pull/552)
38
+
-`custom-errors` rule was renamed to gas-custom-errors and now it is part of Gas Consumption ruleset [#553](https://github.com/protofire/solhint/pull/553)
39
+
- Return error 0 when executed correctly [#554](https://github.com/protofire/solhint/pull/554)
40
+
- Default severity modified to `WARN` instead of `OFF` for
41
+
`foundry-test-functions` and `named-parameters-mapping` rules [#556](https://github.com/protofire/solhint/pull/556)
|[code-complexity](./rules/best-practises/code-complexity.md)| Function has cyclomatic complexity "current" but allowed no more than maxcompl. |||
12
-
|[custom-errors](./rules/best-practises/custom-errors.md)| Enforces the use of Custom Errors over Require and Revert statements | $~~~~~~~~$✔️ ||
13
12
|[explicit-types](./rules/best-practises/explicit-types.md)| Forbid or enforce explicit types (like uint256) that have an alias (like uint). | $~~~~~~~~$✔️ ||
14
13
|[function-max-lines](./rules/best-practises/function-max-lines.md)| Function body contains "count" lines but allowed no more than maxlines. |||
15
14
|[max-line-length](./rules/best-practises/max-line-length.md)| Line length must be no more than maxlen. |||
@@ -20,23 +19,16 @@ title: "Rule Index of Solhint"
20
19
|[no-unused-import](./rules/best-practises/no-unused-import.md)| Imported object name is not being used by the contract. | $~~~~~~~~$✔️ ||
21
20
|[no-unused-vars](./rules/best-practises/no-unused-vars.md)| Variable "name" is unused. | $~~~~~~~~$✔️ ||
22
21
|[one-contract-per-file](./rules/best-practises/one-contract-per-file.md)| Enforces the use of ONE Contract per file see [here](https://docs.soliditylang.org/en/v0.8.21/style-guide.html#contract-and-library-names)| $~~~~~~~~$✔️ ||
23
-
|[payable-fallback](./rules/best-practises/payable-fallback.md)| When fallback is not payable you will not be able to receive ethers. | $~~~~~~~~$✔️ ||
22
+
|[payable-fallback](./rules/best-practises/payable-fallback.md)| When fallback is not payable and there is no receive function you will not be able to receive currency.| $~~~~~~~~$✔️ ||
24
23
|[reason-string](./rules/best-practises/reason-string.md)| Require or revert statement must have a reason string and check that each reason string is at most N characters long. | $~~~~~~~~$✔️ ||
25
24
|[constructor-syntax](./rules/best-practises/constructor-syntax.md)| Constructors should use the new constructor keyword. |||
|[comprehensive-interface](./rules/miscellaneous/comprehensive-interface.md)| Check that all public or external functions are override. This is iseful to make sure that the whole API is extracted in an interface. |||
33
-
|[quotes](./rules/miscellaneous/quotes.md)| Enforces the use of double or simple quotes as configured for string literals. Values must be 'single' or 'double'. | $~~~~~~~~$✔️ ||
|[interface-starts-with-i](./rules/naming/interface-starts-with-i.md)| Solidity Interfaces names should start with an `I`|||
40
32
|[const-name-snakecase](./rules/naming/const-name-snakecase.md)| Constant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming) | $~~~~~~~~$✔️ ||
41
33
|[contract-name-camelcase](./rules/naming/contract-name-camelcase.md)| Contract, Structs and Enums should be in CamelCase. | $~~~~~~~~$✔️ ||
42
34
|[event-name-camelcase](./rules/naming/event-name-camelcase.md)| Event name must be in CamelCase. | $~~~~~~~~$✔️ ||
@@ -47,7 +39,6 @@ title: "Rule Index of Solhint"
47
39
|[immutable-vars-naming](./rules/naming/immutable-vars-naming.md)| Check Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configuration. | $~~~~~~~~$✔️ ||
48
40
|[modifier-name-mixedcase](./rules/naming/modifier-name-mixedcase.md)| Modifier name must be in mixedCase. |||
49
41
|[named-parameters-mapping](./rules/naming/named-parameters-mapping.md)| Solidity v0.8.18 introduced named parameters on the mappings definition. |||
50
-
|[named-return-values](./rules/naming/named-return-values.md)| Enforce the return values of a function to be named |||
51
42
|[private-vars-leading-underscore](./rules/naming/private-vars-leading-underscore.md)| Non-external functions and state variables should start with a single underscore. Others, shouldn't |||
52
43
|[use-forbidden-name](./rules/naming/use-forbidden-name.md)| Avoid to use letters 'I', 'l', 'O' as identifiers. | $~~~~~~~~$✔️ ||
53
44
|[var-name-mixedcase](./rules/naming/var-name-mixedcase.md)| Variable name must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming) | $~~~~~~~~$✔️ ||
@@ -57,6 +48,30 @@ title: "Rule Index of Solhint"
57
48
|[visibility-modifier-order](./rules/order/visibility-modifier-order.md)| Visibility modifier must be first in list of modifiers. | $~~~~~~~~$✔️ ||
|[gas-calldata-parameters](./rules/gas-consumption/gas-calldata-parameters.md)| Suggest calldata keyword on function arguments when read only |||
56
+
|[gas-custom-errors](./rules/gas-consumption/gas-custom-errors.md)| Enforces the use of Custom Errors over Require and Revert statements | $~~~~~~~~$✔️ ||
57
+
|[gas-increment-by-one](./rules/gas-consumption/gas-increment-by-one.md)| Suggest incrementation by one like this ++i instead of other type |||
58
+
|[gas-indexed-events](./rules/gas-consumption/gas-indexed-events.md)| Suggest indexed arguments on events for uint, bool and address |||
59
+
|[gas-length-in-loops](./rules/gas-consumption/gas-length-in-loops.md)| Suggest replacing object.length in a loop condition to avoid calculation on each lap |||
60
+
|[gas-multitoken1155](./rules/gas-consumption/gas-multitoken1155.md)| ERC1155 is a cheaper non-fungible token than ERC721 |||
61
+
|[gas-named-return-values](./rules/gas-consumption/gas-named-return-values.md)| Enforce the return values of a function to be named |||
62
+
|[gas-small-strings](./rules/gas-consumption/gas-small-strings.md)| Keep strings smaller than 32 bytes |||
63
+
|[gas-strict-inequalities](./rules/gas-consumption/gas-strict-inequalities.md)| Suggest Strict Inequalities over non Strict ones |||
64
+
|[gas-struct-packing](./rules/gas-consumption/gas-struct-packing.md)| Suggest to re-arrange struct packing order when it is inefficient |||
|[comprehensive-interface](./rules/miscellaneous/comprehensive-interface.md)| Check that all public or external functions are override. This is iseful to make sure that the whole API is extracted in an interface. |||
72
+
|[quotes](./rules/miscellaneous/quotes.md)| Enforces the use of double or simple quotes as configured for string literals. Values must be 'single' or 'double'. | $~~~~~~~~$✔️ ||
When fallback is not payable you will not be able to receive ethers.
15
+
When fallback is not payable and there is no receive function you will not be able to receive currency.
16
16
17
17
## Options
18
18
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.
@@ -28,36 +28,35 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
28
28
29
29
### Notes
30
30
- Solhint allows this rule to automatically fix the code with `--fix` option
31
+
- Instead of having a fallback function to receive native currency it is recommended to code a receive() function [[here]](https://docs.soliditylang.org/en/v0.8.24/contracts.html#fallback-function)
31
32
32
33
## Examples
33
34
### 👍 Examples of **correct** code for this rule
34
35
35
36
#### Fallback is payable
36
37
37
38
```solidity
39
+
function() public payable {}
40
+
```
41
+
42
+
#### Fallback is payable
38
43
39
-
pragma solidity 0.4.4;
40
-
41
-
42
-
contract A {
43
-
function () public payable {}
44
-
}
45
-
44
+
```solidity
45
+
fallback() external payable {}
46
46
```
47
47
48
48
### 👎 Examples of **incorrect** code for this rule
Suggest calldata keyword on function arguments when read only
13
+
14
+
## Options
15
+
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn.
16
+
17
+
### Example Config
18
+
```json
19
+
{
20
+
"rules": {
21
+
"gas-calldata-parameters": "warn"
22
+
}
23
+
}
24
+
```
25
+
26
+
### Notes
27
+
- Only applies for external functions when receiving arguments with [memory] keyword
28
+
- This rule makes a soft check to see if argument is readOnly to make the suggestion. Check it manually before changing it.
29
+
-[source 1](https://coinsbench.com/comprehensive-guide-tips-and-tricks-for-gas-optimization-in-solidity-5380db734404) of the rule initiative (see Calldata vs Memory)
30
+
-[source 2](https://www.rareskills.io/post/gas-optimization?postId=c9db474a-ff97-4fa3-a51d-fe13ccb8fe3b#viewer-6acr7) of the rule initiative
0 commit comments