Gurpartap/cognizant

View on GitHub

Showing 19 of 19 total issues

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

      def execute(command, options = {})
        options[:groups] ||= []
        options[:env]    ||= {}

        pid, pid_w = IO.pipe
Severity: Minor
Found in lib/cognizant/process/execution.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 drop_privileges has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def drop_privileges(options = {})
        # Cannot drop privileges unless we are superuser.
        if ::Process.euid == 0
          # Drop ~= decrease, since we can only decrease privileges.

Severity: Minor
Found in lib/cognizant/process/execution.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 execute has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def execute(command, options = {})
        options[:groups] ||= []
        options[:env]    ||= {}

        pid, pid_w = IO.pipe
Severity: Major
Found in lib/cognizant/process/execution.rb - About 2 hrs to fix

    Method stop_previous_daemon has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def stop_previous_daemon
          if self.pidfile and File.exists?(self.pidfile)
            if previous_daemon_pid = File.read(self.pidfile).to_i
              # Only attempt to stop automatically if the daemon will run in background.
              if self.daemonize and Cognizant::System.pid_running?(previous_daemon_pid)
    Severity: Minor
    Found in lib/cognizant/daemon.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 start has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def start(options = {})
          self.reset!
    
          load_files = []
          rb_files   = []
    Severity: Major
    Found in lib/cognizant/daemon.rb - About 2 hrs to fix

      Method start has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def start(options = {})
            self.reset!
      
            load_files = []
            rb_files   = []
      Severity: Minor
      Found in lib/cognizant/daemon.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 _restart_result_handler has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              def _restart_result_handler(result, time_left = 0)
                # If it is a boolean and value is true OR if it's an execution result and it succeeded.
                if (!!result == result and result) or (result.respond_to?(:succeeded?) and result.succeeded?)
                  unlink_pid if not pid_running? and self.daemonize
      
      
      Severity: Minor
      Found in lib/cognizant/process/actions/restart.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 read_pid has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def read_pid
              if self.pid_command
                str = execute(self.pid_command).stdout.to_i
                process_pid = str unless not str or str.zero?
                # TODO: Write pid to pidfile, since our source was pid_command instead.
      Severity: Minor
      Found in lib/cognizant/process/pid.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 handle_action has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def handle_action(result_handler, options)
              # TODO: Works well but can some refactoring make it more declarative?
              @action_thread = Thread.new do
                result = false
                queue, thread = execute_action(options)
      Severity: Minor
      Found in lib/cognizant/process/actions.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 load_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_file(file)
            if file.end_with?(".yml")
              yml_config = YAML.load_file(file)
              if yml_config
                yml_config.deep_symbolize_keys!
      Severity: Minor
      Found in lib/cognizant/daemon.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 setup_readline has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def setup_readline(&block)
            Readline.completion_proc = Proc.new do |input|
              case input
              when /^\//
                # Handle file and directory name autocompletion.
      Severity: Minor
      Found in lib/cognizant/shell.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 send_signals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def send_signals(pid, options = {})
                # Return if the process is not running.
                return true unless pid_running?(pid)
      
                signals = options[:signals] || ["TERM", "INT"]
      Severity: Minor
      Found in lib/cognizant/system/signal.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 _stop_result_handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def _stop_result_handler(result, time_left = 0)
                # If it is a boolean and value is true OR if it's an execution result and it succeeded.
                if (!!result == result and result) or (result.respond_to?(:succeeded?) and result.succeeded?)
                  unlink_pid if not pid_running? and self.daemonize
                end
      Severity: Minor
      Found in lib/cognizant/process/actions/stop.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 execute_action has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def execute_action(options)
              before_command = options[:before]
              command        = options[:command]
              after_command  = options[:after]
              signals        = options[:signals]
      Severity: Minor
      Found in lib/cognizant/process/actions.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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def method_missing(name, *args, &block)
              if args.size == 1 and name.to_s =~ /^(.*)=$/
                @attributes[$1.to_sym] = args.first
              elsif args.size == 1
                @attributes[name.to_sym] = args.first
      Severity: Minor
      Found in lib/cognizant/util/dsl_proxy_methods_handler.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(name, options = {}, &block)
              @name = name
              @every = options.delete(:every).to_i
      
              @times = options.delete(:times) || 1
      Severity: Minor
      Found in lib/cognizant/process/condition_delegate.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 _start_result_handler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def _start_result_handler(result, time_left = 0)
                if result.respond_to?(:succeeded?) and result.succeeded?
                  write_pid(result.pid) if self.daemonize and result.pid != 0
                end
      
      
      Severity: Minor
      Found in lib/cognizant/process/actions/start.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 record_transition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def record_transition(transition)
            unless transition.loopback?
              @transitioned = true
              @last_transition_time = Time.now.to_i
      
      
      Severity: Minor
      Found in lib/cognizant/process.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 run_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def run_command(command, args, &block)
            command = command.to_s
      
            begin
              response = @client.command({'command' => command, 'args' => args, 'app' => @app})
      Severity: Minor
      Found in lib/cognizant/shell.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