gree/observed

View on GitHub

Showing 14 of 14 total issues

Method at_key_path_on_hash has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def at_key_path_on_hash(hash, key_path, options = {}, &block)
        create_if_missing = options[:create_if_missing]

        if create_if_missing.nil?
          fail "The key :create_if_missing must be exist in #{options}"
Severity: Minor
Found in lib/observed/hash/key_path_encoding.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 convert_to_task has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def convert_to_task(underlying)
      if underlying.is_a? Observed::Observer
        @task_factory.task {|data, options|
          options ||= {}
          m = underlying.method(:observe)
Severity: Minor
Found in lib/observed/observed_task_factory.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 at_key_path_on_hash has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def at_key_path_on_hash(hash, key_path, options = {}, &block)
        create_if_missing = options[:create_if_missing]

        if create_if_missing.nil?
          fail "The key :create_if_missing must be exist in #{options}"
Severity: Minor
Found in lib/observed/hash/key_path_encoding.rb - About 1 hr to fix

    Method observe has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def observe(tag=nil, args={}, &block)
          if tag.is_a? ::Hash
            args = tag
            tag = nil
          end
    Severity: Minor
    Found in lib/observed/config_builder.rb - About 1 hr to fix

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

          def notify_listener(args)
            return unless @listener
      
            data = args[:data]
            options = args[:options]
      Severity: Minor
      Found in lib/observed/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

      Consider simplifying this complex logical expression.
      Open

            observer = if args[:via] || args[:using]
                         via = args[:via] || args[:using] ||
                             fail(RuntimeError, %Q|Missing observer plugin name for the tag "#{tag}" in "#{args}"|)
                         with = args[:with] || args[:which] || {}
                         plugin = observer_plugins[via] ||
      Severity: Major
      Found in lib/observed/config_builder.rb - About 1 hr to fix

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

            def run(observation_name=nil, data=nil, options=nil)
              options = { tag: (options && options[:tag]) || observation_name, time: now }.merge(options || {})
              params = [data, options]
              if observation_name
                fail "No configuration found for observation name '#{observation_name}'" if @context.config_builder.group(observation_name).empty?
        Severity: Minor
        Found in lib/observed/system.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 report has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def report(tag, time, data=nil)
              options = nil
              if tag.is_a?(::Hash)
                data = tag
                options = time || {}
        Severity: Minor
        Found in lib/observed/observed_task_factory.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

        Consider simplifying this complex logical expression.
        Open

              reporter = if args[:via] || args[:using]
                           via = args[:via] || args[:using]
                           with = args[:with] || args[:which] || {}
                           with = ({logger: @logger}).merge(with).merge({tag_pattern: tag_pattern, system: system})
                           plugin = reporter_plugins[via] ||
        Severity: Major
        Found in lib/observed/config_builder.rb - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                translator = if args[:via] || args[:using]
                               #tag_pattern || fail("Tag pattern missing: #{tag_pattern} where args: #{args}")
                               via = args[:via] || args[:using]
                               with = args[:with] || args[:which] || {}
                               with = ({logger: logger}).merge(with).merge({system: system})
          Severity: Major
          Found in lib/observed/config_builder.rb - About 40 mins to fix

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

                def observe(tag=nil, args={}, &block)
                  if tag.is_a? ::Hash
                    args = tag
                    tag = nil
                  end
            Severity: Minor
            Found in lib/observed/config_builder.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def create(args)
                      ctx = Observed::Context.new(args)
                      sys = ctx.system
                      config = if args[:yaml_file]
                                 YAML.load_file(args[:yaml_file])
            Severity: Minor
            Found in lib/observed/application/oneshot.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 time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def time(options={}, &block)
                    timeout_in_seconds = options[:timeout_in_seconds] ||
                        fail("The key `:timeout_in_seconds` must be exist in the options: #{options}")
            
                    begin
            Severity: Minor
            Found in lib/observed/observer_helpers/timer.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 report has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def report(tag_pattern=nil, args={}, &block)
                  if tag_pattern.is_a? ::Hash
                    args = tag_pattern
                    tag_pattern = nil
                  end
            Severity: Minor
            Found in lib/observed/config_builder.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