ManageIQ/floe

View on GitHub
lib/floe/container_runner/kubernetes.rb

Summary

Maintainability
D
1 day
Test Coverage
C
73%

Method wait has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def wait(timeout: nil, events: %i[create update delete])
        retry_connection = true

        begin
          watcher = kubeclient.watch_pods(:namespace => namespace)
Severity: Minor
Found in lib/floe/container_runner/kubernetes.rb - 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

Class Kubernetes has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Kubernetes < Floe::Runner
      include Floe::ContainerRunner::DockerMixin

      TOKEN_FILE      = "/run/secrets/kubernetes.io/serviceaccount/token"
      CA_CERT_FILE    = "/run/secrets/kubernetes.io/serviceaccount/ca.crt"
Severity: Minor
Found in lib/floe/container_runner/kubernetes.rb - About 2 hrs to fix

    File kubernetes.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Floe
      class ContainerRunner
        class Kubernetes < Floe::Runner
          include Floe::ContainerRunner::DockerMixin
    
    
    Severity: Minor
    Found in lib/floe/container_runner/kubernetes.rb - About 2 hrs to fix

      Method pod_spec has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def pod_spec(name, image, env, secret = nil)
              spec = {
                :kind       => "Pod",
                :apiVersion => "v1",
                :metadata   => {
      Severity: Minor
      Found in lib/floe/container_runner/kubernetes.rb - About 1 hr to fix

        Method initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(options = {})
                require "active_support/core_ext/hash/keys"
                require "awesome_spawn"
                require "securerandom"
                require "base64"
        Severity: Minor
        Found in lib/floe/container_runner/kubernetes.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

        Method wait has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def wait(timeout: nil, events: %i[create update delete])
                retry_connection = true
        
                begin
                  watcher = kubeclient.watch_pods(:namespace => namespace)
        Severity: Minor
        Found in lib/floe/container_runner/kubernetes.rb - About 1 hr to fix

          Method kubeclient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def kubeclient
                  return @kubeclient unless @kubeclient.nil?
          
                  if server && token
                    api_endpoint = server
          Severity: Minor
          Found in lib/floe/container_runner/kubernetes.rb - 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

          There are no issues that match your filters.

          Category
          Status