solhint

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. 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 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 on 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