Comparing version 3.3.2 to 3.3.3
@@ -5,2 +5,6 @@ function isFallbackFunction(node) { | ||
function isReceiveFunction(node) { | ||
return isFunctionDefinition(node) && node.isReceiveEther | ||
} | ||
function isFunctionDefinition(node) { | ||
@@ -20,2 +24,3 @@ return node.type === 'FunctionDefinition' | ||
isFallbackFunction, | ||
isReceiveFunction, | ||
isFunctionDefinition, | ||
@@ -22,0 +27,0 @@ isStructDefinition, |
const BaseChecker = require('./../base-checker') | ||
const { isFallbackFunction } = require('../../common/ast-types') | ||
const { isFallbackFunction, isReceiveFunction } = require('../../common/ast-types') | ||
@@ -131,4 +131,8 @@ const ruleId = 'ordering' | ||
if (isReceiveFunction(node)) { | ||
return [40, 'receive function'] | ||
} | ||
if (isFallbackFunction(node)) { | ||
return [40, 'fallback function'] | ||
return [50, 'fallback function'] | ||
} | ||
@@ -138,18 +142,18 @@ | ||
if (node.visibility === 'external' && !isConst(node)) { | ||
return [50, 'external function'] | ||
return [60, 'external function'] | ||
} | ||
if (node.visibility === 'external' && isConst(node)) { | ||
return [60, 'external const function'] | ||
return [70, 'external const function'] | ||
} | ||
if (node.visibility === 'public' && !isConst(node)) { | ||
return [70, 'public function'] | ||
return [80, 'public function'] | ||
} | ||
if (node.visibility === 'public' && isConst(node)) { | ||
return [80, 'public const function'] | ||
return [90, 'public const function'] | ||
} | ||
if (node.visibility === 'internal') { | ||
return [90, 'internal function'] | ||
return [100, 'internal function'] | ||
} | ||
if (node.visibility === 'private') { | ||
return [100, 'private function'] | ||
return [110, 'private function'] | ||
} | ||
@@ -156,0 +160,0 @@ throw new Error('Unknown order for function, please report this issue') |
{ | ||
"name": "solhint", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "Solidity Code Linter", | ||
@@ -38,3 +38,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@solidity-parser/parser": "^0.8.2", | ||
"@solidity-parser/parser": "^0.12.0", | ||
"ajv": "^6.6.1", | ||
@@ -41,0 +41,0 @@ "antlr4": "4.7.1", |
@@ -88,4 +88,31 @@ const assert = require('assert') | ||
it('should raise incorrect function order error for fallback before receive', () => { | ||
const code = contractWith(` | ||
fallback() external payable {} | ||
receive() external payable {} | ||
`) | ||
const report = linter.processStr(code, { | ||
rules: { ordering: 'error' } | ||
}) | ||
assert.equal(report.errorCount, 1) | ||
assert.ok(report.messages[0].message.includes('Function order is incorrect')) | ||
}) | ||
it('should not raise incorrect function order error', () => { | ||
const code = contractWith(` | ||
receive() external payable {} | ||
fallback() external payable {} | ||
`) | ||
const report = linter.processStr(code, { | ||
rules: { ordering: 'error' } | ||
}) | ||
assert.equal(report.errorCount, 0) | ||
}) | ||
it('should not raise incorrect function order error', () => { | ||
const code = contractWith(` | ||
function A() public {} | ||
@@ -92,0 +119,0 @@ function () public payable {} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
223562
6523
+ Added@solidity-parser/parser@0.12.2(transitive)
- Removed@solidity-parser/parser@0.8.2(transitive)