bdurand/lumberjack

View on GitHub

Showing 12 of 26 total issues

File logger.rb has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Lumberjack
  # Logger is a thread safe logging object. It has a compatible API with the Ruby
  # standard library Logger class, the Log4r gem, and ActiveSupport::BufferedLogger.
  #
  # === Example
Severity: Minor
Found in lib/lumberjack/logger.rb - About 3 hrs to fix

    Method add_entry has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_entry(severity, message, progname = nil, tags = nil)
          begin
            severity = Severity.label_to_level(severity) unless severity.is_a?(Integer)
            return true unless device && severity && severity >= level
    
    
    Severity: Minor
    Found in lib/lumberjack/logger.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 add has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def add(klass, formatter = nil, *args, &block)
          formatter ||= block
          if formatter.nil?
            remove(klass)
          else
    Severity: Minor
    Found in lib/lumberjack/formatter.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 call_with_references has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def call_with_references(obj, references)
            if obj.is_a?(Hash)
              with_object_reference(obj, references) do
                hash = {}
                obj.each do |name, value|
    Severity: Minor
    Found in lib/lumberjack/formatter/structured_formatter.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 call_add_entry has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def call_add_entry(severity, message_or_progname_or_tags, progname_or_tags, &block) # :nodoc:
          message = nil
          progname = nil
          tags = nil
          if block
    Severity: Minor
    Found in lib/lumberjack/logger.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 add_entry has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def add_entry(severity, message, progname = nil, tags = nil)
          begin
            severity = Severity.label_to_level(severity) unless severity.is_a?(Integer)
            return true unless device && severity && severity >= level
    
    
    Severity: Minor
    Found in lib/lumberjack/logger.rb - About 1 hr to fix

      Method format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def format(tags)
            return nil if tags.nil?
            if @default_formatter.nil? && (@formatters.empty? || (@formatters.keys & tags.keys).empty?)
              tags
            else
      Severity: Minor
      Found in lib/lumberjack/tag_formatter.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 add has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def add(klass, formatter = nil, *args, &block)
            formatter ||= block
            if formatter.nil?
              remove(klass)
            else
      Severity: Minor
      Found in lib/lumberjack/formatter.rb - About 1 hr to fix

        Method tag_args has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def tag_args(tags, tag_vars)
              return [nil] * (tag_vars.size + 1) if tags.nil? || tags.size == 0
        
              tags_string = +""
              tags.each do |name, value|
        Severity: Minor
        Found in lib/lumberjack/template.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 expand_runtime_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def expand_runtime_values(hash)
                return nil if hash.nil?
                if hash.all? { |key, value| key.is_a?(String) && !value.is_a?(Proc) }
                  return hash
                end
        Severity: Minor
        Found in lib/lumberjack/tags.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 remove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def remove(klass)
              Array(klass).each do |k|
                if k.instance_of?(Module)
                  @module_formatters.delete(k)
                else
        Severity: Minor
        Found in lib/lumberjack/formatter.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 tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def tag(tags, &block)
              tags = Tags.stringify_keys(tags)
              thread_tags = thread_local_value(:lumberjack_logger_tags)
              if block
                merged_tags = (thread_tags ? thread_tags.merge(tags) : tags.dup)
        Severity: Minor
        Found in lib/lumberjack/logger.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