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

5.0.2 Develop to Master #590

Merged
merged 35 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ccffdcb
Exclude abi.encodeX calls from func-named-parameters
0xCLARITY May 23, 2024
3b74499
Fix linting
0xCLARITY May 28, 2024
2b2a0a4
chore: fix some comments
dropbigfish Jun 13, 2024
13c6c11
Merge pull request #586 from dropbigfish/develop
dbale-altoros Jun 19, 2024
b9530be
Fix typo in error msg
0xCLARITY Jun 28, 2024
8490cc3
Merge branch 'develop' into exclude-abi-calls-from-named-parameters
0xCLARITY Jun 28, 2024
6c33840
add: import-order rule
dbale-altoros Jul 1, 2024
0ae84e3
add: import-order rule
dbale-altoros Jul 1, 2024
93b02f4
autofix e2e tests
dbale-altoros Jul 1, 2024
6fc5b55
autofix e2e tests
dbale-altoros Jul 1, 2024
00325ef
autofix e2e tests2
dbale-altoros Jul 1, 2024
79ecd10
autofix e2e tests3
dbale-altoros Jul 1, 2024
35adc1b
autofix e2e tests4
dbale-altoros Jul 1, 2024
f7d1991
autofix e2e tests5
dbale-altoros Jul 1, 2024
f51ea6a
autofix e2e tests5
dbale-altoros Jul 1, 2024
8339397
autofix e2e tests7
dbale-altoros Jul 1, 2024
25a6fcb
autofix e2e tests8
dbale-altoros Jul 1, 2024
e95e2be
autofix e2e tests9
dbale-altoros Jul 1, 2024
824270b
autofix e2e tests10
dbale-altoros Jul 16, 2024
e25b721
autofix e2e tests10
dbale-altoros Jul 16, 2024
649dee8
autofix e2e test11
dbale-altoros Jul 17, 2024
a0c9cad
autofix e2e test11
dbale-altoros Jul 17, 2024
684aa06
autofix e2e test11
dbale-altoros Jul 17, 2024
a8ac616
autofix e2e test12
dbale-altoros Jul 17, 2024
22aca44
autofix e2e test13
dbale-altoros Jul 17, 2024
f7d7126
autofix e2e test14
dbale-altoros Jul 17, 2024
0b52aaa
fix: import-order rule
dbale-altoros Jul 22, 2024
b91d312
fix: import-order rule
dbale-altoros Jul 22, 2024
bf7893f
fix: import-order rule
dbale-altoros Jul 22, 2024
efa15b5
Merge pull request #583 from 0xCLARITY/exclude-abi-calls-from-named-p…
dbale-altoros Jul 25, 2024
efea5d8
Merge branch 'develop' into import-order-rule
dbale-altoros Jul 25, 2024
e31d090
Merge pull request #587 from protofire/import-order-rule
dbale-altoros Jul 25, 2024
7bdc059
5.0.2 pre-release
dbale-altoros Jul 25, 2024
0b5fea1
Merge pull request #589 from protofire/502-pre-release
dbale-altoros Jul 25, 2024
8012672
Merge branch 'master' into develop
dbale-altoros Jul 25, 2024
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
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 100
"printWidth": 100,
"bracketSpacing": true
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [5.0.2] - 2024-07-25
### Fixed
- `func-named-parameters` exclude abi.encodeX from the rule [#583](https://github.com/protofire/solhint/pull/583) (Thanks to [@0xCLARITY](https://github.com/0xCLARITY))
- Several typos in comments [#586](https://github.com/protofire/solhint/pull/586) (Thanks to [@dropbigfish](https://github.com/dropbigfish))

### Added
- New Rule: Imports order [#587](https://github.com/protofire/solhint/pull/587)

<br><br>

## [5.0.1] - 2024-05-13
### BREAKING CHANGES (refer to v5.0.0)
Fixed an issue on the returining values where only was evaluating the first report instead of all of them.
Expand Down
1 change: 1 addition & 0 deletions conf/rulesets/solhint-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = Object.freeze({
immutablesAsConstants: true,
},
],
'imports-order': 'warn',
'modifier-name-mixedcase': 'warn',
'named-parameters-mapping': 'warn',
'private-vars-leading-underscore': [
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="diego.bale@protofire.io"
ENV VERSION=5.0.1
ENV VERSION=5.0.2

RUN npm install -g solhint@"$VERSION"
1 change: 1 addition & 0 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ 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 | | |
Expand Down
42 changes: 42 additions & 0 deletions docs/rules/naming/imports-order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
warning: "This is a dynamically generated file. Do not edit manually."
layout: "default"
title: "imports-order | Solhint"
---

# imports-order
![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
Order the imports of the contract to follow a certain hierarchy (read "Notes section")

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

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

### Notes
- Paths starting with "@" like "@openzeppelin/" and urls ("http" and "https") will go first
- Order by hierarchy of directories first, e.g. ./../../ comes before ./../, which comes before ./, which comes before ./foo
- Order alphabetically for each path at the same level, e.g. ./contract/Zbar.sol comes before ./interface/Ifoo.sol
- Rule does NOT support this kind of import "import * as Alias from "./filename.sol"
- When "--fix", rule will re-write this notation "../folder/file.sol" or this one "../file.sol" to "./../folder/file.sol" or this one "./../file.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/tree/master/lib/rules/naming/imports-order.js)
- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/imports-order.md)
- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/imports-order.js)
2 changes: 1 addition & 1 deletion docs/rules/naming/named-parameters-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mapping(string name => uint256 balance) public users;
mapping(address owner => mapping(address token => uint256 balance)) public tokenBalances;
```

#### Main key of mapping is enforced. On nested mappings other naming are not neccesary
#### Main key of mapping is enforced. On nested mappings other naming are not necessary

```solidity
mapping(address owner => mapping(address => uint256)) public tokenBalances;
Expand Down
5 changes: 5 additions & 0 deletions e2e/08-autofix/imports-order/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"imports-order": "error"
}
}
25 changes: 25 additions & 0 deletions e2e/08-autofix/imports-order/Foo1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';
import { Unauthorized, add as func, Point } from './Foo.sol';
import 'https://github.com/owner/repo/blob/branch/path/to/Contract.sol';
import { Initializable } from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '../../../../token/interfaces/FakeContract1.sol';
import { FakeContract3 } from '../../../token/interfaces/FakeContract3.sol';
import './../../../../token/interfaces/AFakeContract1.sol';
import './../token/interfaces/IXTokenWrapper.sol';
import { IXTokenFactory, holaquetal } from '../../token/interfaces/IXTokenFactory.sol';
import './../../bpath/otherfolder/otherfolder/aContract.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import { FakeContract2 } from '../../../token/interfaces/FakeContract2.sol';
import '../../apath/zContract.sol';
import 'http://github.com/owner/repo/blob/branch/path/to/Contract2.sol';
import { Afool1 } from './Afool1.sol';
import './Ownable.sol';
import { IXTokenWrapper2 } from '../token/interfaces/IXTokenWrapper2.sol';
import { ReentrancyGuardUpgradeable2 } from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';

contract ImportsOrder {
constructor() {}
}
25 changes: 25 additions & 0 deletions e2e/08-autofix/imports-order/Foo1AfterFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import { ReentrancyGuardUpgradeable2 } from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import 'http://github.com/owner/repo/blob/branch/path/to/Contract2.sol';
import 'https://github.com/owner/repo/blob/branch/path/to/Contract.sol';
import './../../../../token/interfaces/AFakeContract1.sol';
import './../../../../token/interfaces/FakeContract1.sol';
import { FakeContract2 } from './../../../token/interfaces/FakeContract2.sol';
import { FakeContract3 } from './../../../token/interfaces/FakeContract3.sol';
import './../../apath/zContract.sol';
import './../../bpath/otherfolder/otherfolder/aContract.sol';
import { IXTokenFactory, holaquetal } from './../../token/interfaces/IXTokenFactory.sol';
import './../token/interfaces/IXTokenWrapper.sol';
import { IXTokenWrapper2 } from './../token/interfaces/IXTokenWrapper2.sol';
import { Afool1 } from './Afool1.sol';
import { Unauthorized, add as func, Point } from './Foo.sol';
import { Initializable } from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import './Ownable.sol';
import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';

contract ImportsOrder {
constructor() {}
}
25 changes: 25 additions & 0 deletions e2e/08-autofix/imports-order/Foo1BeforeFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';
import { Unauthorized, add as func, Point } from './Foo.sol';
import 'https://github.com/owner/repo/blob/branch/path/to/Contract.sol';
import { Initializable } from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '../../../../token/interfaces/FakeContract1.sol';
import { FakeContract3 } from '../../../token/interfaces/FakeContract3.sol';
import './../../../../token/interfaces/AFakeContract1.sol';
import './../token/interfaces/IXTokenWrapper.sol';
import { IXTokenFactory, holaquetal } from '../../token/interfaces/IXTokenFactory.sol';
import './../../bpath/otherfolder/otherfolder/aContract.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import { FakeContract2 } from '../../../token/interfaces/FakeContract2.sol';
import '../../apath/zContract.sol';
import 'http://github.com/owner/repo/blob/branch/path/to/Contract2.sol';
import { Afool1 } from './Afool1.sol';
import './Ownable.sol';
import { IXTokenWrapper2 } from '../token/interfaces/IXTokenWrapper2.sol';
import { ReentrancyGuardUpgradeable2 } from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';

contract ImportsOrder {
constructor() {}
}
19 changes: 19 additions & 0 deletions e2e/08-autofix/imports-order/Foo2.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';
import '../../../../../token/interfaces/IXTokenWrapper3.sol';
import {IXTokenFactory2} from '../../atoken/interfaces/IXTokenFactory2.sol';
import {Initializable} from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '../../../../token/interfaces/FakeContract1.sol';
import '../token/interfaces/IXTokenWrapper.sol';
import {IXTokenFactory, holaquetal} from '../../token/interfaces/IXTokenFactory.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import {FakeContract2} from '../../../token/interfaces/FakeContract2.sol';
import {Afool1} from './Afool1.sol';
import {IXTokenWrapper2} from '../token/interfaces/IXTokenWrapper2.sol';
import {ReentrancyGuardUpgradeable2} from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';

contract ImportsOrder2 {
constructor() {}
}
19 changes: 19 additions & 0 deletions e2e/08-autofix/imports-order/Foo2AfterFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import {ReentrancyGuardUpgradeable2} from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import '../../../../../token/interfaces/IXTokenWrapper3.sol';
import '../../../../token/interfaces/FakeContract1.sol';
import {FakeContract2} from '../../../token/interfaces/FakeContract2.sol';
import {IXTokenFactory2} from '../../atoken/interfaces/IXTokenFactory2.sol';
import {IXTokenFactory, holaquetal} from '../../token/interfaces/IXTokenFactory.sol';
import '../token/interfaces/IXTokenWrapper.sol';
import {IXTokenWrapper2} from '../token/interfaces/IXTokenWrapper2.sol';
import {Initializable} from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import {Afool1} from './Afool1.sol';
import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';

contract ImportsOrder2 {
constructor() {}
}
19 changes: 19 additions & 0 deletions e2e/08-autofix/imports-order/Foo2BeforeFix.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import './ThisIsAVeryLongFileOnPurposeToTestTheFirstPathShorterThanTheLastOnelooooooooooong.sol';
import '../../../../../token/interfaces/IXTokenWrapper3.sol';
import {IXTokenFactory2} from '../../atoken/interfaces/IXTokenFactory2.sol';
import {Initializable} from './openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '../../../../token/interfaces/FakeContract1.sol';
import '../token/interfaces/IXTokenWrapper.sol';
import {IXTokenFactory, holaquetal} from '../../token/interfaces/IXTokenFactory.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import {FakeContract2} from '../../../token/interfaces/FakeContract2.sol';
import {Afool1} from './Afool1.sol';
import {IXTokenWrapper2} from '../token/interfaces/IXTokenWrapper2.sol';
import {ReentrancyGuardUpgradeable2} from '@apenzeppelin/ReentrancyGuardUpgradeable2.sol';

contract ImportsOrder2 {
constructor() {}
}
Loading
Loading