{"repo":"uudashr/gocognit","free":true,"listed":false,"github":"https://github.com/uudashr/gocognit","clone":"git clone https://github.com/uudashr/gocognit.git","description":"Calculates cognitive complexities of functions (and methods) in Go source code. (Golang cognitive complexity)","language":"Go","stars":487,"topics":["go","golang","tool","linter","complexity","cognitive","metrics"],"license":"MIT","category":"analytics","readme_excerpt":"Gocognit Gocognit calculates cognitive complexities of functions (and methods) in Go source code. A measurement of how hard does the code is intuitively to understand. Understanding the complexity Given code using if statement, Above code can be refactored using switch statement, As you see above codes are the same, but the second code are easier to understand, that is why the cognitive complexity score are lower compare to the first one. Comparison with cyclomatic complexity Example 1 Cyclomatic complexity Cognitive complexity Cognitive complexity give lower score compare to cyclomatic complexity. Example 2 Cyclomatic complexity Cognitive complexity Cognitive complexity give higher score compare to cyclomatic complexity. Rules The cognitive complexity of a function is calculated according to the following rules: Note: these rules are specific for Go, please see the original whitepaper for more complete reference. Increments There is an increment for each of the following: 1. if , else if , else 2. switch , select 3. for 4. goto LABEL, break LABEL, continue LABEL 5. sequence of binary logical operators 6. each method in a recursion cycle Nesting level The following structures increment the nesting level: 1. if , else if , else 2. switch , select 3. for 4. function literal or lambda Nesting increments The following structures receive a nesting increment commensurate with their nested depth inside nesting structures: 1. if 2. switch , select 3. for Installation or Usage Example","default_branch":null,"files":null,"tree":[],"storefront":"/r/uudashr","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/uudashr/gocognit/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}