nesquena/rabl

View on GitHub
lib/rabl/builder.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class Builder has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Builder
    include Helpers
    include Partials

    SETTING_TYPES = {
Severity: Minor
Found in lib/rabl/builder.rb - About 2 hrs to fix

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

        def to_hash(object = nil, settings = nil, options = nil)
          @_object = object           if object
          @options.merge!(options)    if options
          @settings.merge!(settings)  if settings
    
    
    Severity: Minor
    Found in lib/rabl/builder.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 merge_engines_into_result has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def merge_engines_into_result
            engines.each do |engine|
              case engine
              when Hash
                # engine was stored in the form { name => #<Engine> }
    Severity: Minor
    Found in lib/rabl/builder.rb - About 45 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 child has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def child(data, options = {}, &block)
            return unless data.present? && resolve_condition(options)
    
            name   = is_name_value?(options[:root]) ? options[:root] : data_name(data)
            object = data_object(data)
    Severity: Minor
    Found in lib/rabl/builder.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 node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def node(name, options = {}, &block)
            return unless resolve_condition(options)
            return if @options.has_key?(:except) && [@options[:except]].flatten.include?(name)
    
            result = block.call(@_object)
    Severity: Minor
    Found in lib/rabl/builder.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 deep_replace_empty_string_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def deep_replace_empty_string_values(hash)
            hash.inject({}) do |new_hash, (k, v)|
              new_hash[k] = if v.is_a?(Hash)
                deep_replace_empty_string_values(v)
              else
    Severity: Minor
    Found in lib/rabl/builder.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