cerebris/jsonapi-resources

View on GitHub

Showing 105 of 156 total issues

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

    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

        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 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 _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 _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 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 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 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 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 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 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 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
          Severity
          Category
          Status
          Source
          Language