rules.md

December 11, 2025 · View on GitHub

Best Practices Rules

Rule IdErrorRecommendedDeprecated
code-complexityFunction has cyclomatic complexity "current" but allowed no more than configured max complexity.
explicit-typesForbid or enforce explicit types (like uint256) that have an alias (like uint).        ~~~~~~~~✔️
function-max-linesFunction body contains "count" lines but allowed no more than maxlines.        ~~~~~~~~✔️
max-line-lengthLine length should not exceed configured number of characters.
max-states-countContract has "some count" states declarations but allowed no more than defined max states.        ~~~~~~~~✔️
no-consoleNo console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements.        ~~~~~~~~✔️
no-empty-blocksCode block has zero statements inside. Exceptions apply.        ~~~~~~~~✔️
no-global-importImport statement includes an entire file instead of selected symbols.        ~~~~~~~~✔️
no-unused-importImported object name is not being used by the contract.        ~~~~~~~~✔️
no-unused-private-funcsPrivate function "name" is not being used within its defining contract. Support overloads.
no-unused-varsVariable "name" is unused.        ~~~~~~~~✔️
one-contract-per-fileEnforces the use of ONE Contract per file see here        ~~~~~~~~✔️
payable-fallbackWhen fallback is not payable and there is no receive function you will not be able to receive currency.
reason-stringRequire or revert statement must have a reason string and check that each reason string is at most N characters long.        ~~~~~~~~✔️
use-natspecEnforces the presence and correctness of NatSpec tags.        ~~~~~~~~✔️
constructor-syntaxConstructors should use the new constructor keyword.        ~~~~~~~~✔️

Style Guide Rules

Rule IdErrorRecommendedDeprecated
interface-starts-with-iSolidity Interfaces names should start with an I        ~~~~~~~~✔️
duplicated-importsCheck if an import is done twice in the same file and there is no alias        ~~~~~~~~✔️
const-name-snakecaseConstant name must be in capitalized SNAKE_CASE. (Does not check IMMUTABLES, use immutable-vars-naming)        ~~~~~~~~✔️
contract-name-capwordsContract, Structs and Enums should be in CapWords.        ~~~~~~~~✔️
event-name-capwordsEvent name must be in CapWords.        ~~~~~~~~✔️
foundry-test-function-namingEnforce naming convention on functions for Foundry test cases
foundry-test-functionsEnforce naming convention on functions for Foundry test cases (DEPRECATED, use foundry-test-functions-naming)
func-name-mixedcaseFunction name must be in mixedCase.        ~~~~~~~~✔️
func-named-parametersEnforce named parameters for function calls with 4 or more arguments. This rule may have some false positives
func-param-name-mixedcaseFunction param name must be in mixedCase.
immutable-vars-namingCheck Immutable variables. Capitalized SNAKE_CASE or mixedCase depending on configuration.        ~~~~~~~~✔️
modifier-name-mixedcaseModifier name must be in mixedCase.
named-parameters-mappingSolidity v0.8.18 introduced named parameters on the mappings definition.
private-vars-leading-underscoreNon-external functions and state variables should start with a single underscore. Others, shouldn't
use-forbidden-nameAvoid to use letters 'I', 'l', 'O' as identifiers.        ~~~~~~~~✔️
var-name-mixedcaseVariable names must be in mixedCase. (Does not check IMMUTABLES nor CONSTANTS (use inherent rules for that)        ~~~~~~~~✔️
imports-on-topImport statements must be on top.        ~~~~~~~~✔️
imports-orderOrder the imports of the contract to follow a certain hierarchy (read "Notes section")
orderingCheck order of elements in file and inside each contract, according to the style guide
visibility-modifier-orderVisibility modifier must be first in list of modifiers.        ~~~~~~~~✔️

Gas Consumption Rules

Rule IdErrorRecommendedDeprecated
gas-calldata-parametersSuggest calldata keyword on function arguments when read only        ~~~~~~~~✔️
gas-custom-errorsEnforces the use of Custom Errors over Require with strings error and Revert statements        ~~~~~~~~✔️
gas-increment-by-oneSuggest increments by one, like this ++i instead of other type        ~~~~~~~~✔️
gas-indexed-eventsSuggest indexed arguments on events for uint, bool and address        ~~~~~~~~✔️
gas-length-in-loopsSuggest replacing object.length in a loop condition to avoid calculation on each lap
gas-multitoken1155ERC1155 is a cheaper non-fungible token than ERC721
gas-named-return-valuesEnforce the return values of a function to be named
gas-small-stringsKeep strings smaller than 32 bytes. Promote the use of custom errors        ~~~~~~~~✔️
gas-strict-inequalitiesSuggest Strict Inequalities over non Strict ones        ~~~~~~~~✔️
gas-struct-packingSuggest to re-arrange struct packing order when it is inefficient        ~~~~~~~~✔️

Miscellaneous

Rule IdErrorRecommendedDeprecated
comprehensive-interfaceCheck that all public or external functions are overridden. This is useful to make sure that the whole API is extracted in an interface.
foundry-no-block-time-numberWarn on the use of block.timestamp / block.number inside Foundry test files; recommend vm.getBlockTimestamp() / vm.getBlockNumber().
import-path-checkCheck if an import file exists in target path        ~~~~~~~~✔️
quotesEnforces the use of double or simple quotes as configured for string literals. Values must be 'single' or 'double'.        ~~~~~~~~✔️

Security Rules

Rule IdErrorRecommendedDeprecated
avoid-call-valueAvoid to use ".call.value()()".        ~~~~~~~~✔️
avoid-low-level-callsAvoid to use low level calls.        ~~~~~~~~✔️
avoid-sha3Use "keccak256" instead of deprecated "sha3".        ~~~~~~~~✔️
avoid-suicideUse "selfdestruct" instead of deprecated "suicide".        ~~~~~~~~✔️
avoid-throw"throw" is deprecated, avoid to use it.        ~~~~~~~~✔️
avoid-tx-originAvoid to use tx.origin.        ~~~~~~~~✔️
check-send-resultCheck result of "send" call.        ~~~~~~~~✔️
compiler-versionCompiler version must satisfy a semver requirement at least ^0.8.24.        ~~~~~~~~✔️
func-visibilityExplicitly mark visibility in function.        ~~~~~~~~✔️
multiple-sendsAvoid multiple calls of "send" method in single transaction.        ~~~~~~~~✔️
no-complex-fallbackFallback function must be simple.        ~~~~~~~~✔️
no-immutable-before-declarationImmutable variables should not be used in state variable initializers before they are declared.        ~~~~~~~~✔️
no-inline-assemblyAvoid to use inline assembly. It is acceptable only in rare cases.        ~~~~~~~~✔️
not-rely-on-block-hashDo not rely on "block.blockhash". Miners can influence its value.        ~~~~~~~~✔️
not-rely-on-timeAvoid making time-based decisions in your business logic.
reentrancyPossible reentrancy vulnerabilities. Avoid state changes after transfer.        ~~~~~~~~✔️
state-visibilityExplicitly mark visibility of state.        ~~~~~~~~✔️

References