cerebris/jsonapi-resources

View on GitHub

Showing 105 of 156 total issues

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 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 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 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 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 _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 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

    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

      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 _save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _save(validation_context = nil)
              unless @model.valid?(validation_context)
                fail JSONAPI::Exceptions::ValidationErrors.new(self)
              end
        
        
        Severity: Minor
        Found in lib/jsonapi/basic_resource.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 verify_filter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def verify_filter(filter, raw, context = nil)
                filter_values = []
                if raw.present?
                  begin
                    filter_values += raw.is_a?(String) ? CSV.parse_line(raw) : [raw]
        Severity: Minor
        Found in lib/jsonapi/basic_resource.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 _remove_to_many_link has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _remove_to_many_link(relationship_type, key, options)
              relationship = self.class._relationships[relationship_type]
        
              reflect = reflect_relationship?(relationship, options)
        
        
        Severity: Minor
        Found in lib/jsonapi/basic_resource.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 find has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def find
              filters = params[:filters]
              include_directives = params[:include_directives]
              sort_criteria = params[:sort_criteria]
              paginator = params[:paginator]
        Severity: Minor
        Found in lib/jsonapi/processor.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 handle_exceptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_exceptions(e)
              case e
                when JSONAPI::Exceptions::Error
                  errors = e.errors
                when ActionController::ParameterMissing
        Severity: Minor
        Found in lib/jsonapi/acts_as_resource_controller.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 links_page_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

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

            def parse_update_relationship_operation(resource_klass, verified_params, relationship, parent_key)
              options = {
                context: @context,
                resource_id: parent_key,
                relationship_type: relationship.name
        Severity: Minor
        Found in lib/jsonapi/request.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 process_path_to_tree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def process_path_to_tree(path_segments, resource_klass, default_join_type, default_polymorphic_join_type)
                node = {
                    resource_klasses: {
                        resource_klass => {
                            relationships: {}
        Severity: Minor
        Found in lib/jsonapi/active_relation/join_manager.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 contents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def contents
              if has_errors?
                return { 'errors' => @global_errors }
              else
                hash = @serialized_results[0]
        Severity: Minor
        Found in lib/jsonapi/response_document.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(code, parent_resource, relationship, resource_ids, options = {})
        Severity: Minor
        Found in lib/jsonapi/operation_result.rb - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language