chingor13/json_api_client

View on GitHub

Showing 15 of 15 total issues

Class Resource has 72 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Resource
    extend ActiveModel::Naming
    extend ActiveModel::Translation
    include ActiveModel::Validations
    include ActiveModel::Conversion
Severity: Major
Found in lib/json_api_client/resource.rb - About 1 day to fix

    File resource.rb has 454 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'forwardable'
    require 'active_support/all'
    require 'active_model'
    
    module JsonApiClient
    Severity: Minor
    Found in lib/json_api_client/resource.rb - About 6 hrs to fix

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

          class Builder
      
            attr_reader :klass
            delegate :key_formatter, to: :klass
      
      
      Severity: Minor
      Found in lib/json_api_client/query/builder.rb - About 4 hrs to fix

        Class NestedParamPaginator has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class NestedParamPaginator
              DEFAULT_WRAPPER_NAME = "page".freeze
              DEFAULT_PAGE_PARAM = "page".freeze
              DEFAULT_PER_PAGE_PARAM = "per_page".freeze
        
        
        Severity: Minor
        Found in lib/json_api_client/paginating/nested_param_paginator.rb - About 2 hrs to fix

          Method save has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def save
                return false unless valid?
                raise JsonApiClient::Errors::ResourceImmutableError if _immutable
          
                self.last_result_set = if persisted?
          Severity: Minor
          Found in lib/json_api_client/resource.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 compute_type has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.compute_type(klass, type_name)
                return klass.custom_type_to_class.fetch(type_name).constantize if klass.custom_type_to_class.key?(type_name)
                # If the type is prefixed with a scope operator then we assume that
                # the type_name is an absolute reference.
                return type_name.constantize if type_name.match(/^::/)
          Severity: Minor
          Found in lib/json_api_client/utils.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 handle_status has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def handle_status(code, env)
                  custom_handler = custom_handler_for(code)
                  return custom_handler.call(env) if custom_handler.present?
          
                  case code
          Severity: Minor
          Found in lib/json_api_client/middleware/status.rb - About 1 hr to fix

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

                  def track_json_api_errors(msg)
                    return msg unless env.try(:body).kind_of?(Hash) || env.body.key?('errors')
            
                    errors_msg = env.body['errors'].map { |e| e['title'] }.compact.join('; ').presence
                    return msg unless errors_msg
            Severity: Minor
            Found in lib/json_api_client/errors.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 method_missing has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def method_missing(method, *args, &block)
                    if method.to_s =~ /^(.*)_changed\?$/
                      has_attribute?($1) ? attribute_changed?($1) : nil
                    elsif method.to_s =~ /^(.*)_was$/
                      has_attribute?($1) ? attribute_was($1) : nil
            Severity: Minor
            Found in lib/json_api_client/helpers/dirty.rb - About 55 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 relationship_data_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def relationship_data_for(name, relationship_definition)
                  # look in included data
                  if relationship_definition.key?("data")
                    if relationships.attribute_changed?(name)
                      return relation_objects_for(name, relationship_definition)
            Severity: Minor
            Found in lib/json_api_client/resource.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 parse_orders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def parse_orders(*args)
                    args.map do |arg|
                      case arg
                      when Hash
                        arg.map do |k, v|
            Severity: Minor
            Found in lib/json_api_client/query/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 setup_default_properties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def setup_default_properties
                  self.class.schema.each_property do |property|
                    unless attributes.has_key?(property.name) || property.default.nil?
                      attribute_will_change!(property.name) if add_defaults_to_changes
                      attributes[property.name] = property.default
            Severity: Minor
            Found in lib/json_api_client/resource.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 path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def path(params = nil)
                    parts = [resource_path]
                    if params && _prefix_path.present?
                      path_params = params.delete(:path) || params
                      parts.unshift(_set_prefix_path(path_params.symbolize_keys))
            Severity: Minor
            Found in lib/json_api_client/resource.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 cast has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def cast(value)
                    return nil if value.nil?
                    return value if type.nil?
                    type_caster = TypeFactory.type_for(type)
                    return value if type_caster.nil?
            Severity: Minor
            Found in lib/json_api_client/schema.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 select_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def select_params
                    if @fields.empty?
                      {}
                    else
                      field_result = Hash.new { |h,k| h[k] = [] }
            Severity: Minor
            Found in lib/json_api_client/query/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

            Severity
            Category
            Status
            Source
            Language