Socket
Socket
Sign inDemoInstall

solhint

Package Overview
Dependencies
Maintainers
5
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solhint - npm Package Compare versions

Comparing version 3.3.2 to 3.3.3

5

lib/common/ast-types.js

@@ -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,

20

lib/rules/order/ordering.js
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')

4

package.json
{
"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 {}

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc