pboling/dry_views

View on GitHub

Showing 2 of 4 total issues

Method content_for_with_default has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def content_for_with_default(name, *args, &block)
        if content_check = content_for?(name) # returns true, false, or :empty
          content_for_without_empty_check(name) unless content_check == :empty # when content_check is :empty, does nothing
        elsif block_given?
          content_for_without_empty_check(name, yield) # No need to recheck for empty here, as initial condition handles the :empty case
Severity: Minor
Found in lib/dry_views/rails3_two.rb - About 55 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 content_for_with_default has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def content_for_with_default(name, *args, &block)
        if content_check = content_for?(name)
          content_for_without_empty_check(name) unless content_check == :empty
        elsif block_given?
          content_for_without_empty_check(name, yield)
Severity: Minor
Found in lib/dry_views/rails3_zero.rb - About 55 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