reevoo/sapience-rb

View on GitHub
lib/sapience/log.rb

Summary

Maintainability
C
1 day
Test Coverage

Module has too many lines. [149/100]
Open

module Sapience
  # Log Struct
  #
  #   Structure for holding all log entries. We're using a struct because we want it to be fast and lightweight.
  #
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Block has too many lines. [146/25]
Open

  Log = Struct.new(:level, :thread_name, :name, :message, :payload, :time, :duration, :tags, :level_index, :exception, :metric, :backtrace, :metric_amount) do
    MAX_EXCEPTIONS_TO_UNWRAP = 5
    MILLISECONDS_IN_SECOND =   1_000
    MILLISECONDS_IN_MINUTE = 60_000
    MILLISECONDS_IN_HOUR = 3_600_000
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method has too many lines. [43/10]
Open

    def to_h(host = Sapience.config.host, app_name = Sapience.app_name, environment = Sapience.environment) # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity, LineLength
      # Header
      h = {
        name:        name,
        pid:         $PROCESS_ID,
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method to_h has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def to_h(host = Sapience.config.host, app_name = Sapience.app_name, environment = Sapience.environment) # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity, LineLength
      # Header
      h = {
        name:        name,
        pid:         $PROCESS_ID,
Severity: Minor
Found in lib/sapience/log.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 has too many lines. [20/10]
Open

    def duration_human # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
      return nil unless duration
      days, ms    = duration.divmod(MILLISECONDS_IN_DAY)
      hours, ms   = ms.divmod(MILLISECONDS_IN_HOUR)
      minutes, ms = ms.divmod(MILLISECONDS_IN_MINUTE)
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method duration_human has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def duration_human # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity
      return nil unless duration
      days, ms    = duration.divmod(MILLISECONDS_IN_DAY)
      hours, ms   = ms.divmod(MILLISECONDS_IN_HOUR)
      minutes, ms = ms.divmod(MILLISECONDS_IN_MINUTE)
Severity: Minor
Found in lib/sapience/log.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 has too many lines. [16/10]
Open

    def each_exception # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
      # With thanks to https://github.com/bugsnag/bugsnag-ruby/blob/6348306e44323eee347896843d16c690cd7c4362/lib/bugsnag/notification.rb#L81
      depth      = 0
      exceptions = []
      ex         = exception
Severity: Minor
Found in lib/sapience/log.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method to_h has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def to_h(host = Sapience.config.host, app_name = Sapience.app_name, environment = Sapience.environment) # rubocop:disable AbcSize, CyclomaticComplexity, PerceivedComplexity, LineLength
      # Header
      h = {
        name:        name,
        pid:         $PROCESS_ID,
Severity: Minor
Found in lib/sapience/log.rb - About 1 hr to fix

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

        def payload # rubocop:disable AbcSize
          return self[:payload] unless self[:payload].is_a?(Hash) && self[:payload][:params].is_a?(Hash)
          @payload ||= nil
          return @payload unless @payload.nil?
    
    
    Severity: Minor
    Found in lib/sapience/log.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 file_name_and_line has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def file_name_and_line(short_name = false) # rubocop:disable CyclomaticComplexity
          return unless backtrace || (exception && exception.backtrace) # rubocop: disable Style/SafeNavigation
          stack = backtrace || exception.backtrace
          extract_file_and_line(stack, short_name) if stack && !stack.empty?
        end
    Severity: Minor
    Found in lib/sapience/log.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 each_exception has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def each_exception # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
          # With thanks to https://github.com/bugsnag/bugsnag-ruby/blob/6348306e44323eee347896843d16c690cd7c4362/lib/bugsnag/notification.rb#L81
          depth      = 0
          exceptions = []
          ex         = exception
    Severity: Minor
    Found in lib/sapience/log.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 duration_to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def duration_to_s
          return unless duration
          format((duration < 10.0 ? "%.3fms" : "%.1fms"), duration)
        end
    Severity: Minor
    Found in lib/sapience/log.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 backtrace_to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def backtrace_to_s
          trace = ""
          each_exception do |exception, i|
            if i == 0
              trace += (exception.backtrace || []).join("\n")
    Severity: Minor
    Found in lib/sapience/log.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

    Use hours.positive? instead of hours > 0.
    Open

          str += " #{hours}h" if hours > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Avoid comma after the last item of a hash.
    Open

            environment: environment,
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for trailing comma in array and hash literals.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1, 2,
      3,
    ]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2
    ]

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          format((duration < 10.0 ? "%.3fms" : "%.1fms"), duration)
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Line is too long. [98/80]
    Open

      #   The backtrace_level captured at source when the log level >= Sapience.config.backtrace_level
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Avoid comma after the last item of a hash.
    Open

                stack_trace: exception.backtrace,
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for trailing comma in array and hash literals.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1, 2,
      3,
    ]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2
    ]

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

            @payload[:params][filter] = "[FILTERED]" if @payload[:params].key?(filter)
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Use seconds.positive? instead of seconds > 0.
    Open

          str += " #{seconds}s" if seconds > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Use days.positive? instead of days > 0.
    Open

          if days > 0 || hours > 0 || minutes > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

              format "%.3fs", duration / MILLISECONDS_IN_SECOND.to_f
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings inside interpolations.
    Open

          format("#{time.strftime("%Y-%m-%d %H:%M:%S")}.%06d", time.usec) # rubocop: disable Style/FormatStringToken
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks that quotes inside the string interpolation match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    result = "Tests #{success ? "PASS" : "FAIL"}"
    
    # good
    result = "Tests #{success ? 'PASS' : 'FAIL'}"

    Example: EnforcedStyle: double_quotes

    # bad
    result = "Tests #{success ? 'PASS' : 'FAIL'}"
    
    # good
    result = "Tests #{success ? "PASS" : "FAIL"}"

    Use i.zero? instead of i == 0.
    Open

            if i == 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Use ms.positive? instead of ms > 0.
    Open

          str += " #{ms}ms" if ms > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Use i.zero? instead of i == 0.
    Open

              name       = i == 0 ? :exception : :cause
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Use hours.positive? instead of hours > 0.
    Open

          if days > 0 || hours > 0 || minutes > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Use minutes.positive? instead of minutes > 0.
    Open

          str += " #{minutes}m" if minutes > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Add an empty line after magic comments.
    Open

    module Sapience
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks for a newline after the final magic comment.

    Example:

    # good
    # frozen_string_literal: true
    
    # Some documentation for Person
    class Person
      # Some code
    end
    
    # bad
    # frozen_string_literal: true
    # Some documentation for Person
    class Person
      # Some code
    end

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          format((duration < 10.0 ? "%.3fms" : "%.1fms"), duration)
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Line is too long. [112/80]
    Open

      #   Structure for holding all log entries. We're using a struct because we want it to be fast and lightweight.
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Use days.positive? instead of days > 0.
    Open

          str += "#{days}d" if days > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Use minutes.positive? instead of minutes > 0.
    Open

          if days > 0 || hours > 0 || minutes > 0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          message.to_s.gsub(/(\e(\[([\d;]*[mz]?))?)?/, "").strip
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Convert if nested inside else to elsif.
    Open

            if seconds >= 1.0
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    If the else branch of a conditional consists solely of an if node, it can be combined with the else to become an elsif. This helps to keep the nesting level from getting too deep.

    Example:

    # bad
    if condition_a
      action_a
    else
      if condition_b
        action_b
      else
        action_c
      end
    end
    
    # good
    if condition_a
      action_a
    elsif condition_b
      action_b
    else
      action_c
    end

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          trace = ""
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

          str = ""
    Severity: Minor
    Found in lib/sapience/log.rb by rubocop

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    There are no issues that match your filters.

    Category
    Status