txn2/kubefwd

View on GitHub

Showing 15 of 15 total issues

Method ServiceFWD.SyncPodForwards has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring.
Open

func (svcFwd *ServiceFWD) SyncPodForwards(force bool) {
    sync := func() {

        defer func() { svcFwd.LastSyncedAt = time.Now() }()

Severity: Minor
Found in pkg/fwdservice/fwdservice.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 runCmd has 130 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func runCmd(cmd *cobra.Command, _ []string) {

    if verbose {
        log.SetLevel(log.DebugLevel)
    }
Severity: Major
Found in cmd/kubefwd/services/services.go - About 4 hrs to fix

    Method ServiceFWD.LoopPodsToForward has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
    Open

    func (svcFwd *ServiceFWD) LoopPodsToForward(pods []v1.Pod, includePodNameInHost bool) {
        publisher := &fwdpub.Publisher{
            PublisherName: "Services",
            Output:        false,
        }
    Severity: Minor
    Found in pkg/fwdservice/fwdservice.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 ServiceFWD.LoopPodsToForward has 110 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (svcFwd *ServiceFWD) LoopPodsToForward(pods []v1.Pod, includePodNameInHost bool) {
        publisher := &fwdpub.Publisher{
            PublisherName: "Services",
            Output:        false,
        }
    Severity: Major
    Found in pkg/fwdservice/fwdservice.go - About 3 hrs to fix

      Function runCmd has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
      Open

      func runCmd(cmd *cobra.Command, _ []string) {
      
          if verbose {
              log.SetLevel(log.DebugLevel)
          }
      Severity: Minor
      Found in cmd/kubefwd/services/services.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 ForwardIPOpts.MatchList has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (o ForwardIPOpts) MatchList() []string {
          if o.ClusterN == 0 && o.NamespaceN == 0 {
              return []string{
                  o.PodName,
      
      
      Severity: Major
      Found in pkg/fwdIp/fwdIp.go - About 2 hrs to fix

        Method PortForwardOpts.AddHosts has 66 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (pfo *PortForwardOpts) AddHosts() {
        
            pfo.HostFile.Lock()
        
            // pfo.Service holds only the service name
        Severity: Minor
        Found in pkg/fwdport/fwdport.go - About 1 hr to fix

          Method PortForwardOpts.PortForward has 60 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (pfo *PortForwardOpts) PortForward() error {
              defer close(pfo.DoneChan)
          
              transport, upgrader, err := spdy.RoundTripperFor(&pfo.Config)
              if err != nil {
          Severity: Minor
          Found in pkg/fwdport/fwdport.go - About 1 hr to fix

            Method ServiceFWD.SyncPodForwards has 53 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (svcFwd *ServiceFWD) SyncPodForwards(force bool) {
                sync := func() {
            
                    defer func() { svcFwd.LastSyncedAt = time.Now() }()
            
            
            Severity: Minor
            Found in pkg/fwdservice/fwdservice.go - About 1 hr to fix

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

              func ReadyInterface(opts fwdIp.ForwardIPOpts) (net.IP, error) {
              
                  ip, _ := fwdIp.GetIp(opts)
              
                  // lo means we are probably on linux and not mac
              Severity: Major
              Found in pkg/fwdnet/fwdnet.go - About 45 mins to fix

                Method PortForwardOpts.PortForward has 6 return statements (exceeds 4 allowed).
                Open

                func (pfo *PortForwardOpts) PortForward() error {
                    defer close(pfo.DoneChan)
                
                    transport, upgrader, err := spdy.RoundTripperFor(&pfo.Config)
                    if err != nil {
                Severity: Major
                Found in pkg/fwdport/fwdport.go - About 40 mins to fix

                  Function getForwardConfiguration has 5 return statements (exceeds 4 allowed).
                  Open

                  func getForwardConfiguration(opts ForwardIPOpts) *ForwardConfiguration {
                      if forwardConfiguration != nil {
                          return forwardConfiguration
                      }
                  
                  
                  Severity: Major
                  Found in pkg/fwdIp/fwdIp.go - About 35 mins to fix

                    Function BackupHostFile has 5 return statements (exceeds 4 allowed).
                    Open

                    func BackupHostFile(hostFile *txeh.Hosts) (string, error) {
                        homeDirLocation, err := os.UserHomeDir()
                        if err != nil {
                            return "", err
                        }
                    Severity: Major
                    Found in pkg/fwdhost/fwdhost.go - About 35 mins to fix

                      Method PortForwardOpts.WaitUntilPodRunning has 5 return statements (exceeds 4 allowed).
                      Open

                      func (pfo *PortForwardOpts) WaitUntilPodRunning(stopChannel <-chan struct{}) (*v1.Pod, error) {
                          pod, err := pfo.ClientSet.CoreV1().Pods(pfo.Namespace).Get(context.TODO(), pfo.PodName, metav1.GetOptions{})
                          if err != nil {
                              return nil, err
                          }
                      Severity: Major
                      Found in pkg/fwdport/fwdport.go - About 35 mins to fix

                        Function ipFromString has 5 return statements (exceeds 4 allowed).
                        Open

                        func ipFromString(ipStr string) (net.IP, error) {
                            ipParts := strings.Split(ipStr, ".")
                        
                            octet0, err := strconv.Atoi(ipParts[0])
                            if err != nil {
                        Severity: Major
                        Found in pkg/fwdIp/fwdIp.go - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language