libnetwork/cmd/diagnostic/main.go
Function fetchTable
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func fetchTable(ip string, port int, network, tableName string, clusterPeers, networkPeers map[string]string, remediate bool) {
log.G(context.TODO()).Infof("Fetch %s table and check owners", tableName)
resp, err := http.Get(fmt.Sprintf(dumpTable, ip, port, network, tableName))
if err != nil {
log.G(context.TODO()).WithError(err).Fatalf("Failed fetching endpoint table")
Function main
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func main() {
ipPtr := flag.String("ip", "127.0.0.1", "ip address")
portPtr := flag.Int("port", 2000, "port")
networkPtr := flag.String("net", "", "target network")
tablePtr := flag.String("t", "", "table to process <sd/overlay>")
Function fetchTable
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
Open
func fetchTable(ip string, port int, network, tableName string, clusterPeers, networkPeers map[string]string, remediate bool) {
log.G(context.TODO()).Infof("Fetch %s table and check owners", tableName)
resp, err := http.Get(fmt.Sprintf(dumpTable, ip, port, network, tableName))
if err != nil {
log.G(context.TODO()).WithError(err).Fatalf("Failed fetching endpoint table")
- 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 fetchTable
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func fetchTable(ip string, port int, network, tableName string, clusterPeers, networkPeers map[string]string, remediate bool) {