ManageIQ/floe

View on GitHub

Showing 30 of 30 total issues

Method parse_options! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_options!(args)
      opts = Optimist.options(args) do
        version("v#{Floe::VERSION}\n")
        usage("[options] workflow input [workflow2 input2]")

Severity: Minor
Found in lib/floe/cli.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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def run(args = ARGV)
      workflows_inputs, opts = parse_options!(args)

      credentials =
        if opts[:credentials_given]
Severity: Minor
Found in lib/floe/cli.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 29 lines of code (exceeds 25 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 1 hr to fix

    Method parse_options! has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_options!(args)
          opts = Optimist.options(args) do
            version("v#{Floe::VERSION}\n")
            usage("[options] workflow input [workflow2 input2]")
    
    
    Severity: Minor
    Found in lib/floe/cli.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

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

              def initialize(workflow, name, payload)
                super
      
                @heartbeat_seconds = payload["HeartbeatSeconds"]
                @next              = payload["Next"]
      Severity: Minor
      Found in lib/floe/workflow/states/task.rb - About 35 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

      Method resolve_cli_options! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def resolve_cli_options!(opts)
              # shortcut support
              opts[:container_runner] ||= "docker" if opts[:docker]
              opts[:container_runner] ||= "podman" if opts[:podman]
              opts[:container_runner] ||= "kubernetes" if opts[:kubernetes]
      Severity: Minor
      Found in lib/floe/container_runner.rb - About 35 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

      Method parse_output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def parse_output(output)
                return output if output.kind_of?(Hash)
                return if output.nil? || output.empty?
      
                JSON.parse(output.split("\n").last)
      Severity: Minor
      Found in lib/floe/workflow/states/task.rb - About 25 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

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

            def wait(context, timeout: nil)
              start = Time.now.utc
      
              loop do
                return 0             if ready?(context)
      Severity: Minor
      Found in lib/floe/workflow/state.rb - About 25 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

      Unused method argument - workflow. If it's necessary, use _ or _workflow as an argument name to indicate that it won't be used. If it's unnecessary, remove it.
      Open

            def initialize(workflow, name, payload)
      Severity: Minor
      Found in lib/floe/workflow/state.rb by rubocop

      Checks for unused method arguments.

      Example:

      # bad
      def some_method(used, unused, _unused_but_allowed)
        puts used
      end
      
      # good
      def some_method(used, _unused, _unused_but_allowed)
        puts used
      end

      Example: AllowUnusedKeywordArguments: false (default)

      # bad
      def do_something(used, unused: 42)
        used
      end

      Example: AllowUnusedKeywordArguments: true

      # good
      def do_something(used, unused: 42)
        used
      end

      Example: IgnoreEmptyMethods: true (default)

      # good
      def do_something(unused)
      end

      Example: IgnoreEmptyMethods: false

      # bad
      def do_something(unused)
      end

      Example: IgnoreNotImplementedMethods: true (default)

      # good
      def do_something(unused)
        raise NotImplementedError
      end
      
      def do_something_else(unused)
        fail "TODO"
      end

      Example: IgnoreNotImplementedMethods: false

      # bad
      def do_something(unused)
        raise NotImplementedError
      end
      
      def do_something_else(unused)
        fail "TODO"
      end
      Severity
      Category
      Status
      Source
      Language