vadv/kurchatov

View on GitHub

Showing 15 of 17 total issues

Method load_plugins has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def self.load_plugins(plugins_path, config_file)
        Log.error("Config file #{config_file} not found") and
            exit(Kurchatov::Config[:ERROR_CONFIG]) unless File.exists?(config_file)
        @all_plugins = Kurchatov::Plugins::DSL.load_riemann_plugins(plugins_path)
        @all_names = Array.new
Severity: Minor
Found in lib/kurchatov/plugin/config.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 load_plugins has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.load_plugins(plugins_path, config_file)
        Log.error("Config file #{config_file} not found") and
            exit(Kurchatov::Config[:ERROR_CONFIG]) unless File.exists?(config_file)
        @all_plugins = Kurchatov::Plugins::DSL.load_riemann_plugins(plugins_path)
        @all_names = Array.new
Severity: Minor
Found in lib/kurchatov/plugin/config.rb - About 1 hr to fix

    Method normalize_event has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def normalize_event(hash = {})
    
            hash[:description] = hash[:desc] if hash[:description].nil? && hash[:desc]
            hash[:metric] = hash[:metric].to_f if hash[:metric].kind_of?(String)
            if hash[:metric].kind_of?(Float)
    Severity: Minor
    Found in lib/kurchatov/mixin/event.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 runnable_by_config? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def runnable_by_config?
            Log.info("Plugin '#{self.name}' disabled by run and collect nil") and return if (collect.nil? && run.nil?)
            Log.info("Plugin '#{self.name}' disabled in config") and return if (plugin[:disable] == true)
            Log.info("Plugin '#{self.name}' not started by run_if condition ") and
                return unless self.instance_eval(&run_if)
    Severity: Minor
    Found in lib/kurchatov/plugin/riemann.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 set_avg_metric has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_avg_metric(hash ={})
    
            return if hash[:avg].nil? || hash[:avg].to_i != hash[:avg]
            return if hash[:service].nil?
            return if hash[:metric].nil?
    Severity: Minor
    Found in lib/kurchatov/mixin/event.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 set_diff_metric has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_diff_metric(hash ={})
    
            hash[:diff] ||= hash[:as_diff] if hash[:as_diff]
    
            return if hash[:diff].nil? && !hash[:diff]
    Severity: Minor
    Found in lib/kurchatov/mixin/event.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 load_riemann_plugins has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.load_riemann_plugins(paths)
            dsl = Kurchatov::Plugins::DSL.new
            paths = [paths] unless paths.kind_of? Array
            paths.map do |path|
              Log.error("Directory #{path} not exists") and exit Kurchatov::Config[:ERROR_CONFIG] unless
    Severity: Minor
    Found in lib/kurchatov/plugin/dsl.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 get_monit_points_for_fstab has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_monit_points_for_fstab
        monit_points = []
        File.open('/proc/mounts', 'r') do |file|
          while (line = file.gets)
            mtab = line.split(/\s+/)
    Severity: Minor
    Found in examples/disk.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 get_monit_points_for_size has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_monit_points_for_size
        monit_points = []
        File.open('/proc/mounts', 'r') do |file|
          while (line = file.gets)
            mtab = line.split(/\s+/)
    Severity: Minor
    Found in examples/disk.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 get_failed_parts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_failed_parts (device)
        begin
          failed_parts = []
          Dir["/sys/block/#{device}/md/dev-*"].each do |p|
            state = File.read("#{p}/state").strip
    Severity: Minor
    Found in examples/mdadm.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 deep_update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def deep_update(other_hash, &blk)
        other_hash.each_pair do |k, v|
          key = convert_key(k)
          if regular_reader(key).is_a?(Mash) and v.is_a?(::Hash)
            custom_reader(key).deep_update(v, &blk)
    Severity: Minor
    Found in lib/kurchatov/mashie.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 convert_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def convert_value(val, duping=false) #:nodoc:
        case val
          when self.class
            val.dup
          when Hash
    Severity: Minor
    Found in lib/kurchatov/mashie.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 start! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def start!
          loop do
            tasks.each do |task|
              task.start! if task.died?
              if task.stopped?
    Severity: Minor
    Found in lib/kurchatov/monitor.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 set_event_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_event_state(hash = {})
            return if hash[:state]
            return if hash[:critical].nil? && hash[:warning].nil?
            return if hash[:metric].nil?
            hash[:state] = 'ok'
    Severity: Minor
    Found in lib/kurchatov/mixin/event.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 died? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def died?
            if @thread.alive?
              @last_error_count = 0
              return false 
            end
    Severity: Minor
    Found in lib/kurchatov/monitor.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