cerebris/jsonapi-resources

View on GitHub

Showing 105 of 156 total issues

Class BasicResource has 136 methods (exceeds 20 allowed). Consider refactoring.
Open

  class BasicResource
    include Callbacks

    @abstract = true
    @immutable = true
Severity: Major
Found in lib/jsonapi/basic_resource.rb - About 2 days to fix

    File basic_resource.rb has 863 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'jsonapi/callbacks'
    require 'jsonapi/configuration'
    
    module JSONAPI
      class BasicResource
    Severity: Major
    Found in lib/jsonapi/basic_resource.rb - About 2 days to fix

      File active_relation_resource.rb has 620 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module JSONAPI
        class ActiveRelationResource < BasicResource
          root_resource
      
          def find_related_ids(relationship, options = {})
      Severity: Major
      Found in lib/jsonapi/active_relation_resource.rb - About 1 day to fix

        File request.rb has 614 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module JSONAPI
          class Request
            attr_accessor :fields, :include, :filters, :sort_criteria, :errors, :controller_module_path,
                          :context, :paginator, :source_klass, :source_id,
                          :include_directives, :params, :warnings, :server_error_callbacks, :operations
        Severity: Major
        Found in lib/jsonapi/request.rb - About 1 day to fix

          File exceptions.rb has 502 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module JSONAPI
            module Exceptions
              class Error < RuntimeError
                attr_reader :error_object_overrides
          
          
          Severity: Major
          Found in lib/jsonapi/exceptions.rb - About 1 day to fix

            Method jsonapi_resources has a Cognitive Complexity of 48 (exceeds 5 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 7 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 jsonapi_resource has a Cognitive Complexity of 46 (exceeds 5 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 7 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_polymorphic_fragments has 133 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def find_related_polymorphic_fragments(source_fragments, relationship, options, connect_source_identity)
                    filters = options.fetch(:filters, {})
                    source_ids = source_fragments.collect {|item| item.identity.id}
            
                    resource_klass = relationship.resource_klass
            Severity: Major
            Found in lib/jsonapi/active_relation_resource.rb - About 5 hrs to fix

              Method find_related_polymorphic_fragments has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                    def find_related_polymorphic_fragments(source_fragments, relationship, options, connect_source_identity)
                      filters = options.fetch(:filters, {})
                      source_ids = source_fragments.collect {|item| item.identity.id}
              
                      resource_klass = relationship.resource_klass
              Severity: Minor
              Found in lib/jsonapi/active_relation_resource.rb - About 5 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 ActiveRelationResource has 38 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class ActiveRelationResource < BasicResource
                  root_resource
              
                  def find_related_ids(relationship, options = {})
                    self.class.find_related_fragments([self], relationship.name, options).keys.collect { |rid| rid.id }
              Severity: Minor
              Found in lib/jsonapi/active_relation_resource.rb - About 5 hrs to fix

                Class Request has 37 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Request
                    attr_accessor :fields, :include, :filters, :sort_criteria, :errors, :controller_module_path,
                                  :context, :paginator, :source_klass, :source_id,
                                  :include_directives, :params, :warnings, :server_error_callbacks, :operations
                
                
                Severity: Minor
                Found in lib/jsonapi/request.rb - About 4 hrs to fix

                  Method populate! has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def populate!(serializer, context, options)
                        return if @populated
                  
                        # For each resource klass we want to generate the caching key
                  
                  
                  Severity: Minor
                  Found in lib/jsonapi/resource_set.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

                  Method object_hash has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def object_hash(source, relationship_data)
                        obj_hash = {}
                  
                        return obj_hash if source.nil?
                  
                  
                  Severity: Minor
                  Found in lib/jsonapi/resource_serializer.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

                  Method find_related_monomorphic_fragments has 96 lines of code (exceeds 25 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: Major
                  Found in lib/jsonapi/active_relation_resource.rb - About 3 hrs to fix

                    Class ResourceSerializer has 30 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                      class ResourceSerializer
                    
                        attr_reader :link_builder, :key_formatter, :serialization_options,
                                    :fields, :include_directives, :always_include_to_one_linkage_data,
                                    :always_include_to_many_linkage_data, :options
                    Severity: Minor
                    Found in lib/jsonapi/resource_serializer.rb - About 3 hrs to fix

                      File processor.rb has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

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

                        Method verify_permitted_params has a Cognitive Complexity of 24 (exceeds 5 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: 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 find_fragments has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def find_fragments(filters, options = {})
                                include_directives = options.fetch(:include_directives, {})
                                resource_klass = self
                        
                                fragments = {}
                        Severity: Major
                        Found in lib/jsonapi/active_relation_resource.rb - About 3 hrs to fix

                          File resource_serializer.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          module JSONAPI
                            class ResourceSerializer
                          
                              attr_reader :link_builder, :key_formatter, :serialization_options,
                                          :fields, :include_directives, :always_include_to_one_linkage_data,
                          Severity: Minor
                          Found in lib/jsonapi/resource_serializer.rb - About 3 hrs to fix

                            Method populate! has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def populate!(serializer, context, options)
                                  return if @populated
                            
                                  # For each resource klass we want to generate the caching key
                            
                            
                            Severity: Major
                            Found in lib/jsonapi/resource_set.rb - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language