zeisler/active_mocker

View on GitHub
lib/active_mocker/mock_creator/defined_methods.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method has too many lines. [20/10] (https://github.com/bbatsov/ruby-style-guide#short-methods)
Open

      def create_method(m, type)
        plural_type = (type.to_s + "s").to_sym
        if safe_method?(type, m)
          def_type   = type == :method ? :class_defs : :defs
          def_method = class_introspector.parsed_source.public_send(def_type).detect { |meth| meth.name == m }

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.

Assignment Branch Condition size for create_method is too high. [23.69/15] (http://c2.com/cgi/wiki?AbcMetric)
Open

      def create_method(m, type)
        plural_type = (type.to_s + "s").to_sym
        if safe_method?(type, m)
          def_type   = type == :method ? :class_defs : :defs
          def_method = class_introspector.parsed_source.public_send(def_type).detect { |meth| meth.name == m }

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method create_method has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def create_method(m, type)
        plural_type = (type.to_s + "s").to_sym
        if safe_method?(type, m)
          def_type   = type == :method ? :class_defs : :defs
          def_method = class_introspector.parsed_source.public_send(def_type).detect { |meth| meth.name == m }
Severity: Minor
Found in lib/active_mocker/mock_creator/defined_methods.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

Put a comma after the last parameter of a multiline method call. (https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma)
Open

            def_method.body

This cop checks for trailing comma in argument lists.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
method(1, 2,)

# good
method(
  1, 2,
  3,
)

# good
method(
  1,
  2,
)

Example: EnforcedStyleForMultiline: comma

# bad
method(1, 2,)

# good
method(
  1,
  2,
)

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
method(1, 2,)

# good
method(
  1,
  2
)

Put a comma after the last parameter of a multiline method call. (https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma)
Open

              class_introspector.get_class.send(type, m).parameters

This cop checks for trailing comma in argument lists.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
method(1, 2,)

# good
method(
  1, 2,
  3,
)

# good
method(
  1,
  2,
)

Example: EnforcedStyleForMultiline: comma

# bad
method(1, 2,)

# good
method(
  1,
  2,
)

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
method(1, 2,)

# good
method(
  1,
  2
)

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

require_relative "safe_methods"

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

Put a comma after the last parameter of a multiline method call. (https://github.com/bbatsov/ruby-style-guide#no-trailing-params-comma)
Open

            "__am_raise_not_mocked_error(method: __method__, caller: Kernel.caller, type: '#{type_symbol}')"

This cop checks for trailing comma in argument lists.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
method(1, 2,)

# good
method(
  1, 2,
  3,
)

# good
method(
  1,
  2,
)

Example: EnforcedStyleForMultiline: comma

# bad
method(1, 2,)

# good
method(
  1,
  2,
)

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
method(1, 2,)

# good
method(
  1,
  2
)

There are no issues that match your filters.

Category
Status