myfreecomm/nexaas-throttle

View on GitHub
lib/nexaas/throttle/middleware.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

      throttled = throttles.any? do |name, throttle|
Severity: Minor
Found in lib/nexaas/throttle/middleware.rb by rubocop

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

Redundant self detected.
Open

    self.cache.store = ActiveSupport::Cache::RedisStore.new(configuration.redis_options)
Severity: Minor
Found in lib/nexaas/throttle/middleware.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

There are no issues that match your filters.

Category
Status