Solhint

Solhint

Community Analyzer

Require or revert statement must have a reason string and check that each reason string is at most N characters long SOLHINT-W1014

Anti-pattern
Minor

Require or revert statement must have a reason string and check that each reason string is at most N characters long.

Bad Practice

  1. Require without reason string
    pragma solidity 0.4.4;
    
    
    contract A {
    
      function b() public {
        require(!has(role, account));
        role.bearer[account] = true;
        role.bearer[account] = true;
      }
    
    }
    

Recommended

  1. Require with reason string
    pragma solidity 0.4.4;
    
    
    contract A {
    
      function b() public {
        require(!has(role, account), "Roles: account already has role");
        role.bearer[account] = true;
        role.bearer[account] = true;
      }
    
    }
    

Learn more

reason-string on Solhint's documentation.