nesquena/rabl

View on GitHub
lib/rabl/engine.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Engine has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Engine
    include Helpers
    include Partials
    include Helpers::Escaper

Severity: Minor
Found in lib/rabl/engine.rb - About 5 hrs to fix

    File engine.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Rabl
      class Engine
        include Helpers
        include Partials
        include Helpers::Escaper
    Severity: Minor
    Found in lib/rabl/engine.rb - About 2 hrs to fix

      Method object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def object(template_data)
            current_data  = (@_locals[:object].nil? || template_data == false) ? template_data : @_locals[:object]
            @_data_object = data_object(current_data)
            @_root_name_data = template_data.is_a?(Hash) && !current_data.is_a?(Hash) ? template_data : current_data
            @_root_name_data = @_root_name_data.values.first if @_root_name_data.is_a?(Hash)
      Severity: Minor
      Found in lib/rabl/engine.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 format_json has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def format_json(json_output)
              unless json_output.is_a?(String)
                json_engine = Rabl.configuration.json_engine
                json_output = if json_engine.respond_to?(:dump)
                  json_engine.dump(json_output)
      Severity: Minor
      Found in lib/rabl/engine.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 root_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def root_name
            return @_data_name if defined?(@_data_name)
      
            @_data_name = @_options[:object_root_name] || begin
              data = defined?(@_root_name_data) ? @_root_name_data : (@_locals[:object].nil? ? root_object : @_locals[:object])
      Severity: Minor
      Found in lib/rabl/engine.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 eval_source has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def eval_source(locals, &block)
              return unless @_source.present?
      
              msg = "cached_source_#{@_source.hash.abs}"
      
      
      Severity: Minor
      Found in lib/rabl/engine.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 request_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def request_format
              format = request_params[:format]
      
              if format.nil? && context_scope.respond_to?(:request)
                request = context_scope.request
      Severity: Minor
      Found in lib/rabl/engine.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