Showing 5 of 87 total issues
Function main
has a Cognitive Complexity of 284 (exceeds 20 allowed). Consider refactoring. Open
Open
func main() {
// we want to load a config file named "irods_downloader_config.yaml" if it exists in WD or in ~/.config
viper.SetConfigName("irods_downloader_config")
viper.SetConfigType("yaml")
viper.AddConfigPath(".") // look for config in the working directory first
- 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 main
has 566 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func main() {
// we want to load a config file named "irods_downloader_config.yaml" if it exists in WD or in ~/.config
viper.SetConfigName("irods_downloader_config")
viper.SetConfigType("yaml")
viper.AddConfigPath(".") // look for config in the working directory first
File irods_downloader.go
has 686 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package main
import (
"bytes"
"encoding/json"
Function main
has 8 return statements (exceeds 4 allowed). Open
Open
func main() {
// we want to load a config file named "irods_downloader_config.yaml" if it exists in WD or in ~/.config
viper.SetConfigName("irods_downloader_config")
viper.SetConfigType("yaml")
viper.AddConfigPath(".") // look for config in the working directory first
Avoid deeply nested control flow statements. Open
Open
if err != nil {
// Display everything we got if error.
log.Println("Error when running command. Output:")
log.Println(string(output))
log.Printf("Got command status: %s\n", err.Error())