pyrmont/taipo

View on GitHub
lib/taipo/utilities.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method object_to_type_def has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.object_to_type_def(obj)
      return obj.class.name unless obj.is_a? Enumerable

      if obj.is_a? Array
        element_types = Hash.new
Severity: Minor
Found in lib/taipo/utilities.rb - About 2 hrs 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 object_to_type_def has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.object_to_type_def(obj)
      return obj.class.name unless obj.is_a? Enumerable

      if obj.is_a? Array
        element_types = Hash.new
Severity: Minor
Found in lib/taipo/utilities.rb - About 1 hr to fix

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

        def self.throw_error(object:, name:, definition:, result: false)
          subject = (result) ? "The return value of #{name}" : "Object '#{name}'"
    
          if Taipo::Utilities.instance_method? definition
            msg = "#{subject} does not respond to #{definition}."
    Severity: Minor
    Found in lib/taipo/utilities.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

    There are no issues that match your filters.

    Category
    Status