solhint

max-states-count

Recommended Badge Category Badge Default Severity Badge warn

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

Description

Contract has “some count” states declarations but allowed no more than maxstates.

Options

This rule accepts an array of options:

Index Description Default Value
0 Rule severity. Must be one of “error”, “warn”, “off”. warn
1 Maximum allowed number of states declarations 15

Example Config

{
  "rules": {
    "max-states-count": ["warn",15]
  }
}

Examples

👍 Examples of correct code for this rule

Low number of states


      pragma solidity 0.4.4;
        
        
      contract A {
                uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
        uint private constant TEST = 1;
      }
    

👎 Examples of incorrect code for this rule

High number of states


      pragma solidity 0.4.4;
        
        
      contract A {
                uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
        uint private a;
      }
    

Version

This rule was introduced in Solhint 1.1.5

Resources