nesquena/rabl

View on GitHub

Showing 20 of 32 total issues

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

    Method data_name has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def data_name(data_token)
          return unless data_token # nil or false
    
          return data_token.values.first if data_token.is_a?(Hash) # @user => :user
    
    
    Severity: Minor
    Found in lib/rabl/helpers.rb - About 4 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

    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 fetch_rails_source has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def fetch_rails_source(file, options = {})
              # use Rails template resolution mechanism if possible (find_template)
              source_format = request_format if defined?(request_format)
      
              if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
      Severity: Minor
      Found in lib/rabl/sources.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

      Function exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(api) {
        var validEnv = ['development', 'test', 'production']
        var currentEnv = api.env()
        var isDevelopmentEnv = api.env('development')
        var isProductionEnv = api.env('production')
      Severity: Major
      Found in fixtures/rails6/babel.config.js - About 2 hrs to fix

        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 fetch_source has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_source(file, options = {})
                view_paths = Array(options[:view_path]) + Array(Rabl.configuration.view_paths)
          
                Rabl.source_cache(file, view_paths) do
                  file_path = \
          Severity: Minor
          Found in lib/rabl/sources.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 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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize
                @include_json_root                            = true
                @include_child_root                           = true
                @include_msgpack_root                         = true
                @include_plist_root                           = true
          Severity: Minor
          Found in lib/rabl/configuration.rb - About 1 hr 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 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 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 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 load_rails_gem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def load_rails_gem
                  if version = self.class.gem_version
                    gem 'rails', version
                  else
                    gem 'rails'
            Severity: Minor
            Found in fixtures/rails2/config/boot.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 determine_object_root has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def determine_object_root(data_token, data_name = nil, include_root = true)
                  return if object_root_name == false
            
                  root_name = data_name.to_s if include_root
                  if is_object?(data_token) || data_token.nil?
            Severity: Minor
            Found in lib/rabl/helpers.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 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 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

            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 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

            Severity
            Category
            Status
            Source
            Language