xetys/hetzner-kube

View on GitHub
pkg/clustermanager/cluster.go

Summary

Maintainability
B
6 hrs
Test Coverage

Method Manager.InstallWorkers has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
Open

func (manager *Manager) InstallWorkers(nodes []Node) error {
    node, err := manager.clusterProvider.GetMasterNode()
    if err != nil {
        return err
    }
Severity: Minor
Found in pkg/clustermanager/cluster.go - About 3 hrs 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

Method Manager.InstallWorkers has 54 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (manager *Manager) InstallWorkers(nodes []Node) error {
    node, err := manager.clusterProvider.GetMasterNode()
    if err != nil {
        return err
    }
Severity: Minor
Found in pkg/clustermanager/cluster.go - About 1 hr to fix

    Function NewClusterManager has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func NewClusterManager(provider ClusterProvider, nodeCommunicator NodeCommunicator, eventService EventService, name string, haEnabled bool, isolatedEtcd bool, cloudInitFile string) *Manager {
    Severity: Major
    Found in pkg/clustermanager/cluster.go - About 50 mins to fix

      Method Manager.installMasterStep has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (manager *Manager) installMasterStep(node Node, numMaster int, masterNode Node, commands []NodeCommand, trueChan chan bool, errChan chan error) {
      Severity: Minor
      Found in pkg/clustermanager/cluster.go - About 45 mins to fix

        Method Manager.InstallMasters has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func (manager *Manager) InstallMasters(keepCerts KeepCerts) error {
            commands := []NodeCommand{
                {"sysctl settings", `printf '# Strict RPF mode as required by canal/Calico\nnet.ipv4.conf.default.rp_filter=1\nnet.ipv4.conf.all.rp_filter=1\n' >/etc/sysctl.d/50-canal-calico.conf && sysctl --load=/etc/sysctl.d/50-canal-calico.conf`},
                {"kubeadm init", "kubectl version > /dev/null &> /dev/null || kubeadm init --ignore-preflight-errors=all --config /root/master-config.yaml"},
                {"configure kubectl", "rm -rf $HOME/.kube && mkdir -p $HOME/.kube && cp -i /etc/kubernetes/admin.conf $HOME/.kube/config && chown $(id -u):$(id -g) $HOME/.kube/config"},
        Severity: Minor
        Found in pkg/clustermanager/cluster.go - About 35 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

        Your code does not pass gofmt in 1 place. Go fmt your code!
        Open

        package clustermanager
        Severity: Minor
        Found in pkg/clustermanager/cluster.go by gofmt

        There are no issues that match your filters.

        Category
        Status