Skip to content

Commit 48a866d

Browse files
Merge pull request #692 from protofire/fix-rules-revision
rules revision to promote o demote
2 parents e7c1a17 + cef4e31 commit 48a866d

30 files changed

+124
-40
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
## [6.0.0] - 2025-07-04
2+
3+
### BREAKING CHANGE
4+
Some rules were removed from the recommended ruleset and other were promoted. See below:
5+
6+
#### 🟥 DEMOTED
7+
8+
- `payable-fallback`: Outdated due to the introduction of receive(); rarely needed in modern Solidity.
9+
<br>
10+
11+
#### ✅ PROMOTED
12+
13+
- `interface-starts-with-i`: Promotes clarity by clearly distinguishing interfaces from contracts.
14+
- `gas-calldata-parameters`: Encourages optimal memory usage for external functions.
15+
- `gas-increment-by-one`: Suggests using ++i style for gas-efficient increments.
16+
- `gas-indexed-events`: Improves event indexing for off-chain systems and reduces gas usage.
17+
- `gas-small-strings`: Recommends cheaper encoding using bytes32 for short strings.
18+
- `gas-strict-inequalities`: Helps avoid subtle off-by-one bugs in range conditions.
19+
- `gas-struct-packing`: Maximizes storage efficiency by suggesting tight struct packing.
20+
- `duplicated-imports`: Prevents redundant imports that bloat the AST and confuse code structure.
21+
- `import-path-check`: Ensures all imported files exist and resolve correctly, avoiding runtime errors.
22+
- `function-max-lines`: Encourages smaller, more readable and maintainable functions.
23+
- `constructor-syntax`: Enforces modern constructor syntax for consistency and clarity.
24+
- `use-natspec`: Promotes proper documentation with NatSpec for better audits and readability.
25+
26+
127
## [5.2.0] - 2025-06-27
228
### Fixed
329
- `imports-order` interference with `no-unused-imports` [#684](https://github.com/protofire/solhint/pull/684)

conf/rulesets/solhint-recommended.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,55 @@
66
module.exports = Object.freeze({
77
rules: {
88
'explicit-types': ['warn', 'explicit'],
9+
'function-max-lines': ['warn', 50],
10+
'interface-starts-with-i': 'warn',
911
'max-states-count': ['warn', 15],
1012
'no-console': 'error',
1113
'no-empty-blocks': 'warn',
1214
'no-global-import': 'warn',
1315
'no-unused-import': 'warn',
1416
'no-unused-vars': 'warn',
1517
'one-contract-per-file': 'warn',
16-
'payable-fallback': 'warn',
1718
'reason-string': [
1819
'warn',
1920
{
2021
maxLength: 32,
2122
},
2223
],
24+
'use-natspec': [
25+
'warn',
26+
{
27+
title: {
28+
enabled: true,
29+
ignore: {},
30+
},
31+
author: {
32+
enabled: true,
33+
ignore: {},
34+
},
35+
notice: {
36+
enabled: true,
37+
ignore: {},
38+
},
39+
param: {
40+
enabled: true,
41+
ignore: {},
42+
},
43+
return: {
44+
enabled: true,
45+
ignore: {},
46+
},
47+
},
48+
],
49+
'constructor-syntax': 'warn',
50+
'gas-calldata-parameters': 'warn',
2351
'gas-custom-errors': 'warn',
52+
'gas-increment-by-one': 'warn',
53+
'gas-indexed-events': 'warn',
54+
'gas-small-strings': 'warn',
55+
'gas-strict-inequalities': 'warn',
56+
'gas-struct-packing': 'warn',
57+
'duplicated-imports': 'warn',
2458
'import-path-check': ['warn', ['[~dependenciesPath]']],
2559
quotes: ['error', 'double'],
2660
'const-name-snakecase': 'warn',

docs/rules.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ title: "Rule Index of Solhint"
1010
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | ---------- |
1111
| [code-complexity](./rules/best-practices/code-complexity.md) | Function has cyclomatic complexity "current" but allowed no more than configured max complexity. | | |
1212
| [explicit-types](./rules/best-practices/explicit-types.md) | Forbid or enforce explicit types (like uint256) that have an alias (like uint). | $~~~~~~~~$✔️ | |
13-
| [function-max-lines](./rules/best-practices/function-max-lines.md) | Function body contains "count" lines but allowed no more than maxlines. | | |
13+
| [function-max-lines](./rules/best-practices/function-max-lines.md) | Function body contains "count" lines but allowed no more than maxlines. | $~~~~~~~~$✔️ | |
1414
| [max-line-length](./rules/best-practices/max-line-length.md) | Line length should not exceed configured number of characters. | | |
1515
| [max-states-count](./rules/best-practices/max-states-count.md) | Contract has "some count" states declarations but allowed no more than defined max states. | $~~~~~~~~$✔️ | |
1616
| [no-console](./rules/best-practices/no-console.md) | No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements. | $~~~~~~~~$✔️ | |
@@ -19,18 +19,18 @@ title: "Rule Index of Solhint"
1919
| [no-unused-import](./rules/best-practices/no-unused-import.md) | Imported object name is not being used by the contract. | $~~~~~~~~$✔️ | |
2020
| [no-unused-vars](./rules/best-practices/no-unused-vars.md) | Variable "name" is unused. | $~~~~~~~~$✔️ | |
2121
| [one-contract-per-file](./rules/best-practices/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) | $~~~~~~~~$✔️ | |
22-
| [payable-fallback](./rules/best-practices/payable-fallback.md) | When fallback is not payable and there is no receive function you will not be able to receive currency. | $~~~~~~~~$✔️ | |
22+
| [payable-fallback](./rules/best-practices/payable-fallback.md) | When fallback is not payable and there is no receive function you will not be able to receive currency. | | |
2323
| [reason-string](./rules/best-practices/reason-string.md) | Require or revert statement must have a reason string and check that each reason string is at most N characters long. | $~~~~~~~~$✔️ | |
24-
| [use-natspec](./rules/best-practices/use-natspec.md) | Enforces the presence and correctness of NatSpec tags. | | |
25-
| [constructor-syntax](./rules/best-practices/constructor-syntax.md) | Constructors should use the new constructor keyword. | | |
24+
| [use-natspec](./rules/best-practices/use-natspec.md) | Enforces the presence and correctness of NatSpec tags. | $~~~~~~~~$✔️ | |
25+
| [constructor-syntax](./rules/best-practices/constructor-syntax.md) | Constructors should use the new constructor keyword. | $~~~~~~~~$✔️ | |
2626
2727

2828
## Style Guide Rules
2929

3030
| Rule Id | Error | Recommended | Deprecated |
3131
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------ | ---------- |
32-
| [interface-starts-with-i](./rules/naming/interface-starts-with-i.md) | Solidity Interfaces names should start with an `I` | | |
33-
| [duplicated-imports](./rules/miscellaneous/duplicated-imports.md) | Check if an import is done twice in the same file and there is no alias | | |
32+
| [interface-starts-with-i](./rules/naming/interface-starts-with-i.md) | Solidity Interfaces names should start with an `I` | $~~~~~~~~$✔️ | |
33+
| [duplicated-imports](./rules/miscellaneous/duplicated-imports.md) | Check if an import is done twice in the same file and there is no alias | $~~~~~~~~$✔️ | |
3434
| [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) | $~~~~~~~~$✔️ | |
3535
| [contract-name-capwords](./rules/naming/contract-name-capwords.md) | Contract, Structs and Enums should be in CapWords. | $~~~~~~~~$✔️ | |
3636
| [event-name-capwords](./rules/naming/event-name-capwords.md) | Event name must be in CapWords. | $~~~~~~~~$✔️ | |
@@ -54,16 +54,16 @@ title: "Rule Index of Solhint"
5454

5555
| Rule Id | Error | Recommended | Deprecated |
5656
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------ | ---------- |
57-
| [gas-calldata-parameters](./rules/gas-consumption/gas-calldata-parameters.md) | Suggest calldata keyword on function arguments when read only | | |
57+
| [gas-calldata-parameters](./rules/gas-consumption/gas-calldata-parameters.md) | Suggest calldata keyword on function arguments when read only | $~~~~~~~~$✔️ | |
5858
| [gas-custom-errors](./rules/gas-consumption/gas-custom-errors.md) | Enforces the use of Custom Errors over Require with strings error and Revert statements | $~~~~~~~~$✔️ | |
59-
| [gas-increment-by-one](./rules/gas-consumption/gas-increment-by-one.md) | Suggest increments by one, like this ++i instead of other type | | |
60-
| [gas-indexed-events](./rules/gas-consumption/gas-indexed-events.md) | Suggest indexed arguments on events for uint, bool and address | | |
59+
| [gas-increment-by-one](./rules/gas-consumption/gas-increment-by-one.md) | Suggest increments by one, like this ++i instead of other type | $~~~~~~~~$✔️ | |
60+
| [gas-indexed-events](./rules/gas-consumption/gas-indexed-events.md) | Suggest indexed arguments on events for uint, bool and address | $~~~~~~~~$✔️ | |
6161
| [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 | | |
6262
| [gas-multitoken1155](./rules/gas-consumption/gas-multitoken1155.md) | ERC1155 is a cheaper non-fungible token than ERC721 | | |
6363
| [gas-named-return-values](./rules/gas-consumption/gas-named-return-values.md) | Enforce the return values of a function to be named | | |
64-
| [gas-small-strings](./rules/gas-consumption/gas-small-strings.md) | Keep strings smaller than 32 bytes | | |
65-
| [gas-strict-inequalities](./rules/gas-consumption/gas-strict-inequalities.md) | Suggest Strict Inequalities over non Strict ones | | |
66-
| [gas-struct-packing](./rules/gas-consumption/gas-struct-packing.md) | Suggest to re-arrange struct packing order when it is inefficient | | |
64+
| [gas-small-strings](./rules/gas-consumption/gas-small-strings.md) | Keep strings smaller than 32 bytes. Promote the use of custom errors | $~~~~~~~~$✔️ | |
65+
| [gas-strict-inequalities](./rules/gas-consumption/gas-strict-inequalities.md) | Suggest Strict Inequalities over non Strict ones | $~~~~~~~~$✔️ | |
66+
| [gas-struct-packing](./rules/gas-consumption/gas-struct-packing.md) | Suggest to re-arrange struct packing order when it is inefficient | $~~~~~~~~$✔️ | |
6767
6868

6969
## Miscellaneous

docs/rules/best-practices/constructor-syntax.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ title: "constructor-syntax | Solhint"
55
---
66

77
# constructor-syntax
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
89
![Category Badge](https://img.shields.io/badge/-Best%20Practices%20Rules-informational)
910
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
1013

1114
## Description
1215
Constructors should use the new constructor keyword.

docs/rules/best-practices/function-max-lines.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ title: "function-max-lines | Solhint"
55
---
66

77
# function-max-lines
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
89
![Category Badge](https://img.shields.io/badge/-Best%20Practices%20Rules-informational)
910
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
1013

1114
## Description
1215
Function body contains "count" lines but allowed no more than maxlines.

docs/rules/best-practices/payable-fallback.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ title: "payable-fallback | Solhint"
55
---
66

77
# payable-fallback
8-
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
98
![Category Badge](https://img.shields.io/badge/-Best%20Practices%20Rules-informational)
109
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11-
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12-
1310

1411
## Description
1512
When fallback is not payable and there is no receive function you will not be able to receive currency.

docs/rules/best-practices/use-natspec.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ title: "use-natspec | Solhint"
55
---
66

77
# use-natspec
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
89
![Category Badge](https://img.shields.io/badge/-Best%20Practices%20Rules-informational)
910
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
1013

1114
## Description
1215
Enforces the presence and correctness of NatSpec tags.

docs/rules/gas-consumption/gas-calldata-parameters.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ title: "gas-calldata-parameters | Solhint"
55
---
66

77
# gas-calldata-parameters
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
89
![Category Badge](https://img.shields.io/badge/-Gas%20Consumption%20Rules-informational)
910
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
1013

1114
## Description
1215
Suggest calldata keyword on function arguments when read only

docs/rules/gas-consumption/gas-increment-by-one.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ title: "gas-increment-by-one | Solhint"
55
---
66

77
# gas-increment-by-one
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
89
![Category Badge](https://img.shields.io/badge/-Gas%20Consumption%20Rules-informational)
910
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
1013

1114
## Description
1215
Suggest increments by one, like this ++i instead of other type

docs/rules/gas-consumption/gas-indexed-events.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ title: "gas-indexed-events | Solhint"
55
---
66

77
# gas-indexed-events
8+
![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen)
89
![Category Badge](https://img.shields.io/badge/-Gas%20Consumption%20Rules-informational)
910
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)
11+
> The {"extends": "solhint:recommended"} property in a configuration file enables this rule.
12+
1013

1114
## Description
1215
Suggest indexed arguments on events for uint, bool and address

0 commit comments

Comments
 (0)