bluepill-rb/bluepill

View on GitHub

Showing 35 of 43 total issues

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

    def initialize(process_name, checks, options = {})
      @name = process_name
      @event_mutex = Monitor.new
      @watches = []
      @triggers = []
Severity: Minor
Found in lib/bluepill/process.rb - About 1 hr to fix

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

        def handle_command(application, command, *args)
          case command.to_sym
          when :status
            puts send_to_daemon(application, :status, *args)
          when :quit
    Severity: Minor
    Found in lib/bluepill/controller.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 redirect_io has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def redirect_io(io_in, io_out, io_err)
          $stdin.reopen(io_in) if io_in
    
          if !io_out.nil? && !io_err.nil? && io_out == io_err
            $stdout.reopen(io_out, APPEND_MODE)
    Severity: Minor
    Found in lib/bluepill/system.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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def method_missing(name, *args)
          if args.size == 1 && name.to_s =~ /^(.*)=$/
            @attributes[Regexp.last_match[1].to_sym] = args.first
          elsif args.size == 1
            @attributes[name.to_sym] = args.first
    Severity: Minor
    Found in lib/bluepill/dsl/process_proxy.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 run_watches has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_watches
          now = Time.now.to_i
    
          threads = watches.collect do |watch|
            [watch, Thread.new { Thread.current[:events] = watch.run(actual_pid, now) }]
    Severity: Minor
    Found in lib/bluepill/process.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 = {})
          @name = name
    
          @logger = options.delete(:logger)
          @fires  = options.key?(:fires) ? Array(options.delete(:fires)) : [:restart]
    Severity: Minor
    Found in lib/bluepill/condition_watch.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 delete_if_exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete_if_exists(filename)
          tries = 0
    
          begin
            File.unlink(filename) if filename && File.exist?(filename)
    Severity: Minor
    Found in lib/bluepill/system.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 memory_usage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def memory_usage(pid, include_children)
          ps = ps_axu
          return unless ps[pid]
          mem_used = ps[pid][IDX_MAP[:rss]].to_f
          get_children(pid).each do |child_pid|
    Severity: Minor
    Found in lib/bluepill/system.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 restart_process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def restart_process
          if restart_command
            cmd = prepare_command(restart_command)
    
            logger.warning "Executing restart command: #{cmd}"
    Severity: Minor
    Found in lib/bluepill/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 check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def check(value)
            return false unless value.is_a?(@kind)
            return true  unless @pattern
            return false unless value.class.body_permitted?
            @pattern =~ value.body
    Severity: Minor
    Found in lib/bluepill/process_conditions/http.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(pid, tick_number = Time.now.to_i)
          if @last_ran_at.nil? || (@last_ran_at + @every) <= tick_number
            @last_ran_at = tick_number
    
            begin
    Severity: Minor
    Found in lib/bluepill/condition_watch.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 tick has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def tick
          return if skipping_ticks?
          self.skip_ticks_until = nil
    
          # clear the memoization per tick
    Severity: Minor
    Found in lib/bluepill/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 client_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def client_command(base_dir, name, command)
          res = nil
          MAX_ATTEMPTS.times do |current_attempt|
            begin
              client(base_dir, name) do |socket|
    Severity: Minor
    Found in lib/bluepill/socket.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 check_flapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def check_flapping
            # The process has not flapped if we haven't encountered enough incidents
            return unless @timeline.compact.length == times
    
            # Check if the incident happend within the timeframe
    Severity: Minor
    Found in lib/bluepill/triggers/flapping.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 cpu_usage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def cpu_usage(pid, include_children)
          ps = ps_axu
          return unless ps[pid]
          cpu_used = ps[pid][IDX_MAP[:pcpu]].to_f
          get_children(pid).each do |child_pid|
    Severity: Minor
    Found in lib/bluepill/system.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