cerebris/jsonapi-resources

View on GitHub

Showing 156 of 156 total issues

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

    def initialize(resource_klass, id, type, context, fetchable_fields, relationships,
                   links_json, attributes_json, meta_json)
Severity: Major
Found in lib/jsonapi/cached_response_fragment.rb - About 1 hr to fix

    Method inherited has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def inherited(subclass)
            super
            subclass.abstract(false)
            subclass.immutable(false)
            subclass.caching(_caching)
    Severity: Minor
    Found in lib/jsonapi/basic_resource.rb - About 1 hr to fix

      Method object_hash has 28 lines of code (exceeds 25 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 1 hr to fix

        Method check_include has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_include(resource_klass, include_parts)
              relationship_name = unformat_key(include_parts.first)
        
              relationship = resource_klass._relationship(relationship_name)
              if relationship && format_key(relationship_name) == include_parts.first
        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 parse_to_one_relationship has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_to_one_relationship(resource_klass, link_value, relationship)
              if link_value.nil?
                linkage = nil
              else
                linkage = link_value[:data]
        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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.parse(source_resource_klass:, segment_string:, parse_fields: true)
              first_part, last_part = segment_string.split('#', 2)
              relationship = source_resource_klass._relationship(first_part)
        
              if relationship
        Severity: Minor
        Found in lib/jsonapi/path_segment.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 _create_to_many_links has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _create_to_many_links(relationship_type, relationship_key_values, options)
              relationship = self.class._relationships[relationship_type]
              relation_name = relationship.relation_name(context: @context)
        
              if options[:reflected_source]
        Severity: Minor
        Found in lib/jsonapi/basic_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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(fragments: nil, resources: nil, resource: nil, include_related: nil, options: nil)
              @fragments ||= {}
              @related_resource_trees ||= {}
              if fragments || resources || resource
                if fragments
        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 flatten_resource_tree has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def flatten_resource_tree(resource_tree, flattened_tree = {})
              resource_tree.fragments.each_pair do |resource_rid, fragment|
        
                resource_klass = resource_rid.resource_klass
                id = resource_rid.id
        Severity: Minor
        Found in lib/jsonapi/resource_set.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 query_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def query_params(params)
              query_params = {}
              query_params[:page] = params
        
              request = @options[:request]
        Severity: Minor
        Found in lib/jsonapi/response_document.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 setup_operations has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def setup_operations(params)
              return if params.nil?
        
              resource_klass = Resource.resource_klass_for(params[:controller]) if params[:controller]
        
        
        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 show_related_resources has a Cognitive Complexity of 10 (exceeds 5 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

        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 add_resources_to_tree has 27 lines of code (exceeds 25 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

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

              class InvalidPageValue < Error
                attr_accessor :page, :value
          
                def initialize(page, value, error_object_overrides = {})
                  @page = page
          Severity: Major
          Found in lib/jsonapi/exceptions.rb and 4 other locations - About 1 hr to fix
          lib/jsonapi/exceptions.rb on lines 221..237
          lib/jsonapi/exceptions.rb on lines 241..257
          lib/jsonapi/exceptions.rb on lines 312..328
          lib/jsonapi/exceptions.rb on lines 332..348

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

              class InvalidFilterValue < Error
                attr_accessor :filter, :value
          
                def initialize(filter, value, error_object_overrides = {})
                  @filter = filter
          Severity: Major
          Found in lib/jsonapi/exceptions.rb and 4 other locations - About 1 hr to fix
          lib/jsonapi/exceptions.rb on lines 241..257
          lib/jsonapi/exceptions.rb on lines 312..328
          lib/jsonapi/exceptions.rb on lines 332..348
          lib/jsonapi/exceptions.rb on lines 575..591

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

              class InvalidField < Error
                attr_accessor :field, :type
          
                def initialize(type, field, error_object_overrides = {})
                  @field = field
          Severity: Major
          Found in lib/jsonapi/exceptions.rb and 4 other locations - About 1 hr to fix
          lib/jsonapi/exceptions.rb on lines 221..237
          lib/jsonapi/exceptions.rb on lines 241..257
          lib/jsonapi/exceptions.rb on lines 332..348
          lib/jsonapi/exceptions.rb on lines 575..591

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

              class InvalidRelationship < Error
                attr_accessor :relationship_name, :type
          
                def initialize(type, relationship_name, error_object_overrides = {})
                  @relationship_name = relationship_name
          Severity: Major
          Found in lib/jsonapi/exceptions.rb and 4 other locations - About 1 hr to fix
          lib/jsonapi/exceptions.rb on lines 221..237
          lib/jsonapi/exceptions.rb on lines 241..257
          lib/jsonapi/exceptions.rb on lines 312..328
          lib/jsonapi/exceptions.rb on lines 575..591

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 5 locations. Consider refactoring.
          Open

              class InvalidFieldValue < Error
                attr_accessor :field, :value
          
                def initialize(field, value, error_object_overrides = {})
                  @field = field
          Severity: Major
          Found in lib/jsonapi/exceptions.rb and 4 other locations - About 1 hr to fix
          lib/jsonapi/exceptions.rb on lines 221..237
          lib/jsonapi/exceptions.rb on lines 312..328
          lib/jsonapi/exceptions.rb on lines 332..348
          lib/jsonapi/exceptions.rb on lines 575..591

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method links_page_params has 26 lines of code (exceeds 25 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 1 hr to fix

            Method _create_to_many_links has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def _create_to_many_links(relationship_type, relationship_key_values, options)
                  relationship = self.class._relationships[relationship_type]
                  relation_name = relationship.relation_name(context: @context)
            
                  if options[:reflected_source]
            Severity: Minor
            Found in lib/jsonapi/basic_resource.rb - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language