cybernetlab/ensure_it

View on GitHub

Showing 24 of 35 total issues

Method ensure_instance_of has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_instance_of(klass, default: nil, **opts)
      unless klass.is_a?(Class)
        fail(
          ArgumentError,
          'Wrong class argument for #ensure_instance_of specified'
Severity: Minor
Found in lib/ensure_it/ensure_instance_of.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

Method ensure_boolean has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_boolean(default: nil, numbers: true, positive: false, **opts)
      return positive == true ? self > 0 : self != 0 if numbers == true
      default
    end
Severity: Minor
Found in lib/ensure_it/ensure_boolean.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

Method message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def message
      unless @message.is_a?(String)
        @message =
          if @subject.nil? && @subject_type != :unknown_method_result
            '#{subject}'
Severity: Minor
Found in lib/ensure_it/errors.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

Method ensure_instance_of! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_instance_of!(klass, **opts)
      unless klass.is_a?(Class)
        fail(
          ArgumentError,
          'Wrong class argument for #ensure_instance_of specified'
Severity: Minor
Found in lib/ensure_it/ensure_instance_of.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

Severity
Category
Status
Source
Language