Skip to content

Latest commit

 

History

History
75 lines (60 loc) · 2.21 KB

code-complexity.md

File metadata and controls

75 lines (60 loc) · 2.21 KB
warning layout title
This is a dynamically generated file. Do not edit manually.
default
code-complexity | Solhint

code-complexity

Category Badge Default Severity Badge warn

Description

Function has cyclomatic complexity "current" but allowed no more than maxcompl.

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 cyclomatic complexity 7

Example Config

{
  "rules": {
    "code-complexity": ["warn",7]
  }
}

Examples

👍 Examples of correct code for this rule

Low code complexity

 if (a > b) {                   
   if (b > c) {                 
     if (c > d) {               
     }                          
   }                            
 }                              
for (i = 0; i < b; i += 1) { }  
do { d++; } while (b > c);       
while (d > e) { }               

👎 Examples of incorrect code for this rule

High code complexity

 if (a > b) {                   
   if (b > c) {                 
     if (c > d) {               
       if (d > e) {             
       } else {                 
       }                        
     }                          
   }                            
 }                              
for (i = 0; i < b; i += 1) { }  
do { d++; } while (b > c);       
while (d > e) { }               

Version

This rule was introduced in Solhint 1.1.5

Resources