cerebris/jsonapi-resources

View on GitHub

Showing 105 of 156 total issues

Method parse_fields has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_fields(resource_klass, fields)
      extracted_fields = {}

      return extracted_fields if fields.nil?

Severity: Minor
Found in lib/jsonapi/request.rb - About 3 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 verify_key has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def verify_key(key, context = nil)
        key_type = resource_key_type

        case key_type
        when :integer
Severity: Minor
Found in lib/jsonapi/basic_resource.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 find_related_monomorphic_fragments has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

      def find_related_monomorphic_fragments(source_fragments, relationship, options, connect_source_identity)
        filters = options.fetch(:filters, {})
        source_ids = source_fragments.collect {|item| item.identity.id}

        include_directives = options.fetch(:include_directives, {})
Severity: Minor
Found in lib/jsonapi/active_relation_resource.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 perform_joins has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def perform_joins(records, options)
        join_array = flatten_join_tree_by_depth

        join_array.each do |level_joins|
          level_joins.each do |join_details|
Severity: Minor
Found in lib/jsonapi/active_relation/join_manager.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

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

  class Processor
    include Callbacks
    define_jsonapi_resources_callbacks :find,
                                       :show,
                                       :show_relationship,
Severity: Minor
Found in lib/jsonapi/processor.rb - About 2 hrs to fix

    Method attribute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def attribute(attribute_name, options = {})
            _clear_cached_attribute_options
            _clear_fields_cache
    
            attr = attribute_name.to_sym
    Severity: Minor
    Found in lib/jsonapi/basic_resource.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 find_fragments has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def find_fragments(filters, options = {})
            include_directives = options.fetch(:include_directives, {})
            resource_klass = self
    
            fragments = {}
    Severity: Minor
    Found in lib/jsonapi/active_relation_resource.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

    File acts_as_resource_controller.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'csv'
    
    module JSONAPI
      module ActsAsResourceController
        MEDIA_TYPE_MATCHER = /.+".+"[^,]*|[^,]+/
    Severity: Minor
    Found in lib/jsonapi/acts_as_resource_controller.rb - About 2 hrs to fix

      Method verify_permitted_params has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def verify_permitted_params(params, allowed_fields)
            formatted_allowed_fields = allowed_fields.collect { |field| format_key(field).to_sym }
            params_not_allowed = []
      
            params.each do |key, value|
      Severity: Major
      Found in lib/jsonapi/request.rb - About 2 hrs to fix

        Method update_links has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_links(serializer, result)
              @top_level_links.merge!(result.links)
        
              # Build pagination links
              if result.is_a?(JSONAPI::ResourceSetOperationResult) ||
        Severity: Minor
        Found in lib/jsonapi/response_document.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 show_related_resources has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def show_related_resources
              source_klass = params[:source_klass]
              source_id = params[:source_id]
              relationship_type = params[:relationship_type]
              filters = params[:filters]
        Severity: Minor
        Found in lib/jsonapi/processor.rb - About 1 hr to fix

          Method add_resources_to_tree has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_resources_to_tree(resource_klass,
                                        tree,
                                        resources,
                                        include_related,
                                        source_rid: nil,
          Severity: Minor
          Found in lib/jsonapi/resource_tree.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 jsonapi_resources has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def jsonapi_resources(*resources, &_block)
                    @resource_type = resources.first
                    res = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix(@resource_type))
          
                    res._routed = true
          Severity: Minor
          Found in lib/jsonapi/routing_ext.rb - About 1 hr to fix

            Method parse_fields has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def parse_fields(resource_klass, fields)
                  extracted_fields = {}
            
                  return extracted_fields if fields.nil?
            
            
            Severity: Minor
            Found in lib/jsonapi/request.rb - About 1 hr to fix

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

                  def relationships_hash(source, fetchable_fields, relationship_data)
                    relationships = source.class._relationships.select{|k,_v| fetchable_fields.include?(k) }
                    field_set = supplying_relationship_fields(source.class) & relationships.keys
              
                    relationships.each_with_object({}) do |(name, relationship), hash|
              Severity: Minor
              Found in lib/jsonapi/resource_serializer.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 jsonapi_links has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                      def jsonapi_links(*links)
                        link_type = links.first
                        formatted_relationship_name = format_route(link_type)
                        options = links.extract_options!.dup
              
              
              Severity: Minor
              Found in lib/jsonapi/routing_ext.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 parse_pagination_params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse_pagination_params(params)
                  if params.nil?
                    @offset = 0
                    @limit = JSONAPI.configuration.default_page_size
                  elsif params.is_a?(ActionController::Parameters)
              Severity: Minor
              Found in lib/jsonapi/paginator.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 parse_pagination_params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse_pagination_params(params)
                  if params.nil?
                    @number = 1
                    @size = JSONAPI.configuration.default_page_size
                  elsif params.is_a?(ActionController::Parameters)
              Severity: Minor
              Found in lib/jsonapi/paginator.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 parse_filters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_filters(resource_klass, filters)
                    parsed_filters = {}
              
                    # apply default filters
                    resource_klass._allowed_filters.each do |filter, opts|
              Severity: Minor
              Found in lib/jsonapi/request.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 jsonapi_resource has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def jsonapi_resource(*resources, &_block)
                        @resource_type = resources.first
                        res = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix(@resource_type))
              
                        res._routed = true
              Severity: Minor
              Found in lib/jsonapi/routing_ext.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language