gree/observed

View on GitHub
lib/observed/config_builder.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

    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

      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 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

          There are no issues that match your filters.

          Category
          Status