Skip to content

Commit

Permalink
Merge pull request #628 from protofire/develop
Browse files Browse the repository at this point in the history
Merge Develop to Master v5.0.5
  • Loading branch information
dbale-altoros authored Jan 16, 2025
2 parents 0c05a45 + bea42ef commit 0a34c4d
Show file tree
Hide file tree
Showing 70 changed files with 822 additions and 89 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [5.0.5] - 2025-01-16
### Fixed
- `gas-custom-errors` [#620](https://github.com/protofire/solhint/pull/620) - Support for Custom Errors inside `require` statements
- `compiler-version` [#621](https://github.com/protofire/solhint/pull/621) - Upgraded minimum requirement for the rule
- `reentrancy` [#622](https://github.com/protofire/solhint/pull/622) - Fixed path and typos
- Typos [#623](https://github.com/protofire/solhint/pull/623) - Fixed typos
- Typo [#625](https://github.com/protofire/solhint/pull/625) - Fixed typo


### Added
- New Rule: Duplicated Imports [#626](https://github.com/protofire/solhint/pull/626)
- Cute Message on console report to gather community into discord channel

<br><br>


## [5.0.4] - 2024-12-31
### Fixed
- `imports-order` [#595](https://github.com/protofire/solhint/pull/595) - Replaced single quotes with double quotes
Expand Down
5 changes: 3 additions & 2 deletions conf/rulesets/solhint-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = Object.freeze({
'gas-strict-inequalities': 'warn',
'gas-struct-packing': 'warn',
'comprehensive-interface': 'warn',
'duplicated-imports': 'warn',
quotes: ['error', 'double'],
'const-name-snakecase': 'warn',
'contract-name-capwords': 'warn',
Expand All @@ -50,7 +51,6 @@ module.exports = Object.freeze({
immutablesAsConstants: true,
},
],
'imports-order': 'warn',
'modifier-name-mixedcase': 'warn',
'named-parameters-mapping': 'warn',
'private-vars-leading-underscore': [
Expand All @@ -62,6 +62,7 @@ module.exports = Object.freeze({
'use-forbidden-name': 'warn',
'var-name-mixedcase': 'warn',
'imports-on-top': 'warn',
'imports-order': 'warn',
ordering: 'warn',
'visibility-modifier-order': 'warn',
'avoid-call-value': 'warn',
Expand All @@ -71,7 +72,7 @@ module.exports = Object.freeze({
'avoid-throw': 'warn',
'avoid-tx-origin': 'warn',
'check-send-result': 'warn',
'compiler-version': ['error', '^0.8.0'],
'compiler-version': ['error', '^0.8.24'],
'func-visibility': [
'warn',
{
Expand Down
2 changes: 1 addition & 1 deletion conf/rulesets/solhint-recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = Object.freeze({
'avoid-throw': 'warn',
'avoid-tx-origin': 'warn',
'check-send-result': 'warn',
'compiler-version': ['error', '^0.8.0'],
'compiler-version': ['error', '^0.8.24'],
'func-visibility': [
'warn',
{
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM node:20-alpine
LABEL maintainer="[email protected]"
ENV VERSION=5.0.4
ENV VERSION=5.0.5

RUN npm install -g solhint@"$VERSION"
3 changes: 2 additions & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ title: "Rule Index of Solhint"
| Rule Id | Error | Recommended | Deprecated |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------ | ----------- |
| [interface-starts-with-i](./rules/naming/interface-starts-with-i.md) | Solidity Interfaces names should start with an `I` | | |
| [duplicated-imports](./rules/miscellaneous/duplicated-imports.md) | Check if an import is done twice in the same file and there is no alias | | |
| [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) | $~~~~~~~~$✔️ | |
| [contract-name-capwords](./rules/naming/contract-name-capwords.md) | Contract, Structs and Enums should be in CapWords. | $~~~~~~~~$✔️ | |
| [event-name-capwords](./rules/naming/event-name-capwords.md) | Event name must be in CapWords. | $~~~~~~~~$✔️ | |
Expand All @@ -36,14 +37,14 @@ title: "Rule Index of Solhint"
| [func-named-parameters](./rules/naming/func-named-parameters.md) | Enforce named parameters for function calls with 4 or more arguments. This rule may have some false positives | | |
| [func-param-name-mixedcase](./rules/naming/func-param-name-mixedcase.md) | Function param name must be in mixedCase. | | |
| [immutable-vars-naming](./rules/naming/immutable-vars-naming.md) | Check Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configuration. | $~~~~~~~~$✔️ | |
| [imports-order](./rules/naming/imports-order.md) | Order the imports of the contract to follow a certain hierarchy (read "Notes section") | | |
| [modifier-name-mixedcase](./rules/naming/modifier-name-mixedcase.md) | Modifier name must be in mixedCase. | | |
| [named-parameters-mapping](./rules/naming/named-parameters-mapping.md) | Solidity v0.8.18 introduced named parameters on the mappings definition. | | |
| [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 | | |
| [use-forbidden-name](./rules/naming/use-forbidden-name.md) | Avoid to use letters 'I', 'l', 'O' as identifiers. | $~~~~~~~~$✔️ | |
| [var-name-mixedcase](./rules/naming/var-name-mixedcase.md) | Variable names must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming) | $~~~~~~~~$✔️ | |
| [func-order](./rules/order/func-order.md) | Function order is incorrect. | | $~~~~~~~$✔️ |
| [imports-on-top](./rules/order/imports-on-top.md) | Import statements must be on top. | $~~~~~~~~$✔️ | |
| [imports-order](./rules/naming/imports-order.md) | Order the imports of the contract to follow a certain hierarchy (read "Notes section") | | |
| [ordering](./rules/order/ordering.md) | Check order of elements in file and inside each contract, according to the style guide. | | |
| [visibility-modifier-order](./rules/order/visibility-modifier-order.md) | Visibility modifier must be first in list of modifiers. | $~~~~~~~~$✔️ | |
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/code-complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ while (d > e) { }
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/code-complexity.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/explicit-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ uint public variableName = uint256(5)
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/explicit-types.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/function-max-lines.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This rule accepts an array of options:
This rule does not have examples.

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/function-max-lines.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/max-line-length.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This rule accepts an array of options:
This rule does not have examples.

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/max-line-length.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/max-states-count.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ This rule accepts an array of options:
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/max-states-count.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/no-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import "forge-std/consoleN.sol"
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-console.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/no-empty-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ constructor () { }
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-empty-blocks.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/no-global-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import "foo.sol"
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-global-import.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/no-unused-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-unused-import.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/no-unused-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
This rule does not have examples.

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-unused-vars.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/one-contract-per-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
This rule does not have examples.

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/one-contract-per-file.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/payable-fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fallback() {} function g() payable {}
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/payable-fallback.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/best-practices/reason-string.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This rule accepts an array of options:
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/reason-string.js)
Expand Down
1 change: 1 addition & 0 deletions docs/rules/gas-consumption/gas-struct-packing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war

### Notes
- This rule assumes all UserDefinedTypeName take a new slot. (beware of Enums inside Structs)
- Simple cases like a struct with three addresses might be reported as false positive. (needs to be fixed)
- [source 1](https://coinsbench.com/comprehensive-guide-tips-and-tricks-for-gas-optimization-in-solidity-5380db734404) of the rule initiative (Variable Packing)
- [source 2](https://www.rareskills.io/post/gas-optimization?postId=c9db474a-ff97-4fa3-a51d-fe13ccb8fe3b#viewer-f8m1r) of the rule initiative

Expand Down
41 changes: 41 additions & 0 deletions docs/rules/miscellaneous/duplicated-imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
warning: "This is a dynamically generated file. Do not edit manually."
layout: "default"
title: "duplicated-imports | Solhint"
---

# duplicated-imports
![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational)
![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow)

## Description
Check if an import is done twice in the same file and there is no alias

## Options
This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn.

### Example Config
```json
{
"rules": {
"duplicated-imports": "warn"
}
}
```

### Notes
- Rule reports "(inline) duplicated" if the same object is imported more than once in the same import statement
- Rule reports "(globalSamePath) duplicated" if the same object is imported on another import statement from same location
- Rule reports "(globalDiffPath) duplicated" if the same object is imported on another import statement, from other location, but no alias
- Rule does NOT support this kind of import "import * as Alias from "./filename.sol"

## Examples
This rule does not have examples.

## Version
This rule is introduced in the latest version.

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/miscellaneous/duplicated-imports.js)
- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/miscellaneous/duplicated-imports.md)
- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/miscellaneous/duplicated-imports.js)
2 changes: 1 addition & 1 deletion docs/rules/naming/contract-name-capwords.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
This rule does not have examples.

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/contract-name-capwords.js)
Expand Down
2 changes: 1 addition & 1 deletion docs/rules/naming/event-name-capwords.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
This rule does not have examples.

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/event-name-capwords.js)
Expand Down
8 changes: 4 additions & 4 deletions docs/rules/naming/imports-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war
This rule does not have examples.

## Version
This rule was introduced in [Solhint 5.0.2](https://github.com/protofire/solhint/blob/v5.0.2)
This rule is introduced in the latest version.

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/imports-order.js)
- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/imports-order.md)
- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/imports-order.js)
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/order/imports-order.js)
- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/order/imports-order.md)
- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/order/imports-order.js)
2 changes: 1 addition & 1 deletion docs/rules/naming/interface-starts-with-i.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface Foo { function foo () external; }
```

## Version
This rule is introduced in the latest version.
This rule was introduced in [Solhint 5.0.4](https://github.com/protofire/solhint/blob/v5.0.4)

## Resources
- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/interface-starts-with-i.js)
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/security/compiler-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ This rule accepts an array of options:
| Index | Description | Default Value |
| ----- | ----------------------------------------------------- | ------------- |
| 0 | Rule severity. Must be one of "error", "warn", "off". | error |
| 1 | Semver requirement | ^0.8.0 |
| 1 | Semver requirement | ^0.8.24 |


### Example Config
```json
{
"rules": {
"compiler-version": ["error","^0.8.0"]
"compiler-version": ["error","^0.8.24"]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/use-in-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ report.messages.forEach(curError => console.log(curError.message));
**linter.processStr**:

- Arguments:
- code {String} - Source code to validation
- code {String} - Source code for validation
- config {Object} - Object representation of .solhint.json configuration
- Returns:
- report {Report} - object that contains list of errors and warnings
Expand Down
3 changes: 2 additions & 1 deletion e2e/03-no-empty-blocks/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"rules": {
"no-empty-blocks": "error"
"no-empty-blocks": "error",
"compiler-version": "off"
}
}
3 changes: 2 additions & 1 deletion e2e/04-dotSol-on-path/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"rules": {
"no-empty-blocks": "off"
"no-empty-blocks": "off",
"compiler-version": "off"
}
}
2 changes: 1 addition & 1 deletion e2e/05-max-warnings/contracts/Foo.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
pragma solidity >=0.8.24;

contract Foo {
uint256 public constant test1 = 1;
Expand Down
2 changes: 1 addition & 1 deletion e2e/06-formatters/contracts/Foo2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
pragma solidity >=0.8.24;

contract Foo {
uint256 public constant test1 = 1;
Expand Down
2 changes: 1 addition & 1 deletion e2e/06-formatters/contracts/Foo3.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
pragma solidity >=0.8.24;

contract Foo {
uint256 public constant TEST1 = 1;
Expand Down
2 changes: 1 addition & 1 deletion e2e/06-formatters/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const foo1Output = [
line: 2,
column: 1,
severity: 'Error',
message: 'Compiler version >=0.6.0 does not satisfy the ^0.8.0 semver requirement',
message: 'Compiler version >=0.6.0 does not satisfy the ^0.8.24 semver requirement',
ruleId: 'compiler-version',
fix: null,
filePath: 'contracts/Foo.sol',
Expand Down
2 changes: 1 addition & 1 deletion e2e/08-autofix/_commands/Foo1.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.4;
pragma solidity ^0.8.24;

import {ERC20Burnable} from '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol';

Expand Down
2 changes: 1 addition & 1 deletion e2e/08-autofix/_commands/Foo1AfterFix.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.4;
pragma solidity ^0.8.24;

import {ERC20Burnable} from '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol';

Expand Down
2 changes: 1 addition & 1 deletion e2e/08-autofix/_commands/Foo1BeforeFix.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.4;
pragma solidity ^0.8.24;

import {ERC20Burnable} from '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol';

Expand Down
Loading

0 comments on commit 0a34c4d

Please sign in to comment.