piavlo/task-orchestrator

View on GitHub

Showing 19 of 27 total issues

Method run has a Cognitive Complexity of 123 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      validate_config
      save_state

      @state['steps'].each do |step|
Severity: Minor
Found in lib/orchestrator/task.rb - About 2 days 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 validate_config has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_config
      @state['ok_handler'] = validate_command(@state['ok_handler'], 'task success handler') if @state.has_key?('ok_handler')
      @state['failure_handler'] = validate_command(@state['failure_handler'], 'task failure handler') if @state.has_key?('failure_handler')
      if @state.has_key?('email')
        invalid("config email recipients is missing or invalid") unless @state['email'].has_key?('recipients') && @state['email']['recipients'].is_a?(String) || @state['email']['recipients'].is_a?(Array)
Severity: Minor
Found in lib/orchestrator/task.rb - About 1 day 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 64 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(options)
      @mutex = Mutex.new
      Thread.abort_on_exception = true
      @log = ''

Severity: Minor
Found in lib/orchestrator/task.rb - About 1 day 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 task.rb has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'popen4'
require 'pony'
require 'yaml'
require 'timeout'
require 'formatador'
Severity: Minor
Found in lib/orchestrator/task.rb - About 7 hrs to fix

    Method interpolate_command has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def interpolate_command(command,pattern=/^(ENV|ARG|EXEC)\./)
          command = command.to_s if command.is_a?(Integer)
          command.gsub(/:::([^:]*):::/) do
            match = $1
            invalid("interpolation type is not valid in this context - :::#{match}:::") if match !~ pattern and match =~ /^(ENV|ARG|EXEC)\./
    Severity: Minor
    Found in lib/orchestrator/task.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 validate_config has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def validate_config
          @state['ok_handler'] = validate_command(@state['ok_handler'], 'task success handler') if @state.has_key?('ok_handler')
          @state['failure_handler'] = validate_command(@state['failure_handler'], 'task failure handler') if @state.has_key?('failure_handler')
          if @state.has_key?('email')
            invalid("config email recipients is missing or invalid") unless @state['email'].has_key?('recipients') && @state['email']['recipients'].is_a?(String) || @state['email']['recipients'].is_a?(Array)
    Severity: Major
    Found in lib/orchestrator/task.rb - About 3 hrs to fix

      Method initialize has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(options)
            @mutex = Mutex.new
            Thread.abort_on_exception = true
            @log = ''
      
      
      Severity: Major
      Found in lib/orchestrator/task.rb - About 3 hrs to fix

        Method run has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def run
              validate_config
              save_state
        
              @state['steps'].each do |step|
        Severity: Major
        Found in lib/orchestrator/task.rb - About 3 hrs to fix

          Method thread_wrapper has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def thread_wrapper(i,script)
                failures = 0
          
                loop do
                  begin
          Severity: Minor
          Found in lib/orchestrator/task.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

          Method parse has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.parse(args)
                options = OpenStruct.new
                options.args = Object.new
          
                parser = OptionParser.new
          Severity: Major
          Found in lib/orchestrator/cli.rb - About 2 hrs to fix

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

                def validate_command(command,error_prefix)
                  if command.is_a?(String)
                     command = { 'command' => interpolate_command(command) }
                  elsif command.is_a?(Hash)
                    invalid(error_prefix + " is missing command attribute") unless command.has_key?('command')
            Severity: Minor
            Found in lib/orchestrator/task.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_command has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def run_command(command,timeout)
                  result = ""
                  error = ""
            
                  #  start = Time.now
            Severity: Minor
            Found in lib/orchestrator/task.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_command has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def run_command(command,timeout)
                  result = ""
                  error = ""
            
                  #  start = Time.now
            Severity: Minor
            Found in lib/orchestrator/task.rb - About 1 hr to fix

              Method interpolate_command has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def interpolate_command(command,pattern=/^(ENV|ARG|EXEC)\./)
                    command = command.to_s if command.is_a?(Integer)
                    command.gsub(/:::([^:]*):::/) do
                      match = $1
                      invalid("interpolation type is not valid in this context - :::#{match}:::") if match !~ pattern and match =~ /^(ENV|ARG|EXEC)\./
              Severity: Minor
              Found in lib/orchestrator/task.rb - About 1 hr to fix

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

                    def thread_wrapper(i,script)
                      failures = 0
                
                      loop do
                        begin
                Severity: Minor
                Found in lib/orchestrator/task.rb - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  Process.kill("TERM", @state['pid']) if @state.has_key?('pid')
                  Severity: Major
                  Found in lib/orchestrator/task.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  rescue Errno::ESRCH
                    Severity: Major
                    Found in lib/orchestrator/task.rb - About 45 mins to fix

                      Method run_post_script_handlers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def run_post_script_handlers(script,status)
                            handler = nil
                            if status
                              handler = 'ok_handler' if script.has_key?('ok_handler')
                            else
                      Severity: Minor
                      Found in lib/orchestrator/task.rb - About 45 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def self.parse(args)
                            options = OpenStruct.new
                            options.args = Object.new
                      
                            parser = OptionParser.new
                      Severity: Minor
                      Found in lib/orchestrator/cli.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

                      Severity
                      Category
                      Status
                      Source
                      Language