xetys/hetzner-kube

View on GitHub

Showing 29 of 34 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package addons

import (
    "log"

Severity: Major
Found in pkg/addons/addon_cert_manager.go and 1 other location - About 6 hrs to fix
pkg/addons/addon_ingress.go on lines 1..60

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 428.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package addons

import (
    "log"

Severity: Major
Found in pkg/addons/addon_ingress.go and 1 other location - About 6 hrs to fix
pkg/addons/addon_cert_manager.go on lines 1..60

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 428.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Function TestGenerateMasterConfiguration has 86 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestGenerateMasterConfiguration(t *testing.T) {
    expectedConf := `apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: v1.19.2
networking:
Severity: Major
Found in pkg/clustermanager/configs_test.go - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        PreRunE: func(cmd *cobra.Command, args []string) error {
            name, err := cmd.Flags().GetString("name")
            if err != nil {
                return nil
            }
    Severity: Major
    Found in cmd/cluster_remove_worker.go and 1 other location - About 2 hrs to fix
    cmd/cluster_remove_external_worker.go on lines 16..45

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 216.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        PreRunE: func(cmd *cobra.Command, args []string) error {
            name, err := cmd.Flags().GetString("name")
            if err != nil {
                return nil
            }
    Severity: Major
    Found in cmd/cluster_remove_external_worker.go and 1 other location - About 2 hrs to fix
    cmd/cluster_remove_worker.go on lines 16..45

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 216.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function RunClusterCreate has 67 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func RunClusterCreate(cmd *cobra.Command, args []string) {
        workerCount, _ := cmd.Flags().GetInt("worker-count")
        masterCount, _ := cmd.Flags().GetInt("master-count")
        etcdCount := 0
        haEnabled, _ := cmd.Flags().GetBool("ha-enabled")
    Severity: Minor
    Found in cmd/cluster_create.go - About 1 hr to fix

      Function validateClusterCreateFlags has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
      Open

      func validateClusterCreateFlags(cmd *cobra.Command, args []string) error {
      
          var (
              sshKey, masterServerType, workerServerType, cloudInit string
          )
      Severity: Minor
      Found in cmd/cluster_create.go - About 1 hr 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 validateClusterCreateFlags has 12 return statements (exceeds 4 allowed).
      Open

      func validateClusterCreateFlags(cmd *cobra.Command, args []string) error {
      
          var (
              sshKey, masterServerType, workerServerType, cloudInit string
          )
      Severity: Major
      Found in cmd/cluster_create.go - About 1 hr to fix

        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 GenerateMasterConfiguration has 53 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func GenerateMasterConfiguration(masterNode Node, masterNodes []Node, etcdNodes []Node, kubernetesVersion string) string {
              masterConfigTpl := `apiVersion: kubeadm.k8s.io/v1beta1
          kind: ClusterConfiguration
          kubernetesVersion: v%s
          networking:
          Severity: Minor
          Found in pkg/clustermanager/configs.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

              Function validateFlags has 7 return statements (exceeds 4 allowed).
              Open

              func validateFlags(cmd *cobra.Command, args []string) error {
                  if err := AppConf.assertActiveContext(); err != nil {
                      return err
                  }
              
              
              Severity: Major
              Found in cmd/ssh_key_add.go - About 45 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 Provider.runCreateServer has 7 return statements (exceeds 4 allowed).
                  Confirmed

                  func (provider *Provider) runCreateServer(opts *hcloud.ServerCreateOpts) (*hcloud.ServerCreateResult, error) {
                      log.Printf("creating server '%s'...", opts.Name)
                      server, _, err := provider.client.Server.GetByName(provider.context, opts.Name)
                      if err != nil {
                          return nil, err
                  Severity: Major
                  Found in pkg/hetzner/hetzner_provider.go - About 45 mins to fix

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        PreRunE: func(cmd *cobra.Command, args []string) error {
                    
                            name := args[0]
                    
                            if name == "" {
                    Severity: Minor
                    Found in cmd/cluster_delete.go and 1 other location - About 40 mins to fix
                    cmd/cluster_master_ip.go on lines 16..29

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 112.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        PreRunE: func(cmd *cobra.Command, args []string) error {
                            name := args[0]
                    
                            if name == "" {
                                return errors.New("name is required")
                    Severity: Minor
                    Found in cmd/cluster_master_ip.go and 1 other location - About 40 mins to fix
                    cmd/cluster_delete.go on lines 16..31

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 112.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Function validateAddonSubCommand has 6 return statements (exceeds 4 allowed).
                    Open

                    func validateAddonSubCommand(cmd *cobra.Command, args []string) error {
                        name, err := cmd.Flags().GetString("name")
                        if err != nil {
                            return nil
                        }
                    Severity: Major
                    Found in cmd/cluster_addon.go - About 40 mins to fix

                      Method NodeProvisioner.prepareAndInstall has 6 return statements (exceeds 4 allowed).
                      Open

                      func (provisioner *NodeProvisioner) prepareAndInstall() error {
                      
                          err := provisioner.waitForCloudInitCompletion()
                          if err != nil {
                              return err
                      Severity: Major
                      Found in pkg/clustermanager/provision_node.go - About 40 mins to fix

                        Method Provider.CreateMasterNodes has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        func (provider *Provider) CreateMasterNodes(sshKeyName string, masterServerType string, datacenters []string, count int, isEtcd bool) ([]clustermanager.Node, error) {
                        Severity: Minor
                        Found in pkg/hetzner/hetzner_provider.go - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language