ManageIQ/floe

View on GitHub

Showing 30 of 30 total issues

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

      def wait(workflows, timeout: nil, &block)
        workflows = [workflows] if workflows.kind_of?(self)
        logger.info("checking #{workflows.count} workflows...")

        run_until   = Time.now.utc + timeout if timeout.to_i > 0
Severity: Minor
Found in lib/floe/workflow.rb - 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

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

      def wait(timeout: nil, events: %i[create update delete], &block)
        until_timestamp = Time.now.utc + timeout if timeout

        r, w = IO.pipe

Severity: Minor
Found in lib/floe/container_runner/docker.rb - About 4 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 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 Context has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Context
      attr_accessor :credentials

      # @param context [Json|Hash] (default, create another with input and execution params)
      # @param input [Hash] (default: {})
Severity: Minor
Found in lib/floe/workflow/context.rb - About 2 hrs to fix

    Cyclomatic complexity for wait is too high. [21/11]
    Open

          def wait(workflows, timeout: nil, &block)
            workflows = [workflows] if workflows.kind_of?(self)
            logger.info("checking #{workflows.count} workflows...")
    
            run_until   = Time.now.utc + timeout if timeout.to_i > 0
    Severity: Minor
    Found in lib/floe/workflow.rb by rubocop

    Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

    def each_child_node(*types)               # count begins: 1
      unless block_given?                     # unless: +1
        return to_enum(__method__, *types)
    
      children.each do |child|                # each{}: +1
        next unless child.is_a?(Node)         # unless: +1
    
        yield child if types.empty? ||        # if: +1, ||: +1
                       types.include?(child.type)
      end
    
      self
    end                                       # total: 6

    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

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

          def initialize(payload, context = nil, credentials = nil, name = nil)
            payload     = JSON.parse(payload)     if payload.kind_of?(String)
            credentials = JSON.parse(credentials) if credentials.kind_of?(String)
            context     = Context.new(context)    unless context.kind_of?(Context)
      
      
      Severity: Minor
      Found in lib/floe/workflow.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

      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

        Cyclomatic complexity for global_docker_options is too high. [14/11]
        Open

              def global_docker_options
                options = []
                options << [:identity, @identity]                 if @identity
                options << [:"log-level", @log_level]             if @log_level
                options << :noout                                 if @noout
        Severity: Minor
        Found in lib/floe/container_runner/podman.rb by rubocop

        Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

        def each_child_node(*types)               # count begins: 1
          unless block_given?                     # unless: +1
            return to_enum(__method__, *types)
        
          children.each do |child|                # each{}: +1
            next unless child.is_a?(Node)         # unless: +1
        
            yield child if types.empty? ||        # if: +1, ||: +1
                           types.include?(child.type)
          end
        
          self
        end                                       # total: 6

        Cyclomatic complexity for initialize is too high. [14/11]
        Open

              def initialize(options = {})
                require "active_support/core_ext/hash/keys"
                require "awesome_spawn"
                require "securerandom"
                require "base64"

        Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

        def each_child_node(*types)               # count begins: 1
          unless block_given?                     # unless: +1
            return to_enum(__method__, *types)
        
          children.each do |child|                # each{}: +1
            next unless child.is_a?(Node)         # unless: +1
        
            yield child if types.empty? ||        # if: +1, ||: +1
                           types.include?(child.type)
          end
        
          self
        end                                       # total: 6

        Cyclomatic complexity for true? is too high. [13/11]
        Open

                def true?(context, input)
                  lhs = variable_value(context, input)
                  rhs = compare_value(context, input)
        
                  validate!(lhs)

        Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

        def each_child_node(*types)               # count begins: 1
          unless block_given?                     # unless: +1
            return to_enum(__method__, *types)
        
          children.each do |child|                # each{}: +1
            next unless child.is_a?(Node)         # unless: +1
        
            yield child if types.empty? ||        # if: +1, ||: +1
                           types.include?(child.type)
          end
        
          self
        end                                       # total: 6

        Cyclomatic complexity for wait is too high. [13/11]
        Open

              def wait(timeout: nil, events: %i[create update delete])
                retry_connection = true
        
                begin
                  watcher = kubeclient.watch_pods(:namespace => namespace)

        Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

        def each_child_node(*types)               # count begins: 1
          unless block_given?                     # unless: +1
            return to_enum(__method__, *types)
        
          children.each do |child|                # each{}: +1
            next unless child.is_a?(Node)         # unless: +1
        
            yield child if types.empty? ||        # if: +1, ||: +1
                           types.include?(child.type)
          end
        
          self
        end                                       # total: 6

        Cyclomatic complexity for initialize is too high. [13/11]
        Open

              def initialize(context = nil, input: nil, credentials: {})
                context = JSON.parse(context) if context.kind_of?(String)
        
                input ||= {}
                input = JSON.parse(input) if input.kind_of?(String)
        Severity: Minor
        Found in lib/floe/workflow/context.rb by rubocop

        Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

        An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

        def each_child_node(*types)               # count begins: 1
          unless block_given?                     # unless: +1
            return to_enum(__method__, *types)
        
          children.each do |child|                # each{}: +1
            next unless child.is_a?(Node)         # unless: +1
        
            yield child if types.empty? ||        # if: +1, ||: +1
                           types.include?(child.type)
          end
        
          self
        end                                       # total: 6

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

              def wait(workflows, timeout: nil, &block)
                workflows = [workflows] if workflows.kind_of?(self)
                logger.info("checking #{workflows.count} workflows...")
        
                run_until   = Time.now.utc + timeout if timeout.to_i > 0
        Severity: Minor
        Found in lib/floe/workflow.rb - About 1 hr to fix

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

                def initialize(context = nil, input: nil, credentials: {})
                  context = JSON.parse(context) if context.kind_of?(String)
          
                  input ||= {}
                  input = JSON.parse(input) if input.kind_of?(String)
          Severity: Minor
          Found in lib/floe/workflow/context.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 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 global_docker_options has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def global_docker_options
                    options = []
                    options << [:identity, @identity]                 if @identity
                    options << [:"log-level", @log_level]             if @log_level
                    options << :noout                                 if @noout
            Severity: Minor
            Found in lib/floe/container_runner/podman.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 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 true? has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def true?(context, input)
                      lhs = variable_value(context, input)
                      rhs = compare_value(context, input)
            
                      validate!(lhs)
            Severity: Minor
            Found in lib/floe/workflow/choice_rule/data.rb - About 1 hr to fix

              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
                Severity
                Category
                Status
                Source
                Language