stokarenko/ruby-features

View on GitHub

Showing 3 of 3 total issues

Method _apply_methods has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def _apply_methods(target_class)
        target_class_methods = target_class.methods + target_class.private_methods
        target_instance_methods = target_class.instance_methods + target_class.private_instance_methods

        constants.each do |constant|
Severity: Minor
Found in lib/ruby-features/concern/apply_to.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

Method normalize_asserts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def normalize_asserts(asserts)
      asserts.inject({if: {}, unless: {}}) do |mem, (assert_type, asserts_per_type)|
        asserts_per_type = [asserts_per_type] unless asserts_per_type.kind_of?(Array)
        asserts_per_type.each do |assert_per_type|
          assert_per_type = {assert_per_type => true} unless assert_per_type.kind_of?(Hash)
Severity: Minor
Found in lib/ruby-features/conditions.rb - About 35 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 match? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def match?(asserts, normalized = true)
      asserts = normalize_asserts(asserts) unless normalized

      asserts[:if].each do |condition_name, condition_value|
        return false unless value(condition_name) == condition_value
Severity: Minor
Found in lib/ruby-features/conditions.rb - About 35 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

Severity
Category
Status
Source
Language