cerebris/jsonapi-resources

View on GitHub

Showing 105 of 156 total issues

Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(code, source_resource, type, resource_set, options = {})
Severity: Minor
Found in lib/jsonapi/operation_result.rb - About 35 mins to fix

    Method update_with_overrides has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_with_overrides(error_object_overrides)
          @title          = error_object_overrides[:title] || @title
          @detail         = error_object_overrides[:detail] || @detail
          @id             = error_object_overrides[:id] || @id
          @href           = error_object_overrides[:href] || href
    Severity: Minor
    Found in lib/jsonapi/error.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 apply_single_sort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def apply_single_sort(records, field, direction, options)
            context = options[:context]
    
            strategy = _allowed_sort.fetch(field.to_sym, {})[:apply]
    
    
    Severity: Minor
    Found in lib/jsonapi/active_relation_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 concat_table_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def concat_table_field(table, field, quoted = false)
            if table.blank? || field.to_s.include?('.')
              # :nocov:
              if quoted
                quote(field)
    Severity: Minor
    Found in lib/jsonapi/active_relation_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 parse_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_params(resource_klass, params, allowed_fields)
          verify_permitted_params(params, allowed_fields)
    
          checked_attributes = {}
          checked_to_one_relationships = {}
    Severity: Minor
    Found in lib/jsonapi/request.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 relationships_related_link has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def relationships_related_link(source, relationship, query_params = {})
          if relationship._routed
            url = "#{ self_link(source) }/#{ route_for_relationship(relationship) }"
            url = "#{ url }?#{ query_params.to_query }" if query_params.present?
            url
    Severity: Minor
    Found in lib/jsonapi/link_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 links_page_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def links_page_params(options = {})
        record_count = options[:record_count]
        page_count = calculate_page_count(record_count)
    
        links_page_params = {}
    Severity: Minor
    Found in lib/jsonapi/paginator.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 alias_table_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def alias_table_field(table, field, quoted = false)
            if table.blank? || field.to_s.include?('.')
              # :nocov:
              if quoted
                quote(field)
    Severity: Minor
    Found in lib/jsonapi/active_relation_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 apply_join has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def apply_join(records:, relationship:, resource_type:, join_type:, options:)
            if relationship.polymorphic? && relationship.belongs_to?
              case join_type
              when :inner
                records = records.joins(resource_type.to_s.singularize.to_sym)
    Severity: Minor
    Found in lib/jsonapi/active_relation_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 parse_include_directives has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_include_directives(resource_klass, raw_include)
          raw_include ||= ''
    
          included_resources = []
          begin
    Severity: Minor
    Found in lib/jsonapi/request.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 attribute_to_model_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def attribute_to_model_field(attribute)
            field_name = if attribute == :_cache_field
                           _cache_field
                         else
                           # Note: this will allow the returning of model attributes without a corresponding
    Severity: Minor
    Found in lib/jsonapi/basic_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 apply_request_settings_to_records has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def apply_request_settings_to_records(records:,
                                                join_manager: ActiveRelation::JoinManager.new(resource_klass: self),
                                                resource_klass: self,
                                                filters: {},
                                                primary_keys: nil,
    Severity: Minor
    Found in lib/jsonapi/active_relation_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 _model_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def _model_name
            if _abstract
               ''
            else
              return @_model_name.to_s if defined?(@_model_name)
    Severity: Minor
    Found in lib/jsonapi/basic_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 setup_update_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup_update_action(params, resource_klass)
          resolve_singleton_id(params, resource_klass)
          fields = parse_fields(resource_klass, params[:fields])
          include_directives = parse_include_directives(resource_klass, params[:include])
    
    
    Severity: Minor
    Found in lib/jsonapi/request.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 supplying_relationship_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def supplying_relationship_fields(resource_klass)
          @_supplying_relationship_fields.fetch resource_klass do
            relationships = Set.new(resource_klass._relationships.keys.map(&:to_sym))
            cur = resource_klass
            while !cur.root? # do not traverse beyond the first root resource
    Severity: Minor
    Found in lib/jsonapi/resource_serializer.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 allow_include? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def allow_include?(context = nil)
            strategy = if @allow_include.nil?
                         JSONAPI.configuration.default_allow_include_to_many
                       else
                         @allow_include
    Severity: Minor
    Found in lib/jsonapi/relationship.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 get_join_arel_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.get_join_arel_node(records, relationship, join_type, options = {})
            init_join_sources = records.arel.join_sources
            init_join_sources_length = init_join_sources.length
    
            records = yield(records, options)
    Severity: Minor
    Found in lib/jsonapi/active_relation/join_manager.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 primary_resources_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def primary_resources_url
          if @primary_resource_klass._routed
            primary_resources_path = resources_path(primary_resource_klass)
            @primary_resources_url_cached ||= "#{ base_url }#{ engine_mount_point }#{ primary_resources_path }"
          else
    Severity: Minor
    Found in lib/jsonapi/link_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 _replace_to_many_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _replace_to_many_links(relationship_type, relationship_key_values, options)
          relationship = self.class._relationship(relationship_type)
    
          reflect = reflect_relationship?(relationship, options)
    
    
    Severity: Minor
    Found in lib/jsonapi/basic_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 source_join_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def source_join_details(type=nil)
            if source_relationship
              related_resource_klass = type ? resource_klass.resource_klass_for(type) : source_relationship.resource_klass
              segment = PathSegment::Relationship.new(relationship: source_relationship, resource_klass: related_resource_klass)
              details = @join_details[segment]
    Severity: Minor
    Found in lib/jsonapi/active_relation/join_manager.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