Method attach
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def attach(to, before: nil, after: nil, exclude: nil)
fail ArgumentError, "Trying to attach nothing to #{klazz}##{to}. I need a block!" unless block_given?
cb = Proc.new
- Read upRead up
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 bulk
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bulk(hos)
Kungfuig.load_stuff(hos).map do |klazz, hash|
next if hash.empty?
[klazz, H.new.remap_hash_for_easy_iteration(hash).map do |handler, methods|
begin
- Read upRead up
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
FIXME found Open
# FIXME MOVE JOKER HANDLING INTO PREPENDER !!!!
- Exclude checks
FIXME found Open
# NOT YET IMPLEMENTED FIXME MOVE TO PREPENDER
- Exclude checks
Avoid rescuing without specifying an error class. Open
rescue => e
- Read upRead up
- Exclude checks
This cop checks for rescuing StandardError
. There are two supported
styles implicit
and explicit
. This cop will not register an offense
if any error other than StandardError
is specified.
Example: EnforcedStyle: implicit
# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.
# bad
begin
foo
rescue StandardError
bar
end
# good
begin
foo
rescue
bar
end
# good
begin
foo
rescue OtherError
bar
end
# good
begin
foo
rescue StandardError, SecurityError
bar
end
Example: EnforcedStyle: explicit (default)
# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.
# bad
begin
foo
rescue
bar
end
# good
begin
foo
rescue StandardError
bar
end
# good
begin
foo
rescue OtherError
bar
end
# good
begin
foo
rescue StandardError, SecurityError
bar
end
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
hash = hash.each_with_object(Hashie::Mash.new) do |(k, v), memo|
v.each { |m, c| memo.public_send("#{m}!")[k] = c }
end unless (hash.keys - %w(before after exclude)).empty?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
H.new.value_to_method_list(klazz, var, exclude).each do |m|
Kungfuig::Prepender.new(to, m).public_send(k, &cb).hook!
end unless var.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
%w
-literals should be delimited by [
and ]
. Open
end unless (hash.keys - %w(before after exclude)).empty?
- Read upRead up
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)