semlogr/semlogr

View on GitHub

Showing 8 of 8 total issues

Method parse_property_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def self.parse_property_token(template, start)
        return [nil, start] unless template[start] == PROPERTY_TOKEN_START

        token = nil
        pos = start
Severity: Minor
Found in lib/semlogr/templates/parser.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 parse_property_token has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.parse_property_token(template, start)
        return [nil, start] unless template[start] == PROPERTY_TOKEN_START

        token = nil
        pos = start
Severity: Minor
Found in lib/semlogr/templates/parser.rb - About 1 hr to fix

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

          def flush
            @flush_mutex.synchronize do
              loop do
                log_events = @queue.pop_count(@batch_size)
                success = emit_batch_with_retries(log_events)
    Severity: Minor
    Found in lib/semlogr/sinks/batching.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.parse(template)
            return Template.empty unless template && !template.empty?
    
            cached_template = @template_cache[template]
            return cached_template if cached_template
    Severity: Minor
    Found in lib/semlogr/templates/parser.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 render_property_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_property_token(output, token, log_event, output_properties)
            case token.property_name
            when :message
              render_message(output, log_event)
            when :severity
    Severity: Minor
    Found in lib/semlogr/sinks/colored_console.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def render(output, properties)
            output <<
              if properties.key?(property_name)
                format_property_value(properties[property_name])
              else
    Severity: Minor
    Found in lib/semlogr/templates/property_token.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 format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def format(log_event)
            output = +''
            output_properties = Properties::OutputProperties.create(log_event)
    
            @template.tokens.each do |token|
    Severity: Minor
    Found in lib/semlogr/formatters/text_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 format_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def format_message(severity, message, error)
            formatted = +"[#{Time.now.iso8601(3)}] #{severity.upcase}: #{message}"
    
            if error
              case error
    Severity: Minor
    Found in lib/semlogr/self_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