am-kantox/kungfuig

View on GitHub
lib/kungfuig/aspector.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

Severity: Minor
Found in lib/kungfuig/aspector.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 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
Severity: Minor
Found in lib/kungfuig/aspector.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

FIXME found
Open

        # FIXME MOVE JOKER HANDLING INTO PREPENDER !!!!
Severity: Minor
Found in lib/kungfuig/aspector.rb by fixme

FIXME found
Open

          # NOT YET IMPLEMENTED FIXME MOVE TO PREPENDER
Severity: Minor
Found in lib/kungfuig/aspector.rb by fixme

Avoid rescuing without specifying an error class.
Open

          rescue => e
Severity: Minor
Found in lib/kungfuig/aspector.rb by rubocop

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?
Severity: Minor
Found in lib/kungfuig/aspector.rb by rubocop

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?
Severity: Minor
Found in lib/kungfuig/aspector.rb by rubocop

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?
Severity: Minor
Found in lib/kungfuig/aspector.rb by rubocop

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)

There are no issues that match your filters.

Category
Status