Skip to content

Commit

Permalink
feat: add solhint
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaan-deepsource committed Dec 22, 2023
1 parent 2451a07 commit daff927
Show file tree
Hide file tree
Showing 38 changed files with 104 additions and 104 deletions.
4 changes: 2 additions & 2 deletions analyzers/solhint/.deepsource/issues/SOLHINT-W1001.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ severity = "minor"
category = "antipattern"
weight = 40
description = """
Function has cyclomatic complexity "current" but allowed no more than maxcompl.
Function has cyclomatic complexity `current` but allowed no more than maxcompl.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. High code complexity
```solidity
if (a > b) {
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1002.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enforces the use of Custom Errors over Require and Revert statements
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Use of require statement
```solidity
require(userBalance >= availableAmount, "Insufficient Balance");
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1003.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Forbid or enforce explicit types (like uint256) that have an alias (like uint).
<!--more-->
## Not Recommended(s)
## Bad Practice
1. If explicit is selected
```solidity
uint public variableName
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1004.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "minor"
category = "antipattern"
weight = 40
description = """
Function body contains "count" lines but allowed no more than maxlines.
Function body contains `count` lines but allowed no more than maxlines.
<!--more-->
Expand Down
4 changes: 2 additions & 2 deletions analyzers/solhint/.deepsource/issues/SOLHINT-W1006.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ severity = "minor"
category = "antipattern"
weight = 40
description = """
Contract has "some count" states declarations but allowed no more than maxstates.
Contract has `some count` states declarations but allowed no more than maxstates.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. High number of states
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1007.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console
<!--more-->
## Not Recommended(s)
## Bad Practice
1. No console.logX statements
```solidity
console.log('test')
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1008.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Code block has zero statements inside. Exceptions apply.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Empty block on if statement
```solidity
if (condition) { }
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1009.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Import statement includes an entire file instead of selected symbols.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. import all members from a file
```solidity
import * from "foo.sol"
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1010.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Imported object name is not being used by the contract.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Imported object is not being used
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1011.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "minor"
category = "antipattern"
weight = 40
description = """
Variable "name" is unused.
Variable `name` is unused.
<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1012.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title = "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)"
title = "Enforces the use of ONE Contract per file"
verbose_name = "one-contract-per-file"
severity = "minor"
category = "antipattern"
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1013.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ When fallback is not payable you will not be able to receive ethers.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Fallback is not payable
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1014.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Require or revert statement must have a reason string and check that each reason
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Require without reason string
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1016.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Check that all public or external functions are override. This is iseful to make
<!--more-->
## Not Recommended(s)
## Bad Practice
1. A public function is not an override
```solidity
pragma solidity ^0.7.0;
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1017.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enforces the use of double or simple quotes as configured for string literals. V
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Configured with single quotes
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1021.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enforce naming convention on functions for Foundry test cases
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Foundry test case with incorrect Function declaration
```solidity
function numberIs42() public {}
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1023.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enforce named parameters for function calls with 4 or more arguments. This rule
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Function call with four UNNAMED parameters (default 4)
```solidity
functionName(_senderAddress, 1e18, _tokenAddress, _receiverAddress )
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1027.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Solidity v0.8.18 introduced named parameters on the mappings definition.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. No naming at all in regular mapping
```solidity
mapping(address => uint256)) public tokenBalances;
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1028.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Enforce the return values of a function to be named
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Function definition with UNNAMED return values
```solidity
function checkBalance(address wallet) external view returns(uint256) {}
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1029.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Non-external functions and state variables should start with a single underscore
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Internal function with incorrect naming
```solidity
function thisIsInternal() internal {}
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1032.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Function order is incorrect.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Constructor is placed after other functions
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1034.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Check order of elements in file and inside each contract, according to the style
<!--more-->
## Not Recommended(s)
## Bad Practice
1. State variable declaration after function
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1035.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Visibility modifier must be first in list of modifiers.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Visibility modifier not placed first
```solidity
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1036.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "major"
category = "security"
weight = 60
description = """
Avoid to use ".call.value()()".
Avoid to use `.call.value()()`.
<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1037.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Avoid to use low level calls.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Using low level calls
```solidity
anyAddress.call(code);
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1038.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "major"
category = "security"
weight = 60
description = """
Use "keccak256" instead of deprecated "sha3".
Use `keccak256` instead of deprecated `sha3`.
<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1039.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "major"
category = "security"
weight = 60
description = """
Use "selfdestruct" instead of deprecated "suicide".
Use `selfdestruct` instead of deprecated `suicide`.
<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1040.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "major"
category = "security"
weight = 60
description = """
"throw" is deprecated, avoid to use it.
`throw` is deprecated, avoid to use it.
<!--more-->
Expand Down
4 changes: 2 additions & 2 deletions analyzers/solhint/.deepsource/issues/SOLHINT-W1042.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ severity = "major"
category = "security"
weight = 60
description = """
Check result of "send" call.
Check result of `send` call.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. result of "send" call ignored
```solidity
x.send(55);
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1044.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Explicitly mark visibility in function.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Functions without explicitly marked visibility
```solidity
function b() { }
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1045.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Explicitly mark all external contracts as trusted or untrusted.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. External contract name without "Trusted" prefix
```solidity
Bank.withdraw(100);
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1046.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "major"
category = "security"
weight = 60
description = """
Avoid multiple calls of "send" method in single transaction.
Avoid multiple calls of `send` method in single transaction.
<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1049.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ severity = "major"
category = "security"
weight = 60
description = """
Do not rely on "block.blockhash". Miners can influence its value.
Do not rely on `block.blockhash`. Miners can influence its value.
<!--more-->
Expand Down
2 changes: 1 addition & 1 deletion analyzers/solhint/.deepsource/issues/SOLHINT-W1051.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Possible reentrancy vulnerabilities. Avoid state changes after transfer.
<!--more-->
## Not Recommended(s)
## Bad Practice
1. Vulnerable Contract 1
```solidity
Expand Down
6 changes: 3 additions & 3 deletions analyzers/solhint/utils/issue_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_toml_content(
) -> str:
"""Return the content of the toml file."""
bad_practice_section = (
f"\n\n## Not Recommended(s)\n{bad_practice}" if bad_practice else ""
f"\n\n## Bad Practice\n{bad_practice}" if bad_practice else ""
)
good_practice_section = (
f"\n\n## Recommended\n{good_practice}" if good_practice else ""
Expand Down Expand Up @@ -62,9 +62,9 @@ def update_issue_tomls() -> None:

filepath = _get_toml_path(issue_code)

title = rule.description.removesuffix(".").replace('"', "`")
title = rule.description.replace('"', "`").removesuffix(".")
wiki_url = rule.wiki_url
description = rule.description
description = rule.description.replace('"', "`")
bad_practice = "\n\n".join(
(
f"{idx}. {bad_example['description']}\n"
Expand Down
4 changes: 2 additions & 2 deletions analyzers/solhint/utils/issue_map_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def get_mapping() -> Dict[str, Dict[str, str]]:
rules = get_all_rules()

if len(rules) > len(issue_map):
# if the no. of issues in the mapping is less than the no. of detectors,
# then generate the mapping only for the new detectors
# if the no. of issues in the mapping is less than the no. of rules,
# then generate the mapping only for the new rules
for rule in rules:
if rule.rule_id not in issue_map:
next_code = next(generate_code)
Expand Down
Loading

0 comments on commit daff927

Please sign in to comment.