minishift/minishift

View on GitHub

Showing 151 of 151 total issues

File trayicon_unix.go has 2064 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// +build !windows

/*
Copyright (C) 2018 Red Hat, Inc.

Severity: Major
Found in pkg/minishift/systemtray/icon/trayicon_unix.go - About 4 days to fix

    Method RedHatRegistrator.Register has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
    Open

    func (registrator *RedHatRegistrator) Register(param *RegistrationParameters) error {
        keyringDocsLink := "https://docs.okd.io/latest/minishift/troubleshooting/troubleshooting-misc.html#Remove-password-from-keychain"
        if isRegistered, err := registrator.IsRegistered(); !isRegistered && err == nil {
            for i := 1; i < 4; i++ {
                // request username (disallow empty value)
    Severity: Minor
    Found in pkg/minishift/registration/redhat.go - About 6 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

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

    func startProfile(profileName string) error {
        minishiftBinary, _ := os.CurrentExecutable()
        if runtime.GOOS == "windows" {
            var startCommandString = fmt.Sprintf(minishiftBinary + " start --profile " + profileName)
            startFilePath := filepath.Join(goos.TempDir(), "minishift_start.bat")
    Severity: Major
    Found in pkg/minishift/systemtray/systemtray.go and 1 other location - About 6 hrs to fix
    pkg/minishift/systemtray/systemtray.go on lines 163..213

    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 473.

    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

    func stopProfile(profileName string) error {
        minishiftBinary, _ := os.CurrentExecutable()
        if runtime.GOOS == "windows" {
            var stopCommandString = fmt.Sprintf(minishiftBinary + " stop --profile " + profileName)
            stopFilePath := filepath.Join(goos.TempDir(), "minishift_stop.bat")
    Severity: Major
    Found in pkg/minishift/systemtray/systemtray.go and 1 other location - About 6 hrs to fix
    pkg/minishift/systemtray/systemtray.go on lines 216..266

    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 473.

    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

    File start.go has 677 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    /*
    Copyright 2016 The Kubernetes Authors All rights reserved.
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    Severity: Minor
    Found in cmd/minishift/cmd/start.go - About 6 hrs to fix

      Function GenerateZshCompletion has 159 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func GenerateZshCompletion(out io.Writer, cmd *cobra.Command) error {
          zsh_initialization := `
      __minishift_bash_source() {
          alias shopt=':'
          alias _expand=_bash_expand
      Severity: Major
      Found in cmd/minishift/cmd/completion.go - About 5 hrs to fix

        Function serveConnections has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
        Open

        func serveConnections(listener net.Listener, serverConfig *ssh.ServerConfig) {
            for {
                nConn, err := listener.Accept()
                if err != nil {
                    glog.Fatal("failed to accept incoming connection", err)
        Severity: Minor
        Found in cmd/minishift/cmd/daemon/sftpd.go - About 5 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 runStart has 131 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func runStart(cmd *cobra.Command, args []string) {
            fmt.Println(fmt.Sprintf("-- Starting profile '%s'", constants.ProfileName))
        
            libMachineClient := libmachine.NewClient(state.InstanceDirs.Home, state.InstanceDirs.Certs)
            defer libMachineClient.Close()
        Severity: Major
        Found in cmd/minishift/cmd/start.go - About 4 hrs to fix

          Function DownloadOpenShiftReleaseBinary has 126 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func DownloadOpenShiftReleaseBinary(binaryType OpenShiftBinaryType, osType minishiftos.OS, version, outputPath string) error {
              client := Client()
              ctx := context.Background()
              var (
                  err     error
          Severity: Major
          Found in pkg/util/github/github.go - About 4 hrs to fix

            Function preflightChecksBeforeStartingHost has 119 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func preflightChecksBeforeStartingHost() {
                if shouldPreflightChecksBeSkipped() {
                    return
                }
                driverErrorMessage := "See the 'Setting Up the Virtualization Environment' topic (https://docs.okd.io/latest/minishift/getting-started/setting-up-virtualization-environment.html) for more information"
            Severity: Major
            Found in cmd/minishift/cmd/start_preflight.go - About 3 hrs to fix

              Function runStart has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
              Open

              func runStart(cmd *cobra.Command, args []string) {
                  fmt.Println(fmt.Sprintf("-- Starting profile '%s'", constants.ProfileName))
              
                  libMachineClient := libmachine.NewClient(state.InstanceDirs.Home, state.InstanceDirs.Certs)
                  defer libMachineClient.Close()
              Severity: Minor
              Found in cmd/minishift/cmd/start.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

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

              /*
              Copyright (C) 2018 Red Hat, Inc.
              
              Licensed under the Apache License, Version 2.0 (the "License");
              you may not use this file except in compliance with the License.
              Severity: Major
              Found in cmd/minishift/cmd/dns/stop.go and 1 other location - About 3 hrs to fix
              cmd/minishift/cmd/dns/start.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 269.

              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

              /*
              Copyright (C) 2018 Red Hat, Inc.
              
              Licensed under the Apache License, Version 2.0 (the "License");
              you may not use this file except in compliance with the License.
              Severity: Major
              Found in cmd/minishift/cmd/dns/start.go and 1 other location - About 3 hrs to fix
              cmd/minishift/cmd/dns/stop.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 269.

              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 file_passes has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              def file_passes(filename, refs, regexs):
                  try:
                      f = open(filename, 'r')
                  except:
                      return False
              Severity: Minor
              Found in scripts/boilerplate/boilerplate.py - About 2 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 DownloadOpenShiftReleaseBinary has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
              Open

              func DownloadOpenShiftReleaseBinary(binaryType OpenShiftBinaryType, osType minishiftos.OS, version, outputPath string) error {
                  client := Client()
                  ctx := context.Background()
                  var (
                      err     error
              Severity: Minor
              Found in pkg/util/github/github.go - About 2 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 get_files has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_files(extensions):
                  files = []
                  if len(args.filenames) > 0:
                      files = args.filenames
                  else:
              Severity: Minor
              Found in scripts/boilerplate/boilerplate.py - About 2 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 RedHatRegistrator.Register has 82 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (registrator *RedHatRegistrator) Register(param *RegistrationParameters) error {
                  keyringDocsLink := "https://docs.okd.io/latest/minishift/troubleshooting/troubleshooting-misc.html#Remove-password-from-keychain"
                  if isRegistered, err := registrator.IsRegistered(); !isRegistered && err == nil {
                      for i := 1; i < 4; i++ {
                          // request username (disallow empty value)
              Severity: Major
              Found in pkg/minishift/registration/redhat.go - About 2 hrs to fix

                File start_preflight.go has 510 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                /*
                Copyright (C) 2017 Red Hat, Inc.
                
                Licensed under the Apache License, Version 2.0 (the "License");
                you may not use this file except in compliance with the License.
                Severity: Minor
                Found in cmd/minishift/cmd/start_preflight.go - About 2 hrs to fix

                  File testdata.go has 507 lines of code (exceeds 500 allowed). Consider refactoring.
                  Open

                  /*
                  Copyright (C) 2017 Red Hat, Inc.
                  
                  Licensed under the Apache License, Version 2.0 (the "License");
                  you may not use this file except in compliance with the License.
                  Severity: Minor
                  Found in pkg/testing/testdata/testdata.go - About 2 hrs to fix

                    Method navigation_menu has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def navigation_menu
                        navigation = ""
                        topic_map = YAML.load_file('build/_topic_map.yml')
                        topic_map["Topics"].each_with_index do |topic, index|
                          topic_directory = topic["Dir"]
                    Severity: Minor
                    Found in docs/helpers/custom_helpers.rb - 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

                    Severity
                    Category
                    Status
                    Source
                    Language