diff --git a/.github/workflows/PRE-COMMIT-HOOK-TEST.yml b/.github/workflows/PRE-COMMIT-HOOK-TEST.yml new file mode 100644 index 00000000..4e15bbc8 --- /dev/null +++ b/.github/workflows/PRE-COMMIT-HOOK-TEST.yml @@ -0,0 +1,34 @@ +name: PRE-COMMIT + +on: + push: + branches: + - master + - develop + tags: + - '*' + pull_request: + paths: + - .github/workflows/PRE-COMMIT-HOOK-TEST.yml + - .pre-commit-hooks.yaml + - e2e/pre-commit-hook/* + - package.json + +jobs: + hook-test: + runs-on: ubuntu-latest + name: Test Hook + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install pre-commit + run: | + python -m pip install pre-commit + - name: Test hooks + run: | + ./e2e/pre-commit-hook/test.sh diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index e09f21fc..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -sh ./scripts/generate-changed.sh diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..a168aea4 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: solhint + name: solhint + description: Lint Solidity files with Solhint + entry: solhint + types: ["solidity"] + language: node diff --git a/CHANGELOG.md b/CHANGELOG.md index f0304637..1ed59d9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,21 @@ +## [5.0.4] - 2024-12-31 +### Fixed +- `imports-order` [#595](https://github.com/protofire/solhint/pull/595) - Replaced single quotes with double quotes +- `gas-custom-errors` [#613](https://github.com/protofire/solhint/pull/613) - Allows the use of Requirement with Custom Errors +- Typos and broken links [#611](https://github.com/protofire/solhint/pull/611) - [#617](https://github.com/protofire/solhint/pull/617) +- Upgraded `solidity-parser` dependency [#612](https://github.com/protofire/solhint/pull/612) + + +### Added +- `.pre-commit-hooks.yaml` to allow projects to run Solhint via pre-commit [#596](https://github.com/protofire/solhint/pull/596) (Thanks to [@dbast](https://github.com/dbast)) +- Removed `husky` since it is not needed [#612](https://github.com/protofire/solhint/pull/612) + +

+ + ## [5.0.3] - 2024-08-03 ### Fixed -- New Rule: Imports order [#593](https://github.com/protofire/solhint/pull/593) +- `imports-order` [#593](https://github.com/protofire/solhint/pull/593)

@@ -16,10 +31,11 @@ ## [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. +Fixed an issue on the returning values where only was evaluating the first report instead of all of them.

+ ## [5.0.0] - 2024-05-11 ### BREAKING CHANGES @@ -37,6 +53,7 @@ QUIET mode (-c quiet) option now works with the warnings and may exit with 1 if Thanks to [@juanpcapurro](https://github.com/juanpcapurro) for providing the code

+ ## [4.5.4] - 2024-04-10 ### Fixed - `gas-custom-errors` improved logic to ranged pragma versions [#573](https://github.com/protofire/solhint/pull/573) @@ -68,7 +85,7 @@ Thanks to [@juanpcapurro](https://github.com/juanpcapurro) for providing the cod - New Rule: Interface starts with `i` [#557](https://github.com/protofire/solhint/pull/557) #### Gas Consumption Rules -- New Rule: [GC] Mutlitoken1155 rule [#541](https://github.com/protofire/solhint/pull/541) +- New Rule: [GC] Multitoken1155 rule [#541](https://github.com/protofire/solhint/pull/541) - New Rule: [GC] Small strings check [#542](https://github.com/protofire/solhint/pull/542) - New Rule: [GC] Indexed events [#543](https://github.com/protofire/solhint/pull/543) - New Rule: [GC] Calldata parameters [#544](https://github.com/protofire/solhint/pull/544) @@ -153,7 +170,7 @@ Thanks to [@juanpcapurro](https://github.com/juanpcapurro) for providing the cod ### Fixed - `foundry-test-functions` - Modified regex to include invariant and statefulFuzz tests [#484](https://github.com/protofire/solhint/pull/484) -- `quotes` - To allow quotes inside double quotes and viceversa [#485](https://github.com/protofire/solhint/pull/485) +- `quotes` - To allow quotes inside double quotes and vice versa [#485](https://github.com/protofire/solhint/pull/485) - `JSON` - Formatter returning JS object instead of standard json [#490](https://github.com/protofire/solhint/pull/490) diff --git a/DEV-README.md b/DEV-README.md new file mode 100644 index 00000000..2e13cd8e --- /dev/null +++ b/DEV-README.md @@ -0,0 +1,11 @@ +## Setting up Git Hooks + +After cloning the repository, set up the pre-commit hook by running the following commands: + +`git config --unset core.hooksPath` +To reset the hooks config to git default + +```sh +touch .git/hooks/pre-commit +chmod +x .git/hooks/pre-commit +echo '#!/bin/sh\nnode scripts/check-changes.js' > .git/hooks/pre-commit \ No newline at end of file diff --git a/README.md b/README.md index 38361573..e6b341f0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- +

By Protofire @@ -16,7 +16,7 @@ https://coveralls.io/github/protofire/solhint?branch=master) This is an open source project for linting [Solidity](http://solidity.readthedocs.io/en/develop/) code. This project provides both **Security** and **Style Guide** validations.
-[VISIT OUR WEBSITE](https://protofire.io/projects/solhint)
+[VISIT OUR WEBSITE](https://protofire.io/solhint)
[JOIN OUR DISCORD SERVER](https://discord.gg/4TYGq3zpjs)
## Installation @@ -204,12 +204,24 @@ Or disable all validations for a group of lines: ### Style Guide Rules [Full list with all supported Style Guide Rules](docs/rules.md#style-guide-rules) ### Best Practices Rules -[Full list with all supported Best Practices Rules](docs/rules.md#best-practise-rules) +[Full list with all supported Best Practices Rules](docs/rules.md#best-practices-rules) ## Docker ### Solhint has an official Docker Image Go to docker folder and follow [this](docker/docker.md) instructions. +## pre-commit +### Solhint can also be used as [pre-commit](https://pre-commit.com/) hook + +Replace `$GIT_TAG` with real tag: + +```YAML +- repo: https://github.com/protofire/solhint + rev: $GIT_TAG + hooks: + - id: solhint +``` + ## Documentation Related documentation you may find [here](https://protofire.github.io/solhint/). @@ -257,7 +269,7 @@ Related documentation you may find [here](https://protofire.github.io/solhint/). The Solidity parser used is [`@solidity-parser/parser`](https://github.com/solidity-parser/parser). -## Licence +## License MIT diff --git a/conf/rulesets/solhint-all.js b/conf/rulesets/solhint-all.js index 06b9fc5a..5c0629e6 100644 --- a/conf/rulesets/solhint-all.js +++ b/conf/rulesets/solhint-all.js @@ -38,8 +38,8 @@ module.exports = Object.freeze({ 'comprehensive-interface': 'warn', quotes: ['error', 'double'], 'const-name-snakecase': 'warn', - 'contract-name-camelcase': 'warn', - 'event-name-camelcase': 'warn', + 'contract-name-capwords': 'warn', + 'event-name-capwords': 'warn', 'foundry-test-functions': ['warn', ['setUp']], 'func-name-mixedcase': 'warn', 'func-named-parameters': ['warn', 4], diff --git a/conf/rulesets/solhint-recommended.js b/conf/rulesets/solhint-recommended.js index 68c7fadf..da7f6095 100644 --- a/conf/rulesets/solhint-recommended.js +++ b/conf/rulesets/solhint-recommended.js @@ -23,8 +23,8 @@ module.exports = Object.freeze({ 'gas-custom-errors': 'warn', quotes: ['error', 'double'], 'const-name-snakecase': 'warn', - 'contract-name-camelcase': 'warn', - 'event-name-camelcase': 'warn', + 'contract-name-capwords': 'warn', + 'event-name-capwords': 'warn', 'func-name-mixedcase': 'warn', 'immutable-vars-naming': [ 'warn', diff --git a/docker/Dockerfile b/docker/Dockerfile index 61c9a8c3..a520a3f2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ FROM node:20-alpine LABEL maintainer="diego.bale@protofire.io" -ENV VERSION=5.0.3 +ENV VERSION=5.0.4 RUN npm install -g solhint@"$VERSION" \ No newline at end of file diff --git a/docs/configuration.md b/docs/configuration.md index 39e9ed25..3046ec7b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -4,7 +4,7 @@ title: Solhint Configuration date: 2017-10-23 14:16:00 +0300 author: "@drabenia" description: Configuration of solidity security and style guide verification, - best practise validations. + best practice validations. --- ### Configuration diff --git a/docs/rules.md b/docs/rules.md index 8c644b5f..7b108d8a 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -4,24 +4,23 @@ layout: "default" title: "Rule Index of Solhint" --- -## Best Practise Rules +## Best Practice Rules | Rule Id | Error | Recommended | Deprecated | | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------ | ---------- | -| [code-complexity](./rules/best-practises/code-complexity.md) | Function has cyclomatic complexity "current" but allowed no more than maxcompl. | | | -| [explicit-types](./rules/best-practises/explicit-types.md) | Forbid or enforce explicit types (like uint256) that have an alias (like uint). | $~~~~~~~~$✔️ | | -| [function-max-lines](./rules/best-practises/function-max-lines.md) | Function body contains "count" lines but allowed no more than maxlines. | | | -| [max-line-length](./rules/best-practises/max-line-length.md) | Line length must be no more than maxlen. | | | -| [max-states-count](./rules/best-practises/max-states-count.md) | Contract has "some count" states declarations but allowed no more than maxstates. | $~~~~~~~~$✔️ | | -| [no-console](./rules/best-practises/no-console.md) | No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements. | $~~~~~~~~$✔️ | | -| [no-empty-blocks](./rules/best-practises/no-empty-blocks.md) | Code block has zero statements inside. Exceptions apply. | $~~~~~~~~$✔️ | | -| [no-global-import](./rules/best-practises/no-global-import.md) | Import statement includes an entire file instead of selected symbols. | $~~~~~~~~$✔️ | | -| [no-unused-import](./rules/best-practises/no-unused-import.md) | Imported object name is not being used by the contract. | $~~~~~~~~$✔️ | | -| [no-unused-vars](./rules/best-practises/no-unused-vars.md) | Variable "name" is unused. | $~~~~~~~~$✔️ | | -| [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) | $~~~~~~~~$✔️ | | -| [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. | $~~~~~~~~$✔️ | | -| [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. | $~~~~~~~~$✔️ | | -| [constructor-syntax](./rules/best-practises/constructor-syntax.md) | Constructors should use the new constructor keyword. | | | +| [code-complexity](./rules/best-practices/code-complexity.md) | Function has cyclomatic complexity "current" but allowed no more than maxcompl. | | | +| [explicit-types](./rules/best-practices/explicit-types.md) | Forbid or enforce explicit types (like uint256) that have an alias (like uint). | $~~~~~~~~$✔️ | | +| [function-max-lines](./rules/best-practices/function-max-lines.md) | Function body contains "count" lines but allowed no more than maxlines. | | | +| [max-line-length](./rules/best-practices/max-line-length.md) | Line length must be no more than maxlen. | | | +| [max-states-count](./rules/best-practices/max-states-count.md) | Contract has "some count" states declarations but allowed no more than maxstates. | $~~~~~~~~$✔️ | | +| [no-console](./rules/best-practices/no-console.md) | No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements. | $~~~~~~~~$✔️ | | +| [no-empty-blocks](./rules/best-practices/no-empty-blocks.md) | Code block has zero statements inside. Exceptions apply. | $~~~~~~~~$✔️ | | +| [no-global-import](./rules/best-practices/no-global-import.md) | Import statement includes an entire file instead of selected symbols. | $~~~~~~~~$✔️ | | +| [no-unused-import](./rules/best-practices/no-unused-import.md) | Imported object name is not being used by the contract. | $~~~~~~~~$✔️ | | +| [no-unused-vars](./rules/best-practices/no-unused-vars.md) | Variable "name" is unused. | $~~~~~~~~$✔️ | | +| [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) | $~~~~~~~~$✔️ | | +| [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. | $~~~~~~~~$✔️ | | +| [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. | $~~~~~~~~$✔️ | | ## Style Guide Rules @@ -30,8 +29,8 @@ title: "Rule Index of Solhint" | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------ | ----------- | | [interface-starts-with-i](./rules/naming/interface-starts-with-i.md) | Solidity Interfaces names should start with an `I` | | | | [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-camelcase](./rules/naming/contract-name-camelcase.md) | Contract, Structs and Enums should be in CamelCase. | $~~~~~~~~$✔️ | | -| [event-name-camelcase](./rules/naming/event-name-camelcase.md) | Event name must be in CamelCase. | $~~~~~~~~$✔️ | | +| [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. | $~~~~~~~~$✔️ | | | [foundry-test-functions](./rules/naming/foundry-test-functions.md) | Enforce naming convention on functions for Foundry test cases | | | | [func-name-mixedcase](./rules/naming/func-name-mixedcase.md) | Function name must be in mixedCase. | $~~~~~~~~$✔️ | | | [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 | | | @@ -42,35 +41,42 @@ title: "Rule Index of Solhint" | [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 name must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming) | $~~~~~~~~$✔️ | | +| [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. | $~~~~~~~~$✔️ | | | [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. | $~~~~~~~~$✔️ | | +## Best Practices Rules + +| Rule Id | Error | Recommended | Deprecated | +| ------------------------------------------------------------------ | ---------------------------------------------------- | ----------- | ---------- | +| [constructor-syntax](./rules/best-practices/constructor-syntax.md) | Constructors should use the new constructor keyword. | | | + + ## Gas Consumption Rules -| Rule Id | Error | Recommended | Deprecated | -| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------ | ---------- | -| [gas-calldata-parameters](./rules/gas-consumption/gas-calldata-parameters.md) | Suggest calldata keyword on function arguments when read only | | | -| [gas-custom-errors](./rules/gas-consumption/gas-custom-errors.md) | Enforces the use of Custom Errors over Require and Revert statements | $~~~~~~~~$✔️ | | -| [gas-increment-by-one](./rules/gas-consumption/gas-increment-by-one.md) | Suggest incrementation by one like this ++i instead of other type | | | -| [gas-indexed-events](./rules/gas-consumption/gas-indexed-events.md) | Suggest indexed arguments on events for uint, bool and address | | | -| [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 | | | -| [gas-multitoken1155](./rules/gas-consumption/gas-multitoken1155.md) | ERC1155 is a cheaper non-fungible token than ERC721 | | | -| [gas-named-return-values](./rules/gas-consumption/gas-named-return-values.md) | Enforce the return values of a function to be named | | | -| [gas-small-strings](./rules/gas-consumption/gas-small-strings.md) | Keep strings smaller than 32 bytes | | | -| [gas-strict-inequalities](./rules/gas-consumption/gas-strict-inequalities.md) | Suggest Strict Inequalities over non Strict ones | | | -| [gas-struct-packing](./rules/gas-consumption/gas-struct-packing.md) | Suggest to re-arrange struct packing order when it is inefficient | | | +| Rule Id | Error | Recommended | Deprecated | +| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------ | ---------- | +| [gas-calldata-parameters](./rules/gas-consumption/gas-calldata-parameters.md) | Suggest calldata keyword on function arguments when read only | | | +| [gas-custom-errors](./rules/gas-consumption/gas-custom-errors.md) | Enforces the use of Custom Errors over Require with strings error and Revert statements | $~~~~~~~~$✔️ | | +| [gas-increment-by-one](./rules/gas-consumption/gas-increment-by-one.md) | Suggest increments by one, like this ++i instead of other type | | | +| [gas-indexed-events](./rules/gas-consumption/gas-indexed-events.md) | Suggest indexed arguments on events for uint, bool and address | | | +| [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 | | | +| [gas-multitoken1155](./rules/gas-consumption/gas-multitoken1155.md) | ERC1155 is a cheaper non-fungible token than ERC721 | | | +| [gas-named-return-values](./rules/gas-consumption/gas-named-return-values.md) | Enforce the return values of a function to be named | | | +| [gas-small-strings](./rules/gas-consumption/gas-small-strings.md) | Keep strings smaller than 32 bytes | | | +| [gas-strict-inequalities](./rules/gas-consumption/gas-strict-inequalities.md) | Suggest Strict Inequalities over non Strict ones | | | +| [gas-struct-packing](./rules/gas-consumption/gas-struct-packing.md) | Suggest to re-arrange struct packing order when it is inefficient | | | ## Miscellaneous -| Rule Id | Error | Recommended | Deprecated | -| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ---------- | -| [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. | | | -| [quotes](./rules/miscellaneous/quotes.md) | Enforces the use of double or simple quotes as configured for string literals. Values must be 'single' or 'double'. | $~~~~~~~~$✔️ | | +| Rule Id | Error | Recommended | Deprecated | +| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ---------- | +| [comprehensive-interface](./rules/miscellaneous/comprehensive-interface.md) | Check that all public or external functions are overridden. This is useful to make sure that the whole API is extracted in an interface. | | | +| [quotes](./rules/miscellaneous/quotes.md) | Enforces the use of double or simple quotes as configured for string literals. Values must be 'single' or 'double'. | $~~~~~~~~$✔️ | | ## Security Rules @@ -98,5 +104,5 @@ title: "Rule Index of Solhint" ## References -- [ConsenSys Guide for Smart Contracts](https://consensys.github.io/smart-contract-best-practices/recommendations/) +- [ConsenSys Guide for Smart Contracts](https://consensys.github.io/smart-contract-best-practices/development-recommendations/) - [Solidity Style Guide](http://solidity.readthedocs.io/en/develop/style-guide.html) diff --git a/docs/rules/best-practises/code-complexity.md b/docs/rules/best-practices/code-complexity.md similarity index 78% rename from docs/rules/best-practises/code-complexity.md rename to docs/rules/best-practices/code-complexity.md index d5642859..a24a049e 100644 --- a/docs/rules/best-practises/code-complexity.md +++ b/docs/rules/best-practices/code-complexity.md @@ -5,7 +5,7 @@ title: "code-complexity | Solhint" --- # code-complexity -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) ## Description @@ -67,9 +67,9 @@ while (d > e) { } ``` ## Version -This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/code-complexity.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/code-complexity.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/code-complexity.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/code-complexity.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/code-complexity.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/code-complexity.js) diff --git a/docs/rules/best-practises/constructor-syntax.md b/docs/rules/best-practices/constructor-syntax.md similarity index 68% rename from docs/rules/best-practises/constructor-syntax.md rename to docs/rules/best-practices/constructor-syntax.md index e25d5c63..5b0543eb 100644 --- a/docs/rules/best-practises/constructor-syntax.md +++ b/docs/rules/best-practices/constructor-syntax.md @@ -5,14 +5,14 @@ title: "constructor-syntax | Solhint" --- # constructor-syntax -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practices%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) ## Description Constructors should use the new constructor keyword. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -28,9 +28,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 1.2.0](https://github.com/protofire/solhint/tree/v1.2.0) +This rule was introduced in [Solhint 1.2.0](https://github.com/protofire/solhint/blob/v1.2.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/deprecations/constructor-syntax.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/deprecations/constructor-syntax.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/deprecations/constructor-syntax.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/deprecations/constructor-syntax.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/deprecations/constructor-syntax.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/deprecations/constructor-syntax.js) diff --git a/docs/rules/best-practises/explicit-types.md b/docs/rules/best-practices/explicit-types.md similarity index 77% rename from docs/rules/best-practises/explicit-types.md rename to docs/rules/best-practices/explicit-types.md index 2a472762..abf0b10d 100644 --- a/docs/rules/best-practises/explicit-types.md +++ b/docs/rules/best-practices/explicit-types.md @@ -6,7 +6,7 @@ title: "explicit-types | Solhint" # explicit-types ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -77,9 +77,9 @@ uint public variableName = uint256(5) ``` ## Version -This rule was introduced in [Solhint 3.5.1](https://github.com/protofire/solhint/tree/v3.5.1) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/explicit-types.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/explicit-types.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/explicit-types.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/explicit-types.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/explicit-types.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/explicit-types.js) diff --git a/docs/rules/best-practises/function-max-lines.md b/docs/rules/best-practices/function-max-lines.md similarity index 64% rename from docs/rules/best-practises/function-max-lines.md rename to docs/rules/best-practices/function-max-lines.md index 3bedcd83..209d1f9d 100644 --- a/docs/rules/best-practises/function-max-lines.md +++ b/docs/rules/best-practices/function-max-lines.md @@ -5,7 +5,7 @@ title: "function-max-lines | Solhint" --- # function-max-lines -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) ## Description @@ -34,9 +34,9 @@ This rule accepts an array of options: This rule does not have examples. ## Version -This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/function-max-lines.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/function-max-lines.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/function-max-lines.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/function-max-lines.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/function-max-lines.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/function-max-lines.js) diff --git a/docs/rules/best-practises/max-line-length.md b/docs/rules/best-practices/max-line-length.md similarity index 66% rename from docs/rules/best-practises/max-line-length.md rename to docs/rules/best-practices/max-line-length.md index 6017c3b4..d0c02777 100644 --- a/docs/rules/best-practises/max-line-length.md +++ b/docs/rules/best-practices/max-line-length.md @@ -5,7 +5,7 @@ title: "max-line-length | Solhint" --- # max-line-length -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge error](https://img.shields.io/badge/Default%20Severity-error-red) > The {"extends": "solhint:default"} property in a configuration file enables this rule. @@ -36,9 +36,9 @@ This rule accepts an array of options: This rule does not have examples. ## Version -This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/max-line-length.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/max-line-length.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/max-line-length.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/max-line-length.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/max-line-length.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/max-line-length.js) diff --git a/docs/rules/best-practises/max-states-count.md b/docs/rules/best-practices/max-states-count.md similarity index 83% rename from docs/rules/best-practises/max-states-count.md rename to docs/rules/best-practices/max-states-count.md index 3258d9cf..6306d5e8 100644 --- a/docs/rules/best-practises/max-states-count.md +++ b/docs/rules/best-practices/max-states-count.md @@ -6,7 +6,7 @@ title: "max-states-count | Solhint" # max-states-count ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -99,9 +99,9 @@ This rule accepts an array of options: ``` ## Version -This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/max-states-count.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/max-states-count.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/max-states-count.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/max-states-count.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/max-states-count.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/max-states-count.js) diff --git a/docs/rules/best-practises/no-console.md b/docs/rules/best-practices/no-console.md similarity index 70% rename from docs/rules/best-practises/no-console.md rename to docs/rules/best-practices/no-console.md index 84f6549a..c6765893 100644 --- a/docs/rules/best-practises/no-console.md +++ b/docs/rules/best-practices/no-console.md @@ -6,7 +6,7 @@ title: "no-console | Solhint" # no-console ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge error](https://img.shields.io/badge/Default%20Severity-error-red) > The {"extends": "solhint:default"} property in a configuration file enables this rule. @@ -17,7 +17,7 @@ title: "no-console | Solhint" No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to error. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to error. ### Example Config ```json @@ -53,9 +53,9 @@ import "forge-std/consoleN.sol" ``` ## Version -This rule was introduced in [Solhint 3.4.0](https://github.com/protofire/solhint/tree/v3.4.0) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/no-console.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/no-console.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/no-console.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-console.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/no-console.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/no-console.js) diff --git a/docs/rules/best-practises/no-empty-blocks.md b/docs/rules/best-practices/no-empty-blocks.md similarity index 72% rename from docs/rules/best-practises/no-empty-blocks.md rename to docs/rules/best-practices/no-empty-blocks.md index d8a18752..bc54fe80 100644 --- a/docs/rules/best-practises/no-empty-blocks.md +++ b/docs/rules/best-practices/no-empty-blocks.md @@ -6,7 +6,7 @@ title: "no-empty-blocks | Solhint" # no-empty-blocks ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -15,7 +15,7 @@ title: "no-empty-blocks | Solhint" Code block has zero statements inside. Exceptions apply. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -65,9 +65,9 @@ constructor () { } ``` ## Version -This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/no-empty-blocks.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/no-empty-blocks.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/no-empty-blocks.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-empty-blocks.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/no-empty-blocks.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/no-empty-blocks.js) diff --git a/docs/rules/best-practises/no-global-import.md b/docs/rules/best-practices/no-global-import.md similarity index 69% rename from docs/rules/best-practises/no-global-import.md rename to docs/rules/best-practices/no-global-import.md index 1d95ccd4..2ebbd01c 100644 --- a/docs/rules/best-practises/no-global-import.md +++ b/docs/rules/best-practices/no-global-import.md @@ -6,7 +6,7 @@ title: "no-global-import | Solhint" # no-global-import ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -15,7 +15,7 @@ title: "no-global-import | Solhint" Import statement includes an entire file instead of selected symbols. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -63,9 +63,9 @@ import "foo.sol" ``` ## Version -This rule was introduced in [Solhint 3.4.0](https://github.com/protofire/solhint/tree/v3.4.0) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/no-global-import.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/no-global-import.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/no-global-import.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-global-import.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/no-global-import.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/no-global-import.js) diff --git a/docs/rules/best-practises/no-unused-import.md b/docs/rules/best-practices/no-unused-import.md similarity index 68% rename from docs/rules/best-practises/no-unused-import.md rename to docs/rules/best-practices/no-unused-import.md index 8d567c91..ff253f1d 100644 --- a/docs/rules/best-practises/no-unused-import.md +++ b/docs/rules/best-practices/no-unused-import.md @@ -6,7 +6,7 @@ title: "no-unused-import | Solhint" # no-unused-import ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -15,7 +15,7 @@ title: "no-unused-import | Solhint" Imported object name is not being used by the contract. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -51,9 +51,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war ``` ## Version -This rule was introduced in [Solhint 3.5.1](https://github.com/protofire/solhint/tree/v3.5.1) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/no-unused-import.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/no-unused-import.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/no-unused-import.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-unused-import.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/no-unused-import.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/no-unused-import.js) diff --git a/docs/rules/best-practises/no-unused-vars.md b/docs/rules/best-practices/no-unused-vars.md similarity index 57% rename from docs/rules/best-practises/no-unused-vars.md rename to docs/rules/best-practices/no-unused-vars.md index 5ef1ba30..c34045cc 100644 --- a/docs/rules/best-practises/no-unused-vars.md +++ b/docs/rules/best-practices/no-unused-vars.md @@ -6,7 +6,7 @@ title: "no-unused-vars | Solhint" # no-unused-vars ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -15,7 +15,7 @@ title: "no-unused-vars | Solhint" Variable "name" is unused. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/no-unused-vars.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/no-unused-vars.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/no-unused-vars.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/no-unused-vars.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/no-unused-vars.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/no-unused-vars.js) diff --git a/docs/rules/best-practises/one-contract-per-file.md b/docs/rules/best-practices/one-contract-per-file.md similarity index 60% rename from docs/rules/best-practises/one-contract-per-file.md rename to docs/rules/best-practices/one-contract-per-file.md index 92135351..2a59f567 100644 --- a/docs/rules/best-practises/one-contract-per-file.md +++ b/docs/rules/best-practices/one-contract-per-file.md @@ -6,7 +6,7 @@ title: "one-contract-per-file | Solhint" # one-contract-per-file ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -15,7 +15,7 @@ title: "one-contract-per-file | Solhint" 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) ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 3.6.2](https://github.com/protofire/solhint/tree/v3.6.2) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/one-contract-per-file.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/one-contract-per-file.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/one-contract-per-file.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/one-contract-per-file.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/one-contract-per-file.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/one-contract-per-file.js) diff --git a/docs/rules/best-practises/payable-fallback.md b/docs/rules/best-practices/payable-fallback.md similarity index 72% rename from docs/rules/best-practises/payable-fallback.md rename to docs/rules/best-practices/payable-fallback.md index ca8d6b5c..3108b87c 100644 --- a/docs/rules/best-practises/payable-fallback.md +++ b/docs/rules/best-practices/payable-fallback.md @@ -6,7 +6,7 @@ title: "payable-fallback | Solhint" # payable-fallback ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -15,7 +15,7 @@ title: "payable-fallback | Solhint" When fallback is not payable and there is no receive function you will not be able to receive currency. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -60,9 +60,9 @@ fallback() {} function g() payable {} ``` ## Version -This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/payable-fallback.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/payable-fallback.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/payable-fallback.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/payable-fallback.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/payable-fallback.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/payable-fallback.js) diff --git a/docs/rules/best-practises/reason-string.md b/docs/rules/best-practices/reason-string.md similarity index 81% rename from docs/rules/best-practises/reason-string.md rename to docs/rules/best-practices/reason-string.md index b919d85e..3b41906f 100644 --- a/docs/rules/best-practises/reason-string.md +++ b/docs/rules/best-practices/reason-string.md @@ -6,7 +6,7 @@ title: "reason-string | Solhint" # reason-string ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Best%20Practice%20Rules-informational) ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. @@ -77,9 +77,9 @@ This rule accepts an array of options: ``` ## Version -This rule was introduced in [Solhint 2.3.1](https://github.com/protofire/solhint/tree/v2.3.1) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/reason-string.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/reason-string.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/reason-string.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/reason-string.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/reason-string.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/reason-string.js) diff --git a/docs/rules/best-practises/custom-errors.md b/docs/rules/best-practises/custom-errors.md deleted file mode 100644 index 18330416..00000000 --- a/docs/rules/best-practises/custom-errors.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -warning: "This is a dynamically generated file. Do not edit manually." -layout: "default" -title: "custom-errors | Solhint" ---- - -# custom-errors -![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) -![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) -> The {"extends": "solhint:recommended"} property in a configuration file enables this rule. - - -## Description -Enforces the use of Custom Errors over Require and Revert statements - -## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. - -### Example Config -```json -{ - "rules": { - "custom-errors": "warn" - } -} -``` - - -## Examples -### 👍 Examples of **correct** code for this rule - -#### Use of Custom Errors - -```solidity -revert CustomErrorFunction(); -``` - -#### Use of Custom Errors with arguments - -```solidity -revert CustomErrorFunction({ msg: "Insufficient Balance" }); -``` - -### 👎 Examples of **incorrect** code for this rule - -#### Use of require statement - -```solidity -require(userBalance >= availableAmount, "Insufficient Balance"); -``` - -#### Use of plain revert statement - -```solidity -revert(); -``` - -#### Use of revert statement with message - -```solidity -revert("Insufficient Balance"); -``` - -## Version -This rule was introduced in [Solhint 3.6.1](https://github.com/protofire/solhint/tree/v3.6.1) - -## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/custom-errors.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/custom-errors.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/custom-errors.js) diff --git a/docs/rules/gas-consumption/gas-calldata-parameters.md b/docs/rules/gas-consumption/gas-calldata-parameters.md index 30223d27..1b022d2e 100644 --- a/docs/rules/gas-consumption/gas-calldata-parameters.md +++ b/docs/rules/gas-consumption/gas-calldata-parameters.md @@ -12,7 +12,7 @@ title: "gas-calldata-parameters | Solhint" Suggest calldata keyword on function arguments when read only ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -33,9 +33,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-calldata-parameters.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-calldata-parameters.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-calldata-parameters.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-calldata-parameters.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-calldata-parameters.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-calldata-parameters.js) diff --git a/docs/rules/gas-consumption/gas-custom-errors.md b/docs/rules/gas-consumption/gas-custom-errors.md index 6f89f6da..1beac5c5 100644 --- a/docs/rules/gas-consumption/gas-custom-errors.md +++ b/docs/rules/gas-consumption/gas-custom-errors.md @@ -12,10 +12,10 @@ title: "gas-custom-errors | Solhint" ## Description -Enforces the use of Custom Errors over Require and Revert statements +Enforces the use of Custom Errors over Require with strings error and Revert statements ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -44,6 +44,24 @@ revert CustomErrorFunction(); revert CustomErrorFunction({ msg: "Insufficient Balance" }); ``` +#### Use of Require with Custom Error with arguments + +```solidity +require(success, CustomErrorFunction({ msg: "Insufficient Balance" }); +``` + +#### Use of Require with function call and Custom Error + +```solidity +require(isAuthorized(account), CustomErrorFunction(); +``` + +#### Use of Require with binary comparison and Custom Error + +```solidity +require(a > b, CustomErrorFunction(); +``` + ### 👎 Examples of **incorrect** code for this rule #### Use of require statement @@ -65,9 +83,9 @@ revert("Insufficient Balance"); ``` ## Version -This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-custom-errors.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-custom-errors.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-custom-errors.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-custom-errors.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-custom-errors.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-custom-errors.js) diff --git a/docs/rules/gas-consumption/gas-increment-by-one.md b/docs/rules/gas-consumption/gas-increment-by-one.md index 97f11c1a..91394e91 100644 --- a/docs/rules/gas-consumption/gas-increment-by-one.md +++ b/docs/rules/gas-consumption/gas-increment-by-one.md @@ -9,10 +9,10 @@ title: "gas-increment-by-one | Solhint" ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) ## Description -Suggest incrementation by one like this ++i instead of other type +Suggest increments by one, like this ++i instead of other type ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -24,7 +24,7 @@ This rule accepts a string option of rule severity. Must be one of "error", "war ``` ### Notes -- This rule only works for expressions like this: [ j = j + 1 ] but will fail is the code is written like this: [ j = 1 + j ] +- This rule only works for expressions like this: [ j = j + 1 ] but will fail if the code is written like this: [ j = 1 + j ] - [source 1](https://coinsbench.com/comprehensive-guide-tips-and-tricks-for-gas-optimization-in-solidity-5380db734404) of the rule initiative (Incrementing/Decrementing By 1) - [source 2](https://www.rareskills.io/post/gas-optimization?postId=c9db474a-ff97-4fa3-a51d-fe13ccb8fe3b#viewer-8rekj) of the rule initiative @@ -32,9 +32,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-increment-by-one.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-increment-by-one.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-increment-by-one.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-increment-by-one.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-increment-by-one.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-increment-by-one.js) diff --git a/docs/rules/gas-consumption/gas-indexed-events.md b/docs/rules/gas-consumption/gas-indexed-events.md index 6dbf7e95..e0ff00c9 100644 --- a/docs/rules/gas-consumption/gas-indexed-events.md +++ b/docs/rules/gas-consumption/gas-indexed-events.md @@ -12,7 +12,7 @@ title: "gas-indexed-events | Solhint" Suggest indexed arguments on events for uint, bool and address ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -30,9 +30,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-indexed-events.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-indexed-events.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-indexed-events.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-indexed-events.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-indexed-events.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-indexed-events.js) diff --git a/docs/rules/gas-consumption/gas-length-in-loops.md b/docs/rules/gas-consumption/gas-length-in-loops.md index 6c58fa17..f9283fd1 100644 --- a/docs/rules/gas-consumption/gas-length-in-loops.md +++ b/docs/rules/gas-consumption/gas-length-in-loops.md @@ -12,7 +12,7 @@ title: "gas-length-in-loops | Solhint" Suggest replacing object.length in a loop condition to avoid calculation on each lap ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -30,9 +30,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-length-in-loops.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-length-in-loops.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-length-in-loops.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-length-in-loops.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-length-in-loops.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-length-in-loops.js) diff --git a/docs/rules/gas-consumption/gas-multitoken1155.md b/docs/rules/gas-consumption/gas-multitoken1155.md index 6e67f5e5..df2ecfe2 100644 --- a/docs/rules/gas-consumption/gas-multitoken1155.md +++ b/docs/rules/gas-consumption/gas-multitoken1155.md @@ -12,7 +12,7 @@ title: "gas-multitoken1155 | Solhint" ERC1155 is a cheaper non-fungible token than ERC721 ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -30,9 +30,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-multitoken1155.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-multitoken1155.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-multitoken1155.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-multitoken1155.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-multitoken1155.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-multitoken1155.js) diff --git a/docs/rules/gas-consumption/gas-named-return-values.md b/docs/rules/gas-consumption/gas-named-return-values.md index aea699d1..d0deeb5f 100644 --- a/docs/rules/gas-consumption/gas-named-return-values.md +++ b/docs/rules/gas-consumption/gas-named-return-values.md @@ -12,7 +12,7 @@ title: "gas-named-return-values | Solhint" Enforce the return values of a function to be named ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -42,9 +42,9 @@ function checkBalance(address wallet) external view returns(uint256) {} ``` ## Version -This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-named-return-values.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-named-return-values.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-named-return-values.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-named-return-values.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-named-return-values.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-named-return-values.js) diff --git a/docs/rules/gas-consumption/gas-small-strings.md b/docs/rules/gas-consumption/gas-small-strings.md index b8d3d3b0..d2e976e8 100644 --- a/docs/rules/gas-consumption/gas-small-strings.md +++ b/docs/rules/gas-consumption/gas-small-strings.md @@ -12,7 +12,7 @@ title: "gas-small-strings | Solhint" Keep strings smaller than 32 bytes ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -30,9 +30,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-small-strings.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-small-strings.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-small-strings.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-small-strings.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-small-strings.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-small-strings.js) diff --git a/docs/rules/gas-consumption/gas-strict-inequalities.md b/docs/rules/gas-consumption/gas-strict-inequalities.md index 5c12a0fb..ece15f03 100644 --- a/docs/rules/gas-consumption/gas-strict-inequalities.md +++ b/docs/rules/gas-consumption/gas-strict-inequalities.md @@ -12,7 +12,7 @@ title: "gas-strict-inequalities | Solhint" Suggest Strict Inequalities over non Strict ones ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -32,9 +32,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-strict-inequalities.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-strict-inequalities.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-strict-inequalities.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-strict-inequalities.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-strict-inequalities.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-strict-inequalities.js) diff --git a/docs/rules/gas-consumption/gas-struct-packing.md b/docs/rules/gas-consumption/gas-struct-packing.md index 5c350e3a..313edfc1 100644 --- a/docs/rules/gas-consumption/gas-struct-packing.md +++ b/docs/rules/gas-consumption/gas-struct-packing.md @@ -12,7 +12,7 @@ title: "gas-struct-packing | Solhint" Suggest to re-arrange struct packing order when it is inefficient ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -32,9 +32,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 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/blob/v4.5.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-struct-packing.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-struct-packing.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-struct-packing.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/gas-consumption/gas-struct-packing.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/gas-consumption/gas-struct-packing.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/gas-consumption/gas-struct-packing.js) diff --git a/docs/rules/gas-consumption/named-return-values.md b/docs/rules/gas-consumption/named-return-values.md deleted file mode 100644 index 0c5ce0b8..00000000 --- a/docs/rules/gas-consumption/named-return-values.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -warning: "This is a dynamically generated file. Do not edit manually." -layout: "default" -title: "named-return-values | Solhint" ---- - -# named-return-values -![Category Badge](https://img.shields.io/badge/-Gas%20Consumption%20Rules-informational) -![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) - -## Description -Enforce the return values of a function to be named - -## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. - -### Example Config -```json -{ - "rules": { - "named-return-values": "warn" - } -} -``` - - -## Examples -### 👍 Examples of **correct** code for this rule - -#### Function definition with named return values - -```solidity -function checkBalance(address wallet) external view returns(uint256 retBalance) {} -``` - -### 👎 Examples of **incorrect** code for this rule - -#### Function definition with UNNAMED return values - -```solidity -function checkBalance(address wallet) external view returns(uint256) {} -``` - -## Version -This rule is introduced in the latest version. - -## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/gas-consumption/gas-named-return-values.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/gas-consumption/gas-named-return-values.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/gas-consumption/gas-named-return-values.js) diff --git a/docs/rules/miscellaneous/comprehensive-interface.md b/docs/rules/miscellaneous/comprehensive-interface.md index 6ec24fcd..6e5b6ec3 100644 --- a/docs/rules/miscellaneous/comprehensive-interface.md +++ b/docs/rules/miscellaneous/comprehensive-interface.md @@ -9,10 +9,10 @@ title: "comprehensive-interface | Solhint" ![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) ## Description -Check that all public or external functions are override. This is iseful to make sure that the whole API is extracted in an interface. +Check that all public or external functions are overridden. This is useful to make sure that the whole API is extracted in an interface. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -52,9 +52,9 @@ contract Foo { ``` ## Version -This rule was introduced in [Solhint 3.3.0](https://github.com/protofire/solhint/tree/v3.3.0) +This rule was introduced in [Solhint 3.3.0](https://github.com/protofire/solhint/blob/v3.3.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/miscellaneous/comprehensive-interface.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/miscellaneous/comprehensive-interface.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/miscellaneous/comprehensive-interface.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/miscellaneous/comprehensive-interface.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/miscellaneous/comprehensive-interface.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/miscellaneous/comprehensive-interface.js) diff --git a/docs/rules/miscellaneous/quotes.md b/docs/rules/miscellaneous/quotes.md index d2a0134b..54e9e07b 100644 --- a/docs/rules/miscellaneous/quotes.md +++ b/docs/rules/miscellaneous/quotes.md @@ -105,9 +105,9 @@ string private constant STR = 'You shall "pass" !'; ``` ## Version -This rule was introduced in [Solhint 1.4.0](https://github.com/protofire/solhint/tree/v1.4.0) +This rule was introduced in [Solhint 1.4.0](https://github.com/protofire/solhint/blob/v1.4.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/miscellaneous/quotes.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/miscellaneous/quotes.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/miscellaneous/quotes.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/miscellaneous/quotes.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/miscellaneous/quotes.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/miscellaneous/quotes.js) diff --git a/docs/rules/naming/const-name-snakecase.md b/docs/rules/naming/const-name-snakecase.md index fc5cb3ac..ae148cb8 100644 --- a/docs/rules/naming/const-name-snakecase.md +++ b/docs/rules/naming/const-name-snakecase.md @@ -15,7 +15,7 @@ title: "const-name-snakecase | Solhint" Constant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming) ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/const-name-snakecase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/const-name-snakecase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/const-name-snakecase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/const-name-snakecase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/const-name-snakecase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/const-name-snakecase.js) diff --git a/docs/rules/naming/contract-name-camelcase.md b/docs/rules/naming/contract-name-camelcase.md index 03fca320..eba5d37d 100644 --- a/docs/rules/naming/contract-name-camelcase.md +++ b/docs/rules/naming/contract-name-camelcase.md @@ -15,7 +15,7 @@ title: "contract-name-camelcase | Solhint" Contract, Structs and Enums should be in CamelCase. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -34,9 +34,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/contract-name-camelcase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/contract-name-camelcase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/contract-name-camelcase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/contract-name-camelcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/contract-name-camelcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/contract-name-camelcase.js) diff --git a/docs/rules/naming/contract-name-capwords.md b/docs/rules/naming/contract-name-capwords.md new file mode 100644 index 00000000..acdbf7b7 --- /dev/null +++ b/docs/rules/naming/contract-name-capwords.md @@ -0,0 +1,42 @@ +--- +warning: "This is a dynamically generated file. Do not edit manually." +layout: "default" +title: "contract-name-capwords | Solhint" +--- + +# contract-name-capwords +![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) +![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational) +![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) +> The {"extends": "solhint:recommended"} property in a configuration file enables this rule. + + +## Description +Contract, Structs and Enums should be in CapWords. + +## Options +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. + +### Example Config +```json +{ + "rules": { + "contract-name-capwords": "warn" + } +} +``` + +### Notes +- Solhint allows this rule to automatically fix the code with `--fix` option +- The FIX will only change first letter and remove underscores + +## 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/naming/contract-name-capwords.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/contract-name-capwords.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/contract-name-capwords.js) diff --git a/docs/rules/naming/contract-name-pascalcase.md b/docs/rules/naming/contract-name-pascalcase.md new file mode 100644 index 00000000..d5463638 --- /dev/null +++ b/docs/rules/naming/contract-name-pascalcase.md @@ -0,0 +1,42 @@ +--- +warning: "This is a dynamically generated file. Do not edit manually." +layout: "default" +title: "contract-name-pascalcase | Solhint" +--- + +# contract-name-pascalcase +![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) +![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational) +![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) +> The {"extends": "solhint:recommended"} property in a configuration file enables this rule. + + +## Description +Contract, Structs and Enums should be in PascalCase. + +## Options +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. + +### Example Config +```json +{ + "rules": { + "contract-name-pascalcase": "warn" + } +} +``` + +### Notes +- Solhint allows this rule to automatically fix the code with `--fix` option +- The FIX will only change first letter and remove underscores + +## 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/naming/contract-name-pascalcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/contract-name-pascalcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/contract-name-pascalcase.js) diff --git a/docs/rules/naming/event-name-camelcase.md b/docs/rules/naming/event-name-camelcase.md index a6c00b63..91f18d97 100644 --- a/docs/rules/naming/event-name-camelcase.md +++ b/docs/rules/naming/event-name-camelcase.md @@ -15,7 +15,7 @@ title: "event-name-camelcase | Solhint" Event name must be in CamelCase. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -34,9 +34,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/event-name-camelcase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/event-name-camelcase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/event-name-camelcase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/event-name-camelcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/event-name-camelcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/event-name-camelcase.js) diff --git a/docs/rules/naming/event-name-capwords.md b/docs/rules/naming/event-name-capwords.md new file mode 100644 index 00000000..8eb29be1 --- /dev/null +++ b/docs/rules/naming/event-name-capwords.md @@ -0,0 +1,42 @@ +--- +warning: "This is a dynamically generated file. Do not edit manually." +layout: "default" +title: "event-name-capwords | Solhint" +--- + +# event-name-capwords +![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) +![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational) +![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) +> The {"extends": "solhint:recommended"} property in a configuration file enables this rule. + + +## Description +Event name must be in CapWords. + +## Options +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. + +### Example Config +```json +{ + "rules": { + "event-name-capwords": "warn" + } +} +``` + +### Notes +- Solhint allows this rule to automatically fix the code with `--fix` option +- The FIX will only change first letter and remove underscores + +## 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/naming/event-name-capwords.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/event-name-capwords.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/event-name-capwords.js) diff --git a/docs/rules/naming/event-name-pascalcase.md b/docs/rules/naming/event-name-pascalcase.md new file mode 100644 index 00000000..0b798a8b --- /dev/null +++ b/docs/rules/naming/event-name-pascalcase.md @@ -0,0 +1,42 @@ +--- +warning: "This is a dynamically generated file. Do not edit manually." +layout: "default" +title: "event-name-pascalcase | Solhint" +--- + +# event-name-pascalcase +![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) +![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational) +![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) +> The {"extends": "solhint:recommended"} property in a configuration file enables this rule. + + +## Description +Event name must be in PascalCase. + +## Options +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. + +### Example Config +```json +{ + "rules": { + "event-name-pascalcase": "warn" + } +} +``` + +### Notes +- Solhint allows this rule to automatically fix the code with `--fix` option +- The FIX will only change first letter and remove underscores + +## 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/naming/event-name-pascalcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/event-name-pascalcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/event-name-pascalcase.js) diff --git a/docs/rules/naming/foundry-test-functions.md b/docs/rules/naming/foundry-test-functions.md index ff14f06e..6e09f5b4 100644 --- a/docs/rules/naming/foundry-test-functions.md +++ b/docs/rules/naming/foundry-test-functions.md @@ -65,9 +65,9 @@ function numberIs42() public {} ``` ## Version -This rule was introduced in [Solhint 3.6.1](https://github.com/protofire/solhint/tree/v3.6.1) +This rule was introduced in [Solhint 3.6.1](https://github.com/protofire/solhint/blob/v3.6.1) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/foundry-test-functions.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/foundry-test-functions.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/foundry-test-functions.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/foundry-test-functions.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/foundry-test-functions.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/foundry-test-functions.js) diff --git a/docs/rules/naming/func-name-mixedcase.md b/docs/rules/naming/func-name-mixedcase.md index c51e2160..fbd296a3 100644 --- a/docs/rules/naming/func-name-mixedcase.md +++ b/docs/rules/naming/func-name-mixedcase.md @@ -15,7 +15,7 @@ title: "func-name-mixedcase | Solhint" Function name must be in mixedCase. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/func-name-mixedcase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/func-name-mixedcase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/func-name-mixedcase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/func-name-mixedcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/func-name-mixedcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/func-name-mixedcase.js) diff --git a/docs/rules/naming/func-named-parameters.md b/docs/rules/naming/func-named-parameters.md index 88b660f9..b5b0a10c 100644 --- a/docs/rules/naming/func-named-parameters.md +++ b/docs/rules/naming/func-named-parameters.md @@ -66,9 +66,9 @@ functionName(_senderAddress, 1e18, _tokenAddress, _receiverAddress ) ``` ## Version -This rule was introduced in [Solhint 3.5.1](https://github.com/protofire/solhint/tree/v3.5.1) +This rule was introduced in [Solhint 3.5.1](https://github.com/protofire/solhint/blob/v3.5.1) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/func-named-parameters.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/func-named-parameters.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/func-named-parameters.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/func-named-parameters.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/func-named-parameters.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/func-named-parameters.js) diff --git a/docs/rules/naming/func-param-name-mixedcase.md b/docs/rules/naming/func-param-name-mixedcase.md index 3ad19653..1778dc6e 100644 --- a/docs/rules/naming/func-param-name-mixedcase.md +++ b/docs/rules/naming/func-param-name-mixedcase.md @@ -12,7 +12,7 @@ title: "func-param-name-mixedcase | Solhint" Function param name must be in mixedCase. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -28,9 +28,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/func-param-name-mixedcase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/func-param-name-mixedcase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/func-param-name-mixedcase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/func-param-name-mixedcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/func-param-name-mixedcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/func-param-name-mixedcase.js) diff --git a/docs/rules/naming/immutable-vars-naming.md b/docs/rules/naming/immutable-vars-naming.md index a12c2291..d7d301be 100644 --- a/docs/rules/naming/immutable-vars-naming.md +++ b/docs/rules/naming/immutable-vars-naming.md @@ -37,9 +37,9 @@ This rule accepts an array of options: This rule does not have examples. ## Version -This rule was introduced in [Solhint 3.5.1](https://github.com/protofire/solhint/tree/v3.5.1) +This rule was introduced in [Solhint 3.5.1](https://github.com/protofire/solhint/blob/v3.5.1) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/immutable-vars-naming.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/immutable-vars-naming.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/immutable-vars-naming.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/immutable-vars-naming.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/immutable-vars-naming.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/immutable-vars-naming.js) diff --git a/docs/rules/naming/imports-order.md b/docs/rules/naming/imports-order.md index 484934b6..7c668483 100644 --- a/docs/rules/naming/imports-order.md +++ b/docs/rules/naming/imports-order.md @@ -12,7 +12,7 @@ title: "imports-order | Solhint" 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. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -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/tree/v5.0.2) +This rule was introduced in [Solhint 5.0.2](https://github.com/protofire/solhint/blob/v5.0.2) ## 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) +- [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) diff --git a/docs/rules/naming/interface-starts-with-i.md b/docs/rules/naming/interface-starts-with-i.md index b8962f9e..41d163c7 100644 --- a/docs/rules/naming/interface-starts-with-i.md +++ b/docs/rules/naming/interface-starts-with-i.md @@ -12,7 +12,7 @@ title: "interface-starts-with-i | Solhint" Solidity Interfaces names should start with an `I` ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -42,9 +42,9 @@ interface Foo { function foo () external; } ``` ## Version -This rule was introduced in [Solhint 4.5.0](https://github.com/protofire/solhint/tree/v4.5.0) +This rule is introduced in the latest version. ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/interface-starts-with-i.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/interface-starts-with-i.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/interface-starts-with-i.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/best-practices/interface-starts-with-i.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/best-practices/interface-starts-with-i.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/best-practices/interface-starts-with-i.js) diff --git a/docs/rules/naming/modifier-name-mixedcase.md b/docs/rules/naming/modifier-name-mixedcase.md index 23b695ef..aaf23a80 100644 --- a/docs/rules/naming/modifier-name-mixedcase.md +++ b/docs/rules/naming/modifier-name-mixedcase.md @@ -12,7 +12,7 @@ title: "modifier-name-mixedcase | Solhint" Modifier name must be in mixedCase. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -28,9 +28,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/modifier-name-mixedcase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/modifier-name-mixedcase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/modifier-name-mixedcase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/modifier-name-mixedcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/modifier-name-mixedcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/modifier-name-mixedcase.js) diff --git a/docs/rules/naming/named-parameters-mapping.md b/docs/rules/naming/named-parameters-mapping.md index fe793ea6..36f16c7e 100644 --- a/docs/rules/naming/named-parameters-mapping.md +++ b/docs/rules/naming/named-parameters-mapping.md @@ -12,7 +12,7 @@ title: "named-parameters-mapping | Solhint" Solidity v0.8.18 introduced named parameters on the mappings definition. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -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 necessary +#### Main key of mapping is enforced. On nested mappings other names are not necessary ```solidity mapping(address owner => mapping(address => uint256)) public tokenBalances; @@ -77,16 +77,16 @@ mapping(address token => uint256)) public tokenBalances; mapping(address => uint256 balance)) public tokenBalances; ``` -#### No MAIN KEY naming in nested mapping. Other naming are not enforced +#### No MAIN KEY naming in nested mapping. Other names are not enforced ```solidity mapping(address => mapping(address token => uint256 balance)) public tokenBalances; ``` ## Version -This rule was introduced in [Solhint 3.4.0](https://github.com/protofire/solhint/tree/v3.4.0) +This rule was introduced in [Solhint 3.4.0](https://github.com/protofire/solhint/blob/v3.4.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/named-parameters-mapping.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/named-parameters-mapping.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/named-parameters-mapping.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/named-parameters-mapping.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/named-parameters-mapping.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/named-parameters-mapping.js) diff --git a/docs/rules/naming/named-return-values.md b/docs/rules/naming/named-return-values.md deleted file mode 100644 index 660fba64..00000000 --- a/docs/rules/naming/named-return-values.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -warning: "This is a dynamically generated file. Do not edit manually." -layout: "default" -title: "named-return-values | Solhint" ---- - -# named-return-values -![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 -Enforce the return values of a function to be named - -## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. - -### Example Config -```json -{ - "rules": { - "named-return-values": "warn" - } -} -``` - - -## Examples -### 👍 Examples of **correct** code for this rule - -#### Function definition with named return values - -```solidity -function checkBalance(address wallet) external view returns(uint256 retBalance) {} -``` - -### 👎 Examples of **incorrect** code for this rule - -#### Function definition with UNNAMED return values - -```solidity -function checkBalance(address wallet) external view returns(uint256) {} -``` - -## Version -This rule was introduced in [Solhint 3.6.1](https://github.com/protofire/solhint/tree/v3.6.1) - -## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/named-return-values.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/named-return-values.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/named-return-values.js) diff --git a/docs/rules/naming/private-vars-leading-underscore.md b/docs/rules/naming/private-vars-leading-underscore.md index a638d310..909c43cc 100644 --- a/docs/rules/naming/private-vars-leading-underscore.md +++ b/docs/rules/naming/private-vars-leading-underscore.md @@ -90,9 +90,9 @@ uint256 thisIsInternalVariable; ``` ## Version -This rule was introduced in [Solhint 3.0.0-rc.3](https://github.com/protofire/solhint/tree/v3.0.0-rc.3) +This rule was introduced in [Solhint 3.0.0-rc.3](https://github.com/protofire/solhint/blob/v3.0.0-rc.3) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/private-vars-leading-underscore.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/private-vars-leading-underscore.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/private-vars-leading-underscore.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/private-vars-leading-underscore.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/private-vars-leading-underscore.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/private-vars-leading-underscore.js) diff --git a/docs/rules/naming/use-forbidden-name.md b/docs/rules/naming/use-forbidden-name.md index 3776b896..442ea8b9 100644 --- a/docs/rules/naming/use-forbidden-name.md +++ b/docs/rules/naming/use-forbidden-name.md @@ -15,7 +15,7 @@ title: "use-forbidden-name | Solhint" Avoid to use letters 'I', 'l', 'O' as identifiers. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/use-forbidden-name.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/use-forbidden-name.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/use-forbidden-name.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/use-forbidden-name.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/use-forbidden-name.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/use-forbidden-name.js) diff --git a/docs/rules/naming/var-name-mixedcase.md b/docs/rules/naming/var-name-mixedcase.md index 913a62cd..5983f5ea 100644 --- a/docs/rules/naming/var-name-mixedcase.md +++ b/docs/rules/naming/var-name-mixedcase.md @@ -12,10 +12,10 @@ title: "var-name-mixedcase | Solhint" ## Description -Variable name must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming) +Variable names must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming) ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/naming/var-name-mixedcase.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/naming/var-name-mixedcase.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/naming/var-name-mixedcase.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/naming/var-name-mixedcase.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/naming/var-name-mixedcase.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/naming/var-name-mixedcase.js) diff --git a/docs/rules/order/func-order.md b/docs/rules/order/func-order.md index b1b391f5..3eb65f15 100644 --- a/docs/rules/order/func-order.md +++ b/docs/rules/order/func-order.md @@ -15,7 +15,7 @@ title: "func-order | Solhint" Function order is incorrect. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -65,9 +65,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war ``` ## Version -This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/order/func-order.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/order/func-order.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/order/func-order.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/order/func-order.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/order/func-order.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/order/func-order.js) diff --git a/docs/rules/order/imports-on-top.md b/docs/rules/order/imports-on-top.md index 0ac69679..5408c7b4 100644 --- a/docs/rules/order/imports-on-top.md +++ b/docs/rules/order/imports-on-top.md @@ -15,7 +15,7 @@ title: "imports-on-top | Solhint" Import statements must be on top. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/blob/v1.1.5) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/order/imports-on-top.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/order/imports-on-top.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/order/imports-on-top.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/order/imports-on-top.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/order/imports-on-top.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/order/imports-on-top.js) diff --git a/docs/rules/order/ordering.md b/docs/rules/order/ordering.md index 5e0d0092..8779efeb 100644 --- a/docs/rules/order/ordering.md +++ b/docs/rules/order/ordering.md @@ -12,7 +12,7 @@ title: "ordering | Solhint" Check order of elements in file and inside each contract, according to the style guide. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -340,9 +340,9 @@ contract MyContract { ``` ## Version -This rule was introduced in [Solhint 3.2.0](https://github.com/protofire/solhint/tree/v3.2.0) +This rule was introduced in [Solhint 3.2.0](https://github.com/protofire/solhint/blob/v3.2.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/order/ordering.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/order/ordering.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/order/ordering.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/order/ordering.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/order/ordering.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/order/ordering.js) diff --git a/docs/rules/order/visibility-modifier-order.md b/docs/rules/order/visibility-modifier-order.md index 1f4d755f..9f1a2744 100644 --- a/docs/rules/order/visibility-modifier-order.md +++ b/docs/rules/order/visibility-modifier-order.md @@ -15,7 +15,7 @@ title: "visibility-modifier-order | Solhint" Visibility modifier must be first in list of modifiers. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -59,9 +59,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war ``` ## Version -This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/blob/v1.1.5) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/order/visibility-modifier-order.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/order/visibility-modifier-order.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/order/visibility-modifier-order.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/order/visibility-modifier-order.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/order/visibility-modifier-order.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/order/visibility-modifier-order.js) diff --git a/docs/rules/security/avoid-call-value.md b/docs/rules/security/avoid-call-value.md index 2a032333..07e6ced0 100644 --- a/docs/rules/security/avoid-call-value.md +++ b/docs/rules/security/avoid-call-value.md @@ -15,7 +15,7 @@ title: "avoid-call-value | Solhint" Avoid to use ".call.value()()". ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/avoid-call-value.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/avoid-call-value.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/avoid-call-value.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/avoid-call-value.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/avoid-call-value.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/avoid-call-value.js) diff --git a/docs/rules/security/avoid-low-level-calls.md b/docs/rules/security/avoid-low-level-calls.md index eea9d153..11833ac9 100644 --- a/docs/rules/security/avoid-low-level-calls.md +++ b/docs/rules/security/avoid-low-level-calls.md @@ -15,7 +15,7 @@ title: "avoid-low-level-calls | Solhint" Avoid to use low level calls. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -48,9 +48,9 @@ anyAddress.call.value(code)(); ``` ## Version -This rule was introduced in [Solhint 1.1.6](https://github.com/protofire/solhint/tree/v1.1.6) +This rule was introduced in [Solhint 1.1.6](https://github.com/protofire/solhint/blob/v1.1.6) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/avoid-low-level-calls.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/avoid-low-level-calls.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/avoid-low-level-calls.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/avoid-low-level-calls.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/avoid-low-level-calls.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/avoid-low-level-calls.js) diff --git a/docs/rules/security/avoid-sha3.md b/docs/rules/security/avoid-sha3.md index 7947a087..5e9b7016 100644 --- a/docs/rules/security/avoid-sha3.md +++ b/docs/rules/security/avoid-sha3.md @@ -15,7 +15,7 @@ title: "avoid-sha3 | Solhint" Use "keccak256" instead of deprecated "sha3". ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -33,9 +33,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/avoid-sha3.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/avoid-sha3.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/avoid-sha3.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/avoid-sha3.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/avoid-sha3.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/avoid-sha3.js) diff --git a/docs/rules/security/avoid-suicide.md b/docs/rules/security/avoid-suicide.md index 95fa418c..a5a57e83 100644 --- a/docs/rules/security/avoid-suicide.md +++ b/docs/rules/security/avoid-suicide.md @@ -15,7 +15,7 @@ title: "avoid-suicide | Solhint" Use "selfdestruct" instead of deprecated "suicide". ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/avoid-suicide.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/avoid-suicide.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/avoid-suicide.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/avoid-suicide.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/avoid-suicide.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/avoid-suicide.js) diff --git a/docs/rules/security/avoid-throw.md b/docs/rules/security/avoid-throw.md index 5b12fcd7..d83b6bf5 100644 --- a/docs/rules/security/avoid-throw.md +++ b/docs/rules/security/avoid-throw.md @@ -15,7 +15,7 @@ title: "avoid-throw | Solhint" "throw" is deprecated, avoid to use it. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -33,9 +33,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/avoid-throw.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/avoid-throw.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/avoid-throw.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/avoid-throw.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/avoid-throw.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/avoid-throw.js) diff --git a/docs/rules/security/avoid-tx-origin.md b/docs/rules/security/avoid-tx-origin.md index 9e238acc..e4d21d01 100644 --- a/docs/rules/security/avoid-tx-origin.md +++ b/docs/rules/security/avoid-tx-origin.md @@ -15,7 +15,7 @@ title: "avoid-tx-origin | Solhint" Avoid to use tx.origin. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/blob/v1.1.5) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/avoid-tx-origin.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/avoid-tx-origin.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/avoid-tx-origin.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/avoid-tx-origin.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/avoid-tx-origin.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/avoid-tx-origin.js) diff --git a/docs/rules/security/check-send-result.md b/docs/rules/security/check-send-result.md index 18db9a94..efbac6d9 100644 --- a/docs/rules/security/check-send-result.md +++ b/docs/rules/security/check-send-result.md @@ -15,7 +15,7 @@ title: "check-send-result | Solhint" Check result of "send" call. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -54,9 +54,9 @@ x.send(55); ``` ## Version -This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/check-send-result.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/check-send-result.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/check-send-result.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/check-send-result.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/check-send-result.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/check-send-result.js) diff --git a/docs/rules/security/compiler-version.md b/docs/rules/security/compiler-version.md index d7bc39de..5bb37df6 100644 --- a/docs/rules/security/compiler-version.md +++ b/docs/rules/security/compiler-version.md @@ -37,9 +37,9 @@ This rule accepts an array of options: This rule does not have examples. ## Version -This rule was introduced in [Solhint 2.1.0](https://github.com/protofire/solhint/tree/v2.1.0) +This rule was introduced in [Solhint 2.1.0](https://github.com/protofire/solhint/blob/v2.1.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/compiler-version.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/compiler-version.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/compiler-version.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/compiler-version.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/compiler-version.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/compiler-version.js) diff --git a/docs/rules/security/func-visibility.md b/docs/rules/security/func-visibility.md index 97e13645..c85eda84 100644 --- a/docs/rules/security/func-visibility.md +++ b/docs/rules/security/func-visibility.md @@ -55,9 +55,9 @@ function b() { } ``` ## Version -This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/func-visibility.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/func-visibility.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/func-visibility.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/func-visibility.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/func-visibility.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/func-visibility.js) diff --git a/docs/rules/security/mark-callable-contracts.md b/docs/rules/security/mark-callable-contracts.md index 31a12045..56858d97 100644 --- a/docs/rules/security/mark-callable-contracts.md +++ b/docs/rules/security/mark-callable-contracts.md @@ -15,7 +15,7 @@ title: "mark-callable-contracts | Solhint" Explicitly mark all external contracts as trusted or untrusted. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -45,9 +45,9 @@ Bank.withdraw(100); ``` ## Version -This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/mark-callable-contracts.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/mark-callable-contracts.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/mark-callable-contracts.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/mark-callable-contracts.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/mark-callable-contracts.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/mark-callable-contracts.js) diff --git a/docs/rules/security/multiple-sends.md b/docs/rules/security/multiple-sends.md index 122c013d..41b3cb93 100644 --- a/docs/rules/security/multiple-sends.md +++ b/docs/rules/security/multiple-sends.md @@ -15,7 +15,7 @@ title: "multiple-sends | Solhint" Avoid multiple calls of "send" method in single transaction. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/multiple-sends.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/multiple-sends.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/multiple-sends.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/multiple-sends.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/multiple-sends.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/multiple-sends.js) diff --git a/docs/rules/security/no-complex-fallback.md b/docs/rules/security/no-complex-fallback.md index bdd158a9..b2d4410e 100644 --- a/docs/rules/security/no-complex-fallback.md +++ b/docs/rules/security/no-complex-fallback.md @@ -15,7 +15,7 @@ title: "no-complex-fallback | Solhint" Fallback function must be simple. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/no-complex-fallback.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/no-complex-fallback.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/no-complex-fallback.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/no-complex-fallback.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/no-complex-fallback.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/no-complex-fallback.js) diff --git a/docs/rules/security/no-inline-assembly.md b/docs/rules/security/no-inline-assembly.md index 73702de2..b4efa739 100644 --- a/docs/rules/security/no-inline-assembly.md +++ b/docs/rules/security/no-inline-assembly.md @@ -15,7 +15,7 @@ title: "no-inline-assembly | Solhint" Avoid to use inline assembly. It is acceptable only in rare cases. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 1.1.6](https://github.com/protofire/solhint/tree/v1.1.6) +This rule was introduced in [Solhint 1.1.6](https://github.com/protofire/solhint/blob/v1.1.6) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/no-inline-assembly.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/no-inline-assembly.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/no-inline-assembly.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/no-inline-assembly.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/no-inline-assembly.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/no-inline-assembly.js) diff --git a/docs/rules/security/not-rely-on-block-hash.md b/docs/rules/security/not-rely-on-block-hash.md index 234c91d3..35dd82fd 100644 --- a/docs/rules/security/not-rely-on-block-hash.md +++ b/docs/rules/security/not-rely-on-block-hash.md @@ -15,7 +15,7 @@ title: "not-rely-on-block-hash | Solhint" Do not rely on "block.blockhash". Miners can influence its value. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 1.1.6](https://github.com/protofire/solhint/tree/v1.1.6) +This rule was introduced in [Solhint 1.1.6](https://github.com/protofire/solhint/blob/v1.1.6) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/not-rely-on-block-hash.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/not-rely-on-block-hash.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/not-rely-on-block-hash.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/not-rely-on-block-hash.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/not-rely-on-block-hash.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/not-rely-on-block-hash.js) diff --git a/docs/rules/security/not-rely-on-time.md b/docs/rules/security/not-rely-on-time.md index dcc24251..9071e7ed 100644 --- a/docs/rules/security/not-rely-on-time.md +++ b/docs/rules/security/not-rely-on-time.md @@ -12,7 +12,7 @@ title: "not-rely-on-time | Solhint" Avoid making time-based decisions in your business logic. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -28,9 +28,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 1.1.5](https://github.com/protofire/solhint/tree/v1.1.5) +This rule was introduced in [Solhint 1.1.5](https://github.com/protofire/solhint/blob/v1.1.5) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/not-rely-on-time.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/not-rely-on-time.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/not-rely-on-time.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/not-rely-on-time.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/not-rely-on-time.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/not-rely-on-time.js) diff --git a/docs/rules/security/reentrancy.md b/docs/rules/security/reentrancy.md index 569338ba..6cf1388f 100644 --- a/docs/rules/security/reentrancy.md +++ b/docs/rules/security/reentrancy.md @@ -15,7 +15,7 @@ title: "reentrancy | Solhint" Possible reentrancy vulnerabilities. Avoid state changes after transfer. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -139,9 +139,9 @@ This rule accepts a string option of rule severity. Must be one of "error", "war ``` ## Version -This rule was introduced in [Solhint 1.1.6](https://github.com/protofire/solhint/tree/v1.1.6) +This rule was introduced in [Solhint 1.1.6](https://github.com/protofire/solhint/blob/v1.1.6) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/reentrancy.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/reentrancy.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/reentrancy.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/reentrancy.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/reentrancy.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/reentrancy.js) diff --git a/docs/rules/security/state-visibility.md b/docs/rules/security/state-visibility.md index fa81b049..89b4d34a 100644 --- a/docs/rules/security/state-visibility.md +++ b/docs/rules/security/state-visibility.md @@ -15,7 +15,7 @@ title: "state-visibility | Solhint" Explicitly mark visibility of state. ## Options -This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Defaults to warn. ### Example Config ```json @@ -31,9 +31,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 2.0.0-alpha.0](https://github.com/protofire/solhint/tree/v2.0.0-alpha.0) +This rule was introduced in [Solhint 2.0.0-alpha.0](https://github.com/protofire/solhint/blob/v2.0.0-alpha.0) ## Resources -- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/security/state-visibility.js) -- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/security/state-visibility.md) -- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/security/state-visibility.js) +- [Rule source](https://github.com/protofire/solhint/blob/master/lib/rules/security/state-visibility.js) +- [Document source](https://github.com/protofire/solhint/blob/master/docs/rules/security/state-visibility.md) +- [Test cases](https://github.com/protofire/solhint/blob/master/test/rules/security/state-visibility.js) diff --git a/docs/shareable-configs.md b/docs/shareable-configs.md index 8e9edd27..693ab917 100644 --- a/docs/shareable-configs.md +++ b/docs/shareable-configs.md @@ -8,7 +8,7 @@ To use a shareable config, you have to add it to your Solhint configuration: "extends": ["solhint:recommended", "protofire"] ``` -This example shows the two kind of shareable configs that you can use: the ones included with Solhint, that start with `solhint:`, and the ones that you can install from npm. The latter are packages that are prefixed with `solhint-config-`, so in this case the package would be installed doing `npm install solhint-config-protofire` but used as just `protofire` when adding it. +This example shows the two types of shareable configs that you can use: the ones included with Solhint, that start with `solhint:`, and the ones that you can install from npm. The latter are packages that are prefixed with `solhint-config-`, so in this case the package would be installed doing `npm install solhint-config-protofire` but used as just `protofire` when adding it. ## Creating your own shareable config diff --git a/e2e/08-autofix/contract-name-camelcase/.solhint.json b/e2e/08-autofix/contract-name-camelcase/.solhint.json deleted file mode 100644 index 6da8ad19..00000000 --- a/e2e/08-autofix/contract-name-camelcase/.solhint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "contract-name-camelcase": "error" - } -} diff --git a/e2e/08-autofix/contract-name-capwords/.solhint.json b/e2e/08-autofix/contract-name-capwords/.solhint.json new file mode 100644 index 00000000..e1789abb --- /dev/null +++ b/e2e/08-autofix/contract-name-capwords/.solhint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "contract-name-capwords": "error" + } +} diff --git a/e2e/08-autofix/contract-name-camelcase/Foo1.sol b/e2e/08-autofix/contract-name-capwords/Foo1.sol similarity index 100% rename from e2e/08-autofix/contract-name-camelcase/Foo1.sol rename to e2e/08-autofix/contract-name-capwords/Foo1.sol diff --git a/e2e/08-autofix/contract-name-camelcase/Foo1AfterFix.sol b/e2e/08-autofix/contract-name-capwords/Foo1AfterFix.sol similarity index 100% rename from e2e/08-autofix/contract-name-camelcase/Foo1AfterFix.sol rename to e2e/08-autofix/contract-name-capwords/Foo1AfterFix.sol diff --git a/e2e/08-autofix/contract-name-camelcase/Foo1BeforeFix.sol b/e2e/08-autofix/contract-name-capwords/Foo1BeforeFix.sol similarity index 100% rename from e2e/08-autofix/contract-name-camelcase/Foo1BeforeFix.sol rename to e2e/08-autofix/contract-name-capwords/Foo1BeforeFix.sol diff --git a/e2e/08-autofix/event-name-camelcase/.solhint.json b/e2e/08-autofix/event-name-camelcase/.solhint.json deleted file mode 100644 index 7f809bb3..00000000 --- a/e2e/08-autofix/event-name-camelcase/.solhint.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "event-name-camelcase": "error" - } -} diff --git a/e2e/08-autofix/event-name-capwords/.solhint.json b/e2e/08-autofix/event-name-capwords/.solhint.json new file mode 100644 index 00000000..22cb73d9 --- /dev/null +++ b/e2e/08-autofix/event-name-capwords/.solhint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "event-name-capwords": "error" + } +} diff --git a/e2e/08-autofix/event-name-camelcase/Foo1.sol b/e2e/08-autofix/event-name-capwords/Foo1.sol similarity index 100% rename from e2e/08-autofix/event-name-camelcase/Foo1.sol rename to e2e/08-autofix/event-name-capwords/Foo1.sol diff --git a/e2e/08-autofix/event-name-camelcase/Foo1AfterFix.sol b/e2e/08-autofix/event-name-capwords/Foo1AfterFix.sol similarity index 100% rename from e2e/08-autofix/event-name-camelcase/Foo1AfterFix.sol rename to e2e/08-autofix/event-name-capwords/Foo1AfterFix.sol diff --git a/e2e/08-autofix/event-name-camelcase/Foo1BeforeFix.sol b/e2e/08-autofix/event-name-capwords/Foo1BeforeFix.sol similarity index 100% rename from e2e/08-autofix/event-name-camelcase/Foo1BeforeFix.sol rename to e2e/08-autofix/event-name-capwords/Foo1BeforeFix.sol diff --git a/e2e/08-autofix/imports-order/Foo1AfterFix.sol b/e2e/08-autofix/imports-order/Foo1AfterFix.sol index e835d7dd..6e7e8cae 100644 --- a/e2e/08-autofix/imports-order/Foo1AfterFix.sol +++ b/e2e/08-autofix/imports-order/Foo1AfterFix.sol @@ -1,24 +1,24 @@ // 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'; +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() {} diff --git a/e2e/autofix-test.js b/e2e/autofix-test.js index 0b7812ca..f57ae859 100644 --- a/e2e/autofix-test.js +++ b/e2e/autofix-test.js @@ -476,9 +476,9 @@ describe('e2e', function () { }) }) - describe('autofix rule: contract-name-camelcase', () => { + describe('autofix rule: contract-name-capwords', () => { before(function () { - params = retrieveParams('contract-name-camelcase/') + params = retrieveParams('contract-name-capwords/') currentConfig = `${params.path}${params.subpath}.solhint.json` currentFile = `${params.path}${params.subpath}Foo1.sol` beforeFixFile = `${params.path}${params.subpath}Foo1BeforeFix.sol` @@ -522,9 +522,9 @@ describe('e2e', function () { }) }) - describe('autofix rule: event-name-camelcase', () => { + describe('autofix rule: event-name-capwords', () => { before(function () { - params = retrieveParams('event-name-camelcase/') + params = retrieveParams('event-name-capwords/') currentConfig = `${params.path}${params.subpath}.solhint.json` currentFile = `${params.path}${params.subpath}Foo1.sol` beforeFixFile = `${params.path}${params.subpath}Foo1BeforeFix.sol` diff --git a/e2e/pre-commit-hook/.solhint.json b/e2e/pre-commit-hook/.solhint.json new file mode 100644 index 00000000..ce2220e0 --- /dev/null +++ b/e2e/pre-commit-hook/.solhint.json @@ -0,0 +1,3 @@ +{ + "extends": "solhint:recommended" +} diff --git a/e2e/pre-commit-hook/Counter.sol b/e2e/pre-commit-hook/Counter.sol new file mode 100644 index 00000000..087b4069 --- /dev/null +++ b/e2e/pre-commit-hook/Counter.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.26; + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} diff --git a/e2e/pre-commit-hook/test.sh b/e2e/pre-commit-hook/test.sh new file mode 100755 index 00000000..e26554ba --- /dev/null +++ b/e2e/pre-commit-hook/test.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -o errtrace -o nounset -o pipefail -o errexit + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + +# Create temp working directory for mock repo +MOCK_REPO=$(mktemp -d) +if [[ ! "$MOCK_REPO" || ! -d "$MOCK_REPO" ]]; then + echo "Could not create temp dir" + exit 1 +fi +function cleanup { + echo "Deleting temp working directory $MOCK_REPO" + rm -rf "$MOCK_REPO" +} + +trap cleanup EXIT + +# Filling the mock repo +pushd "$MOCK_REPO" >/dev/null || exit 1 +git init --initial-branch=master +git config user.email "test@example.com" +git config user.name "pre-commit test" +cp "$SCRIPT_DIR/.solhint.json" "$SCRIPT_DIR/Counter.sol" . +git add . +git commit -m "Initial commit" + +# Run pre-commit inside the mock repo while referencing the solhint directory, +# where the .pre-commit-hooks.yaml is located. +pre-commit try-repo "$SCRIPT_DIR/../.." solhint --verbose --color=always --all-files diff --git a/lib/common/identifier-naming.js b/lib/common/identifier-naming.js index 970bcc71..368490ae 100644 --- a/lib/common/identifier-naming.js +++ b/lib/common/identifier-naming.js @@ -11,12 +11,12 @@ module.exports = { return !this.isMixedCase(text) }, - isCamelCase(text) { + isCapWords(text) { return match(text, /[A-Z$]+[a-zA-Z0-9$]*/) }, - isNotCamelCase(text) { - return !this.isCamelCase(text) + isNotCapWords(text) { + return !this.isCapWords(text) }, isUpperSnakeCase(text) { diff --git a/lib/rules/best-practises/code-complexity.js b/lib/rules/best-practices/code-complexity.js similarity index 93% rename from lib/rules/best-practises/code-complexity.js rename to lib/rules/best-practices/code-complexity.js index a581462c..5c5731c9 100644 --- a/lib/rules/best-practises/code-complexity.js +++ b/lib/rules/best-practices/code-complexity.js @@ -5,11 +5,11 @@ const ruleId = 'code-complexity' const DEFAULT_SEVERITY = 'warn' const DEFAULT_COMPLEXITY = 7 const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Function has cyclomatic complexity "current" but allowed no more than maxcompl.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, @@ -24,13 +24,13 @@ const meta = { good: [ { description: 'Low code complexity', - code: require('../../../test/fixtures/best-practises/code-complexity-low'), + code: require('../../../test/fixtures/best-practices/code-complexity-low'), }, ], bad: [ { description: 'High code complexity', - code: require('../../../test/fixtures/best-practises/code-complexity-high'), + code: require('../../../test/fixtures/best-practices/code-complexity-high'), }, ], }, diff --git a/lib/rules/best-practises/explicit-types.js b/lib/rules/best-practices/explicit-types.js similarity index 98% rename from lib/rules/best-practises/explicit-types.js rename to lib/rules/best-practices/explicit-types.js index 217132c2..c3137d0e 100644 --- a/lib/rules/best-practises/explicit-types.js +++ b/lib/rules/best-practices/explicit-types.js @@ -12,11 +12,11 @@ let typesToSearch const ruleId = 'explicit-types' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Forbid or enforce explicit types (like uint256) that have an alias (like uint).', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, diff --git a/lib/rules/best-practises/function-max-lines.js b/lib/rules/best-practices/function-max-lines.js similarity index 96% rename from lib/rules/best-practises/function-max-lines.js rename to lib/rules/best-practices/function-max-lines.js index e0fdaddc..1b4e7def 100644 --- a/lib/rules/best-practises/function-max-lines.js +++ b/lib/rules/best-practices/function-max-lines.js @@ -5,11 +5,11 @@ const DEFAULT_SEVERITY = 'warn' const DEFAULT_MAX_LINES_COUNT = 50 const ruleId = 'function-max-lines' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Function body contains "count" lines but allowed no more than maxlines.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, diff --git a/lib/rules/best-practises/index.js b/lib/rules/best-practices/index.js similarity index 100% rename from lib/rules/best-practises/index.js rename to lib/rules/best-practices/index.js diff --git a/lib/rules/best-practises/interface-starts-with-i.js b/lib/rules/best-practices/interface-starts-with-i.js similarity index 100% rename from lib/rules/best-practises/interface-starts-with-i.js rename to lib/rules/best-practices/interface-starts-with-i.js diff --git a/lib/rules/best-practises/max-line-length.js b/lib/rules/best-practices/max-line-length.js similarity index 95% rename from lib/rules/best-practises/max-line-length.js rename to lib/rules/best-practices/max-line-length.js index 749bd4fb..21a99ce1 100644 --- a/lib/rules/best-practises/max-line-length.js +++ b/lib/rules/best-practices/max-line-length.js @@ -7,11 +7,11 @@ const ruleId = 'max-line-length' const DEFAULT_SEVERITY = 'error' const DEFAULT_MAX_LINE_LENGTH = 120 const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Line length must be no more than maxlen.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, diff --git a/lib/rules/best-practises/max-states-count.js b/lib/rules/best-practices/max-states-count.js similarity index 91% rename from lib/rules/best-practises/max-states-count.js rename to lib/rules/best-practices/max-states-count.js index b2ff5cb9..b5104515 100644 --- a/lib/rules/best-practises/max-states-count.js +++ b/lib/rules/best-practices/max-states-count.js @@ -6,12 +6,12 @@ const ruleId = 'max-states-count' const DEFAULT_SEVERITY = 'warn' const DEFAULT_MAX_STATES_COUNT = 15 const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Contract has "some count" states declarations but allowed no more than maxstates.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, @@ -26,13 +26,13 @@ const meta = { good: [ { description: 'Low number of states', - code: require('../../../test/fixtures/best-practises/number-of-states-low'), + code: require('../../../test/fixtures/best-practices/number-of-states-low'), }, ], bad: [ { description: 'High number of states', - code: require('../../../test/fixtures/best-practises/number-of-states-high'), + code: require('../../../test/fixtures/best-practices/number-of-states-high'), }, ], }, diff --git a/lib/rules/best-practises/no-console.js b/lib/rules/best-practices/no-console.js similarity index 97% rename from lib/rules/best-practises/no-console.js rename to lib/rules/best-practices/no-console.js index 1a8a0fa9..01d505ec 100644 --- a/lib/rules/best-practises/no-console.js +++ b/lib/rules/best-practices/no-console.js @@ -2,11 +2,11 @@ const BaseChecker = require('../base-checker') const ruleId = 'no-console' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', examples: { bad: [ { diff --git a/lib/rules/best-practises/no-empty-blocks.js b/lib/rules/best-practices/no-empty-blocks.js similarity index 97% rename from lib/rules/best-practises/no-empty-blocks.js rename to lib/rules/best-practices/no-empty-blocks.js index a8c81bf7..4816bc57 100644 --- a/lib/rules/best-practises/no-empty-blocks.js +++ b/lib/rules/best-practices/no-empty-blocks.js @@ -3,11 +3,11 @@ const { isFallbackFunction, isReceiveFunction } = require('../../common/ast-type const ruleId = 'no-empty-blocks' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Code block has zero statements inside. Exceptions apply.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', examples: { bad: [ { description: 'Empty block on if statement', code: 'if (condition) { }' }, diff --git a/lib/rules/best-practises/no-global-import.js b/lib/rules/best-practices/no-global-import.js similarity index 95% rename from lib/rules/best-practises/no-global-import.js rename to lib/rules/best-practices/no-global-import.js index a4e337ac..6b0f71cb 100644 --- a/lib/rules/best-practises/no-global-import.js +++ b/lib/rules/best-practices/no-global-import.js @@ -2,11 +2,11 @@ const BaseChecker = require('../base-checker') const ruleId = 'no-global-import' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Import statement includes an entire file instead of selected symbols.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', examples: { bad: [ { description: 'import all members from a file', code: 'import * from "foo.sol"' }, diff --git a/lib/rules/best-practises/no-unused-import.js b/lib/rules/best-practices/no-unused-import.js similarity index 97% rename from lib/rules/best-practises/no-unused-import.js rename to lib/rules/best-practices/no-unused-import.js index 297875ff..5b4c7702 100644 --- a/lib/rules/best-practises/no-unused-import.js +++ b/lib/rules/best-practices/no-unused-import.js @@ -3,11 +3,11 @@ const BaseChecker = require('../base-checker') const ruleId = 'no-unused-import' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Imported object name is not being used by the contract.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', examples: { good: [ { diff --git a/lib/rules/best-practises/no-unused-vars.js b/lib/rules/best-practices/no-unused-vars.js similarity index 98% rename from lib/rules/best-practises/no-unused-vars.js rename to lib/rules/best-practices/no-unused-vars.js index 76cee5c5..939ec37f 100644 --- a/lib/rules/best-practises/no-unused-vars.js +++ b/lib/rules/best-practices/no-unused-vars.js @@ -6,11 +6,11 @@ const traversing = new TreeTraversing() const ruleId = 'no-unused-vars' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Variable "name" is unused.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', }, isDefault: false, diff --git a/lib/rules/best-practises/one-contract-per-file.js b/lib/rules/best-practices/one-contract-per-file.js similarity index 94% rename from lib/rules/best-practises/one-contract-per-file.js rename to lib/rules/best-practices/one-contract-per-file.js index 51cdf004..cadd1cd5 100644 --- a/lib/rules/best-practises/one-contract-per-file.js +++ b/lib/rules/best-practices/one-contract-per-file.js @@ -5,12 +5,12 @@ const DEFAULT_SEVERITY = 'warn' const ruleId = 'one-contract-per-file' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: '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)', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, diff --git a/lib/rules/best-practises/payable-fallback.js b/lib/rules/best-practices/payable-fallback.js similarity index 97% rename from lib/rules/best-practises/payable-fallback.js rename to lib/rules/best-practices/payable-fallback.js index 6655bace..bc0b87a0 100644 --- a/lib/rules/best-practises/payable-fallback.js +++ b/lib/rules/best-practices/payable-fallback.js @@ -2,12 +2,12 @@ const BaseChecker = require('../base-checker') const ruleId = 'payable-fallback' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'When fallback is not payable and there is no receive function you will not be able to receive currency.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', examples: { good: [ { diff --git a/lib/rules/best-practises/reason-string.js b/lib/rules/best-practices/reason-string.js similarity index 94% rename from lib/rules/best-practises/reason-string.js rename to lib/rules/best-practices/reason-string.js index 33b44a2f..aff4b1fa 100644 --- a/lib/rules/best-practises/reason-string.js +++ b/lib/rules/best-practices/reason-string.js @@ -8,12 +8,12 @@ const DEFAULT_OPTION = { maxLength: DEFAULT_MAX_CHARACTERS_LONG } const ruleId = 'reason-string' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Require or revert statement must have a reason string and check that each reason string is at most N characters long.', - category: 'Best Practise Rules', + category: 'Best Practice Rules', options: [ { description: severityDescription, @@ -29,13 +29,13 @@ const meta = { good: [ { description: 'Require with reason string', - code: require('../../../test/fixtures/best-practises/require-with-reason'), + code: require('../../../test/fixtures/best-practices/require-with-reason'), }, ], bad: [ { description: 'Require without reason string', - code: require('../../../test/fixtures/best-practises/require-without-reason'), + code: require('../../../test/fixtures/best-practices/require-without-reason'), }, ], }, diff --git a/lib/rules/deprecations/constructor-syntax.js b/lib/rules/deprecations/constructor-syntax.js index 9129ebf8..cb569a84 100644 --- a/lib/rules/deprecations/constructor-syntax.js +++ b/lib/rules/deprecations/constructor-syntax.js @@ -2,11 +2,11 @@ const BaseDeprecation = require('./base-deprecation') const ruleId = 'constructor-syntax' const meta = { - type: 'best-practises', + type: 'best-practices', docs: { description: 'Constructors should use the new constructor keyword.', - category: 'Best Practise Rules', + category: 'Best Practices Rules', }, isDefault: false, diff --git a/lib/rules/gas-consumption/gas-custom-errors.js b/lib/rules/gas-consumption/gas-custom-errors.js index f6ed21e2..577de5ab 100644 --- a/lib/rules/gas-consumption/gas-custom-errors.js +++ b/lib/rules/gas-consumption/gas-custom-errors.js @@ -9,7 +9,8 @@ const meta = { type: 'gas-consumption', docs: { - description: 'Enforces the use of Custom Errors over Require and Revert statements', + description: + 'Enforces the use of Custom Errors over Require with strings error and Revert statements', category: 'Gas Consumption Rules', options: [ { @@ -32,6 +33,18 @@ const meta = { description: 'Use of Custom Errors with arguments', code: 'revert CustomErrorFunction({ msg: "Insufficient Balance" });', }, + { + description: 'Use of Require with Custom Error with arguments', + code: 'require(success, CustomErrorFunction({ msg: "Insufficient Balance" });', + }, + { + description: 'Use of Require with function call and Custom Error', + code: 'require(isAuthorized(account), CustomErrorFunction();', + }, + { + description: 'Use of Require with binary comparison and Custom Error', + code: 'require(a > b, CustomErrorFunction();', + }, ], bad: [ { @@ -75,9 +88,9 @@ class GasCustomErrorsChecker extends BaseChecker { FunctionCall(node) { let errorStr = '' - if (this.isVersionGreater(node)) { - if (node.expression.name === 'require') { + // added second part of conditional to be able to use require with Custom Errors + if (node.expression.name === 'require' && node.arguments[1].type !== 'FunctionCall') { errorStr = 'require' } else if ( node.expression.name === 'revert' && diff --git a/lib/rules/gas-consumption/gas-increment-by-one.js b/lib/rules/gas-consumption/gas-increment-by-one.js index 74fc8a51..02fdbc55 100644 --- a/lib/rules/gas-consumption/gas-increment-by-one.js +++ b/lib/rules/gas-consumption/gas-increment-by-one.js @@ -6,11 +6,11 @@ const meta = { type: 'gas-consumption', docs: { - description: 'Suggest incrementation by one like this ++i instead of other type', + description: 'Suggest increments by one, like this ++i instead of other type', category: 'Gas Consumption Rules', notes: [ { - note: 'This rule only works for expressions like this: [ j = j + 1 ] but will fail is the code is written like this: [ j = 1 + j ]', + note: 'This rule only works for expressions like this: [ j = j + 1 ] but will fail if the code is written like this: [ j = 1 + j ]', }, { note: '[source 1](https://coinsbench.com/comprehensive-guide-tips-and-tricks-for-gas-optimization-in-solidity-5380db734404) of the rule initiative (Incrementing/Decrementing By 1)', diff --git a/lib/rules/index.js b/lib/rules/index.js index c423db5f..b9f4e245 100644 --- a/lib/rules/index.js +++ b/lib/rules/index.js @@ -3,7 +3,7 @@ const _ = require('lodash') const security = require('./security/index') const naming = require('./naming/index') const order = require('./order/index') -const bestPractises = require('./best-practises/index') +const bestPractices = require('./best-practices/index') const deprecations = require('./deprecations/index') const miscellaneous = require('./miscellaneous/index') const gasConsumption = require('./gas-consumption/index') @@ -59,7 +59,7 @@ function coreRules(meta) { const { reporter, config, inputSrc, tokens } = meta return [ - ...bestPractises(reporter, config, inputSrc, tokens), + ...bestPractices(reporter, config, inputSrc, tokens), ...deprecations(reporter), ...miscellaneous(reporter, config, tokens), ...naming(reporter, config), diff --git a/lib/rules/miscellaneous/comprehensive-interface.js b/lib/rules/miscellaneous/comprehensive-interface.js index 1ff4e0de..d61733dd 100644 --- a/lib/rules/miscellaneous/comprehensive-interface.js +++ b/lib/rules/miscellaneous/comprehensive-interface.js @@ -6,7 +6,7 @@ const meta = { docs: { description: - 'Check that all public or external functions are override. This is iseful to make sure that the whole API is extracted in an interface.', + 'Check that all public or external functions are overridden. This is useful to make sure that the whole API is extracted in an interface.', category: 'Miscellaneous', examples: { good: [ diff --git a/lib/rules/naming/contract-name-camelcase.js b/lib/rules/naming/contract-name-capwords.js similarity index 84% rename from lib/rules/naming/contract-name-camelcase.js rename to lib/rules/naming/contract-name-capwords.js index d7fd9de1..3b0f2999 100644 --- a/lib/rules/naming/contract-name-camelcase.js +++ b/lib/rules/naming/contract-name-capwords.js @@ -1,12 +1,12 @@ const BaseChecker = require('../base-checker') const naming = require('../../common/identifier-naming') -const ruleId = 'contract-name-camelcase' +const ruleId = 'contract-name-capwords' const meta = { type: 'naming', docs: { - description: 'Contract, Structs and Enums should be in CamelCase.', + description: 'Contract, Structs and Enums should be in CapWords.', category: 'Style Guide Rules', notes: [ { @@ -25,7 +25,7 @@ const meta = { schema: null, } -class ContractNameCamelcaseChecker extends BaseChecker { +class ContractNameCapWordsChecker extends BaseChecker { constructor(reporter) { super(reporter, ruleId, meta) } @@ -43,7 +43,7 @@ class ContractNameCamelcaseChecker extends BaseChecker { } validateName(node, type) { - if (naming.isNotCamelCase(node.name)) { + if (naming.isNotCapWords(node.name)) { this._error(node, type) } } @@ -73,10 +73,10 @@ class ContractNameCamelcaseChecker extends BaseChecker { _error(node, type) { this.error( node, - 'Contract, Structs and Enums should be in CamelCase', + 'Contract, Structs and Enums should be in CapWords', this.fixStatement(node, type) ) } } -module.exports = ContractNameCamelcaseChecker +module.exports = ContractNameCapWordsChecker diff --git a/lib/rules/naming/event-name-camelcase.js b/lib/rules/naming/event-name-capwords.js similarity index 81% rename from lib/rules/naming/event-name-camelcase.js rename to lib/rules/naming/event-name-capwords.js index aecfca95..b0d31c16 100644 --- a/lib/rules/naming/event-name-camelcase.js +++ b/lib/rules/naming/event-name-capwords.js @@ -1,12 +1,12 @@ const BaseChecker = require('../base-checker') const naming = require('../../common/identifier-naming') -const ruleId = 'event-name-camelcase' +const ruleId = 'event-name-capwords' const meta = { type: 'naming', docs: { - description: 'Event name must be in CamelCase.', + description: 'Event name must be in CapWords.', category: 'Style Guide Rules', notes: [ { @@ -25,7 +25,7 @@ const meta = { schema: null, } -class EventNameCamelcaseChecker extends BaseChecker { +class EventNameCapWordsChecker extends BaseChecker { constructor(reporter) { super(reporter, ruleId, meta) } @@ -53,10 +53,10 @@ class EventNameCamelcaseChecker extends BaseChecker { } EventDefinition(node) { - if (naming.isNotCamelCase(node.name)) { - this.error(node, 'Event name must be in CamelCase', this.fixStatement(node)) + if (naming.isNotCapWords(node.name)) { + this.error(node, 'Event name must be in CapWords', this.fixStatement(node)) } } } -module.exports = EventNameCamelcaseChecker +module.exports = EventNameCapWordsChecker diff --git a/lib/rules/naming/imports-order.js b/lib/rules/naming/imports-order.js index 77807d37..8e298b7e 100644 --- a/lib/rules/naming/imports-order.js +++ b/lib/rules/naming/imports-order.js @@ -91,7 +91,8 @@ class ImportsOrderChecker extends BaseChecker { let currentStart = Math.min(...this.fromContractImports.map((imp) => imp.range[0])) // Prepare replacements changing the range const replacements = this.orderedImports.map((orderedImport) => { - const newText = orderedImport.fullSentence + // replace single quotes by double quotes + const newText = orderedImport.fullSentence.replace(/'/g, '"') const rangeEnd = currentStart + newText.length const replacement = { diff --git a/lib/rules/naming/index.js b/lib/rules/naming/index.js index 2949ad35..9ca600c9 100644 --- a/lib/rules/naming/index.js +++ b/lib/rules/naming/index.js @@ -1,6 +1,6 @@ const ConstNameSnakecaseChecker = require('./const-name-snakecase') -const ContractNameCamelcaseChecker = require('./contract-name-camelcase') -const EventNameCamelcaseChecker = require('./event-name-camelcase') +const ContractNameCapWordsChecker = require('./contract-name-capwords') +const EventNameCapWordsChecker = require('./event-name-capwords') const FuncNameMixedcaseChecker = require('./func-name-mixedcase') const FuncParamNameMixedcaseChecker = require('./func-param-name-mixedcase') const ModifierNameMixedcaseChecker = require('./modifier-name-mixedcase') @@ -16,8 +16,8 @@ const ImportsOrderChecker = require('./imports-order') module.exports = function checkers(reporter, config) { return [ new ConstNameSnakecaseChecker(reporter), - new ContractNameCamelcaseChecker(reporter), - new EventNameCamelcaseChecker(reporter), + new ContractNameCapWordsChecker(reporter), + new EventNameCapWordsChecker(reporter), new FuncNameMixedcaseChecker(reporter), new FuncParamNameMixedcaseChecker(reporter), new ModifierNameMixedcaseChecker(reporter), diff --git a/lib/rules/naming/named-parameters-mapping.js b/lib/rules/naming/named-parameters-mapping.js index a798abc8..63faac39 100644 --- a/lib/rules/naming/named-parameters-mapping.js +++ b/lib/rules/naming/named-parameters-mapping.js @@ -20,7 +20,7 @@ const meta = { }, { description: - 'Main key of mapping is enforced. On nested mappings other naming are not necessary', + 'Main key of mapping is enforced. On nested mappings other names are not necessary', code: 'mapping(address owner => mapping(address => uint256)) public tokenBalances;', }, { @@ -48,7 +48,7 @@ const meta = { code: 'mapping(address => uint256 balance)) public tokenBalances;', }, { - description: 'No MAIN KEY naming in nested mapping. Other naming are not enforced', + description: 'No MAIN KEY naming in nested mapping. Other names are not enforced', code: 'mapping(address => mapping(address token => uint256 balance)) public tokenBalances;', }, ], diff --git a/lib/rules/naming/var-name-mixedcase.js b/lib/rules/naming/var-name-mixedcase.js index 3e9581c3..66d18e18 100644 --- a/lib/rules/naming/var-name-mixedcase.js +++ b/lib/rules/naming/var-name-mixedcase.js @@ -6,7 +6,7 @@ const meta = { type: 'naming', docs: { - description: `Variable name must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming)`, + description: `Variable names must be in mixedCase. (Does not check IMMUTABLES, use immutable-vars-naming)`, category: 'Style Guide Rules', }, diff --git a/package-lock.json b/package-lock.json index 3a57c215..fef8f0d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "solhint", - "version": "4.2.0", + "version": "5.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "solhint", - "version": "4.2.0", + "version": "5.0.4", "license": "MIT", "dependencies": { - "@solidity-parser/parser": "^0.18.0", + "@solidity-parser/parser": "^0.19.0", "ajv": "^6.12.6", "antlr4": "^4.13.1-patch-1", "ast-parents": "^0.0.1", @@ -39,7 +39,6 @@ "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.3", "markdown-table": "^2.0.0", "mocha": "^10.2.0", "mocha-lcov-reporter": "^1.3.0", @@ -852,9 +851,9 @@ } }, "node_modules/@solidity-parser/parser": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.18.0.tgz", - "integrity": "sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA==" + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.19.0.tgz", + "integrity": "sha512-RV16k/qIxW/wWc+mLzV3ARyKUaMUTBy9tOLMzFhtNSKYeTAanQ3a5MudJKf/8arIFnA2L27SNjarQKmFg0w/jA==" }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", @@ -2917,21 +2916,6 @@ "node": ">=10.19.0" } }, - "node_modules/husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true, - "bin": { - "husky": "lib/bin.js" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -6524,9 +6508,9 @@ "integrity": "sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g==" }, "@solidity-parser/parser": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.18.0.tgz", - "integrity": "sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA==" + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.19.0.tgz", + "integrity": "sha512-RV16k/qIxW/wWc+mLzV3ARyKUaMUTBy9tOLMzFhtNSKYeTAanQ3a5MudJKf/8arIFnA2L27SNjarQKmFg0w/jA==" }, "@szmarczak/http-timer": { "version": "5.0.1", @@ -8044,12 +8028,6 @@ "resolve-alpn": "^1.2.0" } }, - "husky": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", - "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", - "dev": true - }, "ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", diff --git a/package.json b/package.json index 74324f37..dcaaa8c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solhint", - "version": "5.0.3", + "version": "5.0.4", "description": "Solidity Code Linter", "main": "lib/index.js", "keywords": [ @@ -22,7 +22,6 @@ "lint": "eslint .", "generate-rulesets": "node scripts/generate-rulesets.js && prettier --write conf/rulesets", "docs": "node scripts/generate-rule-docs.js", - "prepare": "husky install", "prepublishOnly": "npm run lint && npm run test && npm run generate-rulesets" }, "bin": { @@ -35,10 +34,12 @@ "/solhint.js" ], "author": "Ilya Drabenia ", - "contributors": ["Diego Bale "], + "contributors": [ + "Diego Bale " + ], "license": "MIT", "dependencies": { - "@solidity-parser/parser": "^0.18.0", + "@solidity-parser/parser": "^0.19.0", "ajv": "^6.12.6", "antlr4": "^4.13.1-patch-1", "ast-parents": "^0.0.1", @@ -65,7 +66,6 @@ "eslint-config-prettier": "^8.6.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.3", "markdown-table": "^2.0.0", "mocha": "^10.2.0", "mocha-lcov-reporter": "^1.3.0", diff --git a/scripts/check-changes.js b/scripts/check-changes.js new file mode 100644 index 00000000..1aea29e0 --- /dev/null +++ b/scripts/check-changes.js @@ -0,0 +1,28 @@ +const { execSync } = require('child_process'); + +function changed() { + try { + // Run Git commands to check for changes in the lib/rules directory + const diffIndex = execSync('git diff-index --name-only -B -R -M -C HEAD lib/rules').toString().trim(); + const lsFiles = execSync('git ls-files -t -o -m lib/rules').toString().trim(); + + // Return true if there are changes + return diffIndex !== '' || lsFiles !== ''; + } catch (error) { + console.error('Error checking for changes:', error); + return false; + } +} + +if (changed()) { + try { + // Run npm commands if there are changes + execSync('npm run generate-rulesets', { stdio: 'inherit' }); + execSync('npm run docs', { stdio: 'inherit' }); + } catch (error) { + console.error('Error running npm commands:', error); + process.exit(1); + } +} else { + console.log('No changes detected in lib/rules.'); +} \ No newline at end of file diff --git a/scripts/generate-changed.sh b/scripts/generate-changed.sh deleted file mode 100644 index a5b92f58..00000000 --- a/scripts/generate-changed.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -changed() { - git diff-index --name-only -B -R -M -C HEAD lib/rules - git ls-files -t -o -m lib/rules -} - -if [ "$(changed)" != "" ]; then - npm run generate-rulesets - npm run docs -fi diff --git a/scripts/generate-rule-docs.js b/scripts/generate-rule-docs.js index 8b2c9953..5a1733bf 100755 --- a/scripts/generate-rule-docs.js +++ b/scripts/generate-rule-docs.js @@ -151,7 +151,7 @@ function loadOptions(rule) { ${table(optionsTable)} ` } else if (typeof rule.meta.defaultSetup === 'string') { - return `This rule accepts a string option of rule severity. Must be one of ${ruleSeverityEnum}. Default to ${rule.meta.defaultSetup}.` + return `This rule accepts a string option of rule severity. Must be one of ${ruleSeverityEnum}. Defaults to ${rule.meta.defaultSetup}.` } else { throw new Error(`Unhandled type of rule.meta.defaultSetup from rule ${rule.ruleId}`) } @@ -184,7 +184,7 @@ function loadNotes(rule) { function linkToVersion(version) { if (version) { - return `This rule was introduced in [Solhint ${version}](https://github.com/protofire/solhint/tree/v${version})` + return `This rule was introduced in [Solhint ${version}](https://github.com/protofire/solhint/blob/v${version})` } else { return `This rule is introduced in the latest version.` } @@ -192,19 +192,19 @@ function linkToVersion(version) { function linkToSource(rule) { const link = localPathToUri(rule.file) - return `https://github.com/protofire/solhint/tree/master${link}` + return `https://github.com/protofire/solhint/blob/master${link}` } function linkToDocumentSource(rule) { const link = localPathToUri(rule.file) .replace('lib/rules', 'docs/rules') .replace(/\.js$/, '.md') - return `https://github.com/protofire/solhint/tree/master${link}` + return `https://github.com/protofire/solhint/blob/master${link}` } function linkToTestCase(rule) { const link = localPathToUri(rule.file).replace('lib/rules/', '') - return `https://github.com/protofire/solhint/tree/master/test/rules${link}` + return `https://github.com/protofire/solhint/blob/master/test/rules${link}` } function localPathToUri(file) { @@ -283,7 +283,7 @@ ${contents} ## References -- [ConsenSys Guide for Smart Contracts](https://consensys.github.io/smart-contract-best-practices/recommendations/) +- [ConsenSys Guide for Smart Contracts](https://consensys.github.io/smart-contract-best-practices/development-recommendations/) - [Solidity Style Guide](http://solidity.readthedocs.io/en/develop/style-guide.html) ` } diff --git a/test/fixtures/best-practises/--fallback-not-payable.js b/test/fixtures/best-practices/--fallback-not-payable.js similarity index 100% rename from test/fixtures/best-practises/--fallback-not-payable.js rename to test/fixtures/best-practices/--fallback-not-payable.js diff --git a/test/fixtures/best-practises/--fallback-payable.js b/test/fixtures/best-practices/--fallback-payable.js similarity index 100% rename from test/fixtures/best-practises/--fallback-payable.js rename to test/fixtures/best-practices/--fallback-payable.js diff --git a/test/fixtures/best-practises/code-complexity-high.js b/test/fixtures/best-practices/code-complexity-high.js similarity index 100% rename from test/fixtures/best-practises/code-complexity-high.js rename to test/fixtures/best-practices/code-complexity-high.js diff --git a/test/fixtures/best-practises/code-complexity-low.js b/test/fixtures/best-practices/code-complexity-low.js similarity index 100% rename from test/fixtures/best-practises/code-complexity-low.js rename to test/fixtures/best-practices/code-complexity-low.js diff --git a/test/fixtures/best-practises/explicit-types.js b/test/fixtures/best-practices/explicit-types.js similarity index 100% rename from test/fixtures/best-practises/explicit-types.js rename to test/fixtures/best-practices/explicit-types.js diff --git a/test/fixtures/best-practises/number-of-states-high.js b/test/fixtures/best-practices/number-of-states-high.js similarity index 100% rename from test/fixtures/best-practises/number-of-states-high.js rename to test/fixtures/best-practices/number-of-states-high.js diff --git a/test/fixtures/best-practises/number-of-states-low.js b/test/fixtures/best-practices/number-of-states-low.js similarity index 100% rename from test/fixtures/best-practises/number-of-states-low.js rename to test/fixtures/best-practices/number-of-states-low.js diff --git a/test/fixtures/best-practises/one-contract-per-file.js b/test/fixtures/best-practices/one-contract-per-file.js similarity index 100% rename from test/fixtures/best-practises/one-contract-per-file.js rename to test/fixtures/best-practices/one-contract-per-file.js diff --git a/test/fixtures/best-practises/require-with-reason.js b/test/fixtures/best-practices/require-with-reason.js similarity index 100% rename from test/fixtures/best-practises/require-with-reason.js rename to test/fixtures/best-practices/require-with-reason.js diff --git a/test/fixtures/best-practises/require-without-reason.js b/test/fixtures/best-practices/require-without-reason.js similarity index 100% rename from test/fixtures/best-practises/require-without-reason.js rename to test/fixtures/best-practices/require-without-reason.js diff --git a/test/rules/best-practises/code-complexity.js b/test/rules/best-practices/code-complexity.js similarity index 91% rename from test/rules/best-practises/code-complexity.js rename to test/rules/best-practices/code-complexity.js index 5385e554..c0abe289 100644 --- a/test/rules/best-practises/code-complexity.js +++ b/test/rules/best-practices/code-complexity.js @@ -5,7 +5,7 @@ const { assertErrorCount, assertErrorMessage, assertNoErrors } = require('../../ describe('Linter - code-complexity', () => { it('should raise error when cyclomatic complexity of a function is too high', () => { const report = linter.processStr( - funcWith(require('../../fixtures/best-practises/code-complexity-high')), + funcWith(require('../../fixtures/best-practices/code-complexity-high')), { rules: { 'code-complexity': 'error' }, } @@ -17,7 +17,7 @@ describe('Linter - code-complexity', () => { it('should not raise error when cyclomatic complexity of a function is equal to max default allowed', () => { const report = linter.processStr( - funcWith(require('../../fixtures/best-practises/code-complexity-low')), + funcWith(require('../../fixtures/best-practices/code-complexity-low')), { rules: { 'code-complexity': 'error' }, } @@ -28,7 +28,7 @@ describe('Linter - code-complexity', () => { it('should raise error when cyclomatic complexity of a modifier is too high', () => { const report = linter.processStr( - modifierWith(require('../../fixtures/best-practises/code-complexity-high')), + modifierWith(require('../../fixtures/best-practices/code-complexity-high')), { rules: { 'code-complexity': 'error' }, } diff --git a/test/rules/best-practises/explicit-types.js b/test/rules/best-practices/explicit-types.js similarity index 97% rename from test/rules/best-practises/explicit-types.js rename to test/rules/best-practices/explicit-types.js index bdfebd3a..71abdb21 100644 --- a/test/rules/best-practises/explicit-types.js +++ b/test/rules/best-practices/explicit-types.js @@ -1,7 +1,7 @@ const linter = require('../../../lib/index') const contractWith = require('../../common/contract-builder').contractWith const { assertErrorCount, assertNoErrors, assertErrorMessage } = require('../../common/asserts') -const VAR_DECLARATIONS = require('../../fixtures/best-practises/explicit-types') +const VAR_DECLARATIONS = require('../../fixtures/best-practices/explicit-types') const getZeroErrosObject = () => { const zeroErrorsExplicit = {} diff --git a/test/rules/best-practises/function-max-lines.js b/test/rules/best-practices/function-max-lines.js similarity index 100% rename from test/rules/best-practises/function-max-lines.js rename to test/rules/best-practices/function-max-lines.js diff --git a/test/rules/best-practises/interface-starts-with-i.js b/test/rules/best-practices/interface-starts-with-i.js similarity index 100% rename from test/rules/best-practises/interface-starts-with-i.js rename to test/rules/best-practices/interface-starts-with-i.js diff --git a/test/rules/best-practises/max-line-length.js b/test/rules/best-practices/max-line-length.js similarity index 100% rename from test/rules/best-practises/max-line-length.js rename to test/rules/best-practices/max-line-length.js diff --git a/test/rules/best-practises/max-states-count.js b/test/rules/best-practices/max-states-count.js similarity index 92% rename from test/rules/best-practises/max-states-count.js rename to test/rules/best-practices/max-states-count.js index 4a5d354d..8956b71b 100644 --- a/test/rules/best-practises/max-states-count.js +++ b/test/rules/best-practices/max-states-count.js @@ -4,7 +4,7 @@ const { contractWith, stateDef } = require('../../common/contract-builder') describe('Linter - max-states-count', () => { it('should raise error when count of states too big', () => { - const code = require('../../fixtures/best-practises/number-of-states-high') + const code = require('../../fixtures/best-practices/number-of-states-high') const report = linter.processStr(code, { rules: { 'max-states-count': ['error', 15] }, @@ -15,7 +15,7 @@ describe('Linter - max-states-count', () => { }) it('should not raise error for count of states that lower that max', () => { - const code = require('../../fixtures/best-practises/number-of-states-low') + const code = require('../../fixtures/best-practices/number-of-states-low') const report = linter.processStr(code, { rules: { 'max-states-count': 'error' }, diff --git a/test/rules/best-practises/no-console.js b/test/rules/best-practices/no-console.js similarity index 100% rename from test/rules/best-practises/no-console.js rename to test/rules/best-practices/no-console.js diff --git a/test/rules/best-practises/no-empty-blocks.js b/test/rules/best-practices/no-empty-blocks.js similarity index 100% rename from test/rules/best-practises/no-empty-blocks.js rename to test/rules/best-practices/no-empty-blocks.js diff --git a/test/rules/best-practises/no-global-import.js b/test/rules/best-practices/no-global-import.js similarity index 100% rename from test/rules/best-practises/no-global-import.js rename to test/rules/best-practices/no-global-import.js diff --git a/test/rules/best-practises/no-unused-import.js b/test/rules/best-practices/no-unused-import.js similarity index 100% rename from test/rules/best-practises/no-unused-import.js rename to test/rules/best-practices/no-unused-import.js diff --git a/test/rules/best-practises/no-unused-vars.js b/test/rules/best-practices/no-unused-vars.js similarity index 100% rename from test/rules/best-practises/no-unused-vars.js rename to test/rules/best-practices/no-unused-vars.js diff --git a/test/rules/best-practises/one-contract-per-file.js b/test/rules/best-practices/one-contract-per-file.js similarity index 97% rename from test/rules/best-practises/one-contract-per-file.js rename to test/rules/best-practices/one-contract-per-file.js index 86dc782f..0483a39d 100644 --- a/test/rules/best-practises/one-contract-per-file.js +++ b/test/rules/best-practices/one-contract-per-file.js @@ -1,6 +1,6 @@ const { assertNoWarnings, assertErrorMessage, assertErrorCount } = require('../../common/asserts') const linter = require('../../../lib/index') -const contracts = require('../../fixtures/best-practises/one-contract-per-file') +const contracts = require('../../fixtures/best-practices/one-contract-per-file') describe('Linter - one-contract-per-file', () => { it('should not raise error for ONE contract only', () => { diff --git a/test/rules/best-practises/payable-fallback.js b/test/rules/best-practices/payable-fallback.js similarity index 100% rename from test/rules/best-practises/payable-fallback.js rename to test/rules/best-practices/payable-fallback.js diff --git a/test/rules/best-practises/reason-string.js b/test/rules/best-practices/reason-string.js similarity index 96% rename from test/rules/best-practises/reason-string.js rename to test/rules/best-practices/reason-string.js index 30546d7b..9b8aafc3 100644 --- a/test/rules/best-practises/reason-string.js +++ b/test/rules/best-practices/reason-string.js @@ -11,7 +11,7 @@ const { funcWith } = require('../../common/contract-builder') describe('Linter - reason-string', () => { it('should raise reason string is mandatory for require', () => { - const code = require('../../fixtures/best-practises/require-without-reason') + const code = require('../../fixtures/best-practices/require-without-reason') const report = linter.processStr(code, { rules: { 'reason-string': ['warn', { maxLength: 5 }] }, @@ -65,7 +65,7 @@ describe('Linter - reason-string', () => { }) it('should not raise warning for require', () => { - const code = require('../../fixtures/best-practises/require-with-reason') + const code = require('../../fixtures/best-practices/require-with-reason') const report = linter.processStr(code, { rules: { 'reason-string': ['warn', { maxLength: 31 }] }, diff --git a/test/rules/gas-consumption/gas-custom-errors.js b/test/rules/gas-consumption/gas-custom-errors.js index 0256207a..e2fd0281 100644 --- a/test/rules/gas-consumption/gas-custom-errors.js +++ b/test/rules/gas-consumption/gas-custom-errors.js @@ -17,6 +17,70 @@ function replaceSolidityVersion(code, newVersion) { } describe('Linter - gas-custom-errors', () => { + it('should NOT raise error for require with comparison and custom error()', () => { + let code = funcWith(`require(a > b, CustomErrorEmitted());`) + code = replaceSolidityVersion(code, '^0.8.4') + + const report = linter.processStr(code, { + rules: { 'gas-custom-errors': 'error' }, + }) + + assertNoWarnings(report) + assertNoErrors(report) + }) + + it('should NOT raise error for require with function call and comparison along with custom error', () => { + let code = funcWith(`require(isAok(a) > b, CustomErrorEmitted(param1));`) + code = replaceSolidityVersion(code, '^0.8.4') + + const report = linter.processStr(code, { + rules: { 'gas-custom-errors': 'error' }, + }) + + assertNoWarnings(report) + assertNoErrors(report) + }) + + it('should NOT raise error for require with boolean check and custom error call', () => { + let code = funcWith(`require(success, CustomErrorEmitted(param1, param2));`) + code = replaceSolidityVersion(code, '^0.8.4') + + const report = linter.processStr(code, { + rules: { 'gas-custom-errors': 'error' }, + }) + + assertNoWarnings(report) + assertNoErrors(report) + }) + + it('should NOT raise error for require with function call and custom error call', () => { + let code = funcWith( + `require(isSuccess(param1) == true && value > 10, CustomErrorEmitted(param1, param2));` + ) + code = replaceSolidityVersion(code, '^0.8.4') + + const report = linter.processStr(code, { + rules: { 'gas-custom-errors': 'error' }, + }) + + assertNoWarnings(report) + assertNoErrors(report) + }) + + it('should NOT raise error for require and mapping access with boolean value check and custom error call', () => { + let code = funcWith( + `require(users[msg.sender].isRegistered, CustomErrorEmitted(param1, param2));` + ) + code = replaceSolidityVersion(code, '^0.8.4') + + const report = linter.processStr(code, { + rules: { 'gas-custom-errors': 'error' }, + }) + + assertNoWarnings(report) + assertNoErrors(report) + }) + it('should raise error for revert()', () => { let code = funcWith(`revert();`) code = replaceSolidityVersion(code, '^0.8.4') @@ -30,7 +94,7 @@ describe('Linter - gas-custom-errors', () => { }) it('should raise error for revert([string])', () => { - let code = funcWith(`revert("Insufficent funds");`) + let code = funcWith(`revert("Insufficient funds");`) code = replaceSolidityVersion(code, '0.8.4') const report = linter.processStr(code, { @@ -54,7 +118,7 @@ describe('Linter - gas-custom-errors', () => { }) it('should NOT raise error for revert ErrorFunction() with arguments', () => { - let code = funcWith(`revert ErrorFunction({ msg: "Insufficent funds msg" });`) + let code = funcWith(`revert ErrorFunction({ msg: "Insufficient funds msg" });`) code = replaceSolidityVersion(code, '^0.8.5') const report = linter.processStr(code, { @@ -134,7 +198,7 @@ describe('Linter - gas-custom-errors', () => { }) it('should NOT raise error for lower versions 0.4.4', () => { - const code = funcWith(`revert("Insufficent funds");`) + const code = funcWith(`revert("Insufficient funds");`) const report = linter.processStr(code, { rules: { 'gas-custom-errors': 'error' }, diff --git a/test/rules/naming/contract-name-camelcase.js b/test/rules/naming/contract-name-capwords.js similarity index 80% rename from test/rules/naming/contract-name-camelcase.js rename to test/rules/naming/contract-name-capwords.js index 787816c3..7dea13a2 100644 --- a/test/rules/naming/contract-name-camelcase.js +++ b/test/rules/naming/contract-name-capwords.js @@ -2,38 +2,38 @@ const assert = require('assert') const linter = require('../../../lib/index') const contractWith = require('../../common/contract-builder').contractWith -describe('Linter - contract-name-camelcase', () => { +describe('Linter - contract-name-capwords', () => { it('should raise struct name error', () => { const code = contractWith('struct a {}') const report = linter.processStr(code, { - rules: { 'contract-name-camelcase': 'error' }, + rules: { 'contract-name-capwords': 'error' }, }) assert.equal(report.errorCount, 1) - assert.ok(report.messages[0].message.includes('CamelCase')) + assert.ok(report.messages[0].message.includes('CapWords')) }) it('should raise contract name error', () => { const code = 'contract a {}' const report = linter.processStr(code, { - rules: { 'contract-name-camelcase': 'error' }, + rules: { 'contract-name-capwords': 'error' }, }) assert.equal(report.errorCount, 1) - assert.ok(report.messages[0].message.includes('CamelCase')) + assert.ok(report.messages[0].message.includes('CapWords')) }) it('should raise enum name error', () => { const code = contractWith('enum abc {}') const report = linter.processStr(code, { - rules: { 'contract-name-camelcase': 'error' }, + rules: { 'contract-name-capwords': 'error' }, }) assert.equal(report.errorCount, 1) - assert.ok(report.messages[0].message.includes('CamelCase')) + assert.ok(report.messages[0].message.includes('CapWords')) }) describe('Struct name with $ character', () => { @@ -47,7 +47,7 @@ describe('Linter - contract-name-camelcase', () => { for (const [key, code] of Object.entries(WITH_$)) { it(`should not raise contract name error for Structs ${key}`, () => { const report = linter.processStr(code, { - rules: { 'contract-name-camelcase': 'error' }, + rules: { 'contract-name-capwords': 'error' }, }) assert.equal(report.errorCount, 0) @@ -66,7 +66,7 @@ describe('Linter - contract-name-camelcase', () => { for (const [key, code] of Object.entries(WITH_$)) { it(`should not raise contract name error for Enums ${key}`, () => { const report = linter.processStr(code, { - rules: { 'contract-name-camelcase': 'error' }, + rules: { 'contract-name-capwords': 'error' }, }) assert.equal(report.errorCount, 0) @@ -85,7 +85,7 @@ describe('Linter - contract-name-camelcase', () => { for (const [key, code] of Object.entries(WITH_$)) { it(`should not raise contract name error for Contracts ${key}`, () => { const report = linter.processStr(code, { - rules: { 'contract-name-camelcase': 'error' }, + rules: { 'contract-name-capwords': 'error' }, }) assert.equal(report.errorCount, 0) diff --git a/test/rules/naming/event-name-camelcase.js b/test/rules/naming/event-name-capwords.js similarity index 66% rename from test/rules/naming/event-name-camelcase.js rename to test/rules/naming/event-name-capwords.js index 27bcd05c..3c2990ae 100644 --- a/test/rules/naming/event-name-camelcase.js +++ b/test/rules/naming/event-name-capwords.js @@ -2,16 +2,26 @@ const assert = require('assert') const linter = require('../../../lib/index') const contractWith = require('../../common/contract-builder').contractWith -describe('Linter - event-name-camelcase', () => { +describe('Linter - event-name-capwords', () => { + it('should raise event name error for event in mixedCase', () => { + const code = contractWith('event EventCap(uint a);') + + const report = linter.processStr(code, { + rules: { 'event-name-capwords': 'error' }, + }) + + assert.equal(report.errorCount, 0) + }) + it('should raise event name error for event in mixedCase', () => { const code = contractWith('event event1(uint a);') const report = linter.processStr(code, { - rules: { 'event-name-camelcase': 'error' }, + rules: { 'event-name-capwords': 'error' }, }) assert.equal(report.errorCount, 1) - assert.ok(report.messages[0].message.includes('CamelCase')) + assert.ok(report.messages[0].message.includes('CapWords')) }) describe('Event name with $ character', () => { @@ -25,7 +35,7 @@ describe('Linter - event-name-camelcase', () => { for (const [key, code] of Object.entries(WITH_$)) { it(`should not raise event name error for Events ${key}`, () => { const report = linter.processStr(code, { - rules: { 'event-name-camelcase': 'error' }, + rules: { 'event-name-capwords': 'error' }, }) assert.equal(report.errorCount, 0)