Showing 6 of 10 total issues
Function main
has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring. Open
Open
func main() {
version := "1.4.1"
args := os.Args[1:]
_, update := Find(args, "-u")
if update {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generateInfo
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
Open
func generateInfo(config Config, title xterm256.Color, info xterm256.Color, userc xterm256.Color, sep xterm256.Color) []string {
var s []string
cpu, err := ghw.CPU()
if err != nil {
fmt.Printf("Error getting CPU info: %v", err)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generateInfo
has 94 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func generateInfo(config Config, title xterm256.Color, info xterm256.Color, userc xterm256.Color, sep xterm256.Color) []string {
var s []string
cpu, err := ghw.CPU()
if err != nil {
fmt.Printf("Error getting CPU info: %v", err)
Function getCustomColor
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func getCustomColor(color string) xterm256.Color {
var (
Black = xterm256.Color{ForegroundColor: 0, BackgroundColor: -1}
DarkRed = xterm256.Color{ForegroundColor: 1, BackgroundColor: -1}
DarkGreen = xterm256.Color{ForegroundColor: 2, BackgroundColor: -1}
Avoid deeply nested control flow statements. Open
Open
} else if hours > 0 {
result = plural(int(hours), "hour") + plural(int(minutes), "minute") + plural(int(seconds), "second")
} else if minutes > 0 {
result = plural(int(minutes), "minute") + plural(int(seconds), "second")
} else {
Avoid deeply nested control flow statements. Open
Open
} else if inputNum >= 1000000000000 {
returnVal = RoundUp((inputNum / 1099511627776), precision)
unit = " TB" // terabyte
} else if inputNum >= 1000000000 {
returnVal = RoundUp((inputNum / 1073741824), precision)