Skip to content

Commit

Permalink
Exclude abi.encodeX calls from func-named-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCLARITY committed May 23, 2024
1 parent cf6bf43 commit ccffdcb
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/rules/naming/func-named-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const meta = {
description: 'Function call with four NAMED parameters',
code: 'functionName({ sender: _senderAddress, amount: 1e18, token: _tokenAddress, receiver: _receiverAddress })',
},
{
description: 'abi.encodeX call with four UNNAMED parameters',
code: 'abi.encodePacked(_senderAddress, 1e18, _tokenAddress, _receiverAddress )',
},
],
bad: [
{
Expand Down Expand Up @@ -67,12 +71,24 @@ class FunctionNamedParametersChecker extends BaseChecker {
const qtyNamed = node.names.length
const qtyArgs = node.arguments.length

if (qtyArgs !== 0) {
if (qtyNamed === 0 && qtyArgs > this.maxUnnamedArguments) {
this.error(
node,
`Named parameters missing. MIN unnamed argumenst is ${this.maxUnnamedArguments}`
)
if (!this.isAbiCall(node)) {
if (qtyArgs !== 0) {
if (qtyNamed === 0 && qtyArgs > this.maxUnnamedArguments) {
this.error(
node,
`Named parameters missing. MIN unnamed argumenst is ${this.maxUnnamedArguments}`
)
}
}
}
}

isAbiCall(node) {
if (node.expression.type == 'MemberAccess') {

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 16

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on MacOS

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on MacOS

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (16)

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Windows

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (18)

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 18

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Windows

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 20

Expected '===' and instead saw '=='

Check failure on line 87 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (20)

Expected '===' and instead saw '=='
if (node.expression.expression.type == 'Identifier') {

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 16

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on MacOS

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on MacOS

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (16)

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Windows

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (18)

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 18

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Windows

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 20

Expected '===' and instead saw '=='

Check failure on line 88 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (20)

Expected '===' and instead saw '=='
if (node.expression.expression.name == 'abi') {

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 16

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on MacOS

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on MacOS

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (16)

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Windows

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (18)

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 18

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Windows

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Test on Linux with Node 20

Expected '===' and instead saw '=='

Check failure on line 89 in lib/rules/naming/func-named-parameters.js

View workflow job for this annotation

GitHub Actions / Run linter and tests on Linux (20)

Expected '===' and instead saw '=='
return true
}
}
}
}
Expand Down

0 comments on commit ccffdcb

Please sign in to comment.