reevoo/sapience-rb

View on GitHub
lib/sapience/formatters/color.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

      def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
        colors      = Sapience::AnsiColors
        level_color = colors::LEVEL_MAP[log.level]


Severity: Minor
Found in lib/sapience/formatters/color.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 call has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
        colors      = Sapience::AnsiColors
        level_color = colors::LEVEL_MAP[log.level]


Severity: Minor
Found in lib/sapience/formatters/color.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

Line is too long. [97/80]
Open

      def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

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

        message += " " + log.tags.collect { |tag| "[#{level_color}#{tag}#{colors::CLEAR}]" }.join(" ") if log.tags && !log.tags.empty? # rubocop:disable LineLength
Severity: Minor
Found in lib/sapience/formatters/color.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

        message = time_format.nil? ? "" : "#{format_time(log.time)} "
Severity: Minor
Found in lib/sapience/formatters/color.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. [92/80]
Open

        message += " (#{colors::BOLD}#{log.duration_human}#{colors::CLEAR})" if log.duration
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

Line is too long. [102/80]
Open

                       payload.ai(@ai_options) rescue payload.inspect # rubocop:disable RescueModifier
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

Missing top-level class documentation comment.
Open

    class Color < Base
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

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

        message += " " + log.tags.collect { |tag| "[#{level_color}#{tag}#{colors::CLEAR}]" }.join(" ") if log.tags && !log.tags.empty? # rubocop:disable LineLength
Severity: Minor
Found in lib/sapience/formatters/color.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

          message += " -- "
Severity: Minor
Found in lib/sapience/formatters/color.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"

Add an empty line after magic comments.
Open

# Load AwesomePrint if available
Severity: Minor
Found in lib/sapience/formatters/color.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

Extra blank line detected.
Open


        message = time_format.nil? ? "" : "#{format_time(log.time)} "
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Line is too long. [90/80]
Open

        message += "#{level_color}#{log.level_to_s}#{colors::CLEAR} [#{log.process_info}]"
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

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

  require "awesome_print"
Severity: Minor
Found in lib/sapience/formatters/color.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. [119/80]
Open

          message += " -- Exception: #{colors::BOLD}#{log.exception.class}: #{log.exception.message}#{colors::CLEAR}\n"
Severity: Minor
Found in lib/sapience/formatters/color.rb by rubocop

There are no issues that match your filters.

Category
Status