solhint-community

no-empty-blocks

Recommended Badge Category Badge Default Severity Badge warn

The {“extends”: “solhint:recommended”} property in a configuration file enables this rule.

Description

Code block has zero statements inside. Some common exceptions apply.

Options

This rule accepts a string option of rule severity. Must be one of “error”, “warn”, “off”. Default to warn.

Example Config

{
  "rules": {
    "no-empty-blocks": "warn"
  }
}

Notes

Examples

👍 Examples of correct code for this rule

empty receive function

receive () external {}

empty fallback function

fallback () external {}

empty constructor with member initialization list

constructor(uint param) Foo(param) Bar(param*2) {}

👎 Examples of incorrect code for this rule

empty block for an if statement

if(condition) {}

empty contract

contract Foo {}

empty block in constructor without parent initialization

constructor () {}

Version

This rule was introduced in Solhint 1.1.5

Resources