dotcloud/docker

View on GitHub
libnetwork/cmd/diagnostic/main.go

Summary

Maintainability
B
4 hrs
Test Coverage

Function fetchTable has 59 lines of code (exceeds 50 allowed). Consider refactoring.
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")
Severity: Minor
Found in libnetwork/cmd/diagnostic/main.go - About 1 hr to fix

    Function main has 53 lines of code (exceeds 50 allowed). Consider refactoring.
    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>")
    Severity: Minor
    Found in libnetwork/cmd/diagnostic/main.go - About 1 hr to fix

      Function fetchTable has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
      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")
      Severity: Minor
      Found in libnetwork/cmd/diagnostic/main.go - About 55 mins to fix

      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

      func fetchTable(ip string, port int, network, tableName string, clusterPeers, networkPeers map[string]string, remediate bool) {
      Severity: Minor
      Found in libnetwork/cmd/diagnostic/main.go - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status