cerebris/jsonapi-resources

View on GitHub
lib/jsonapi/active_relation/join_manager.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method perform_joins has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def perform_joins(records, options)
        join_array = flatten_join_tree_by_depth

        join_array.each do |level_joins|
          level_joins.each do |join_details|
Severity: Minor
Found in lib/jsonapi/active_relation/join_manager.rb - About 2 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 perform_joins has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def perform_joins(records, options)
        join_array = flatten_join_tree_by_depth

        join_array.each do |level_joins|
          level_joins.each do |join_details|
Severity: Minor
Found in lib/jsonapi/active_relation/join_manager.rb - About 1 hr to fix

    Method add_join has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def add_join(path, default_type = :inner, default_polymorphic_join_type = :left)
            if source_relationship
              if source_relationship.polymorphic?
                # Polymorphic paths will come it with the resource_type as the first segment (for example `#documents.comments`)
                # We just need to prepend the relationship portion the
    Severity: Minor
    Found in lib/jsonapi/active_relation/join_manager.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 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 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

    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

    There are no issues that match your filters.

    Category
    Status