payout/announcer

View on GitHub
lib/announcer/plugins/logging_plugin.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

      def _load_level
        case config.level
        when :info, nil
          Logger::INFO
        when :warn

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 has too many lines. [12/10]
Open

      def _run(subject, object, &block)
        logger.debug("#{subject}: #{object}")

        if config.log_exceptions?
          begin

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.

Use yield instead of block.call.
Open

            block.call

This cop identifies the use of a &block parameter and block.call where yield would do just as well.

Example:

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

Use yield instead of block.call.
Open

          block.call

This cop identifies the use of a &block parameter and block.call where yield would do just as well.

Example:

# bad
def method(&block)
  block.call
end
def another(&func)
  func.call 1, 2, 3
end

# good
def method
  yield
end
def another
  yield 1, 2, 3
end

Missing top-level class documentation comment.
Open

    class LoggingPlugin < Plugin

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

Line is too long. [93/80]
Open

          raise Errors::PluginError, "Invalid plugins.logging.level: #{config.level.inspect}"

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

          rescue Exception => e
            logger.fatal("Exception raised when #{subject.downcase} #{object}: #{e.inspect}")
            raise

This cop checks for rescue blocks targeting the Exception class.

Example:

# bad

begin
  do_something
rescue Exception
  handle_exception
end

Example:

# good

begin
  do_something
rescue ArgumentError
  handle_exception
end

Keep a blank line before and after private.
Open

      private

Access modifiers should be surrounded by blank lines.

Example:

# bad
class Foo
  def bar; end
  private
  def baz; end
end

# good
class Foo
  def bar; end

  private

  def baz; end
end

Unused block argument - event. If it's necessary, use _ or _event as an argument name to indicate that it won't be used.
Open

      around_subscription do |sub, event|

This cop checks for unused block arguments.

Example:

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Example:

#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Line is too long. [93/80]
Open

            logger.fatal("Exception raised when #{subject.downcase} #{object}: #{e.inspect}")

Avoid using {...} for multi-line blocks.
Open

          Logger.new(STDOUT).tap { |logger|

Check for uses of braces or do/end around single line or multi-line blocks.

Example: EnforcedStyle: linecountbased (default)

# bad - single line block
items.each do |item| item / 5 end

# good - single line block
items.each { |item| item / 5 }

# bad - multi-line block
things.map { |thing|
  something = thing.some_method
  process(something)
}

# good - multi-line block
things.map do |thing|
  something = thing.some_method
  process(something)
end

Example: EnforcedStyle: semantic

# Prefer `do...end` over `{...}` for procedural blocks.

# return value is used/assigned
# bad
foo = map do |x|
  x
end
puts (map do |x|
  x
end)

# return value is not used out of scope
# good
map do |x|
  x
end

# Prefer `{...}` over `do...end` for functional blocks.

# return value is not used out of scope
# bad
each { |x|
  x
}

# return value is used/assigned
# good
foo = map { |x|
  x
}
map { |x|
  x
}.inspect

Example: EnforcedStyle: bracesforchaining

# bad
words.each do |word|
  word.flip.flop
end.join("-")

# good
words.each { |word|
  word.flip.flop
}.join("-")

There are no issues that match your filters.

Category
Status