archivesspace/archivesspace

View on GitHub
backend/app/lib/merge_helpers.rb

Summary

Maintainability
D
2 days
Test Coverage

Method preview_sort_name has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

  def preview_sort_name(target)
    result = ""

    case target['jsonmodel_type']
    when 'name_person'
Severity: Minor
Found in backend/app/lib/merge_helpers.rb - About 1 day 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_selections has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_selections(selections, path=[], all_values={})
    selections.each_pair do |k, v|
      path << k

      position = selections['position']
Severity: Minor
Found in backend/app/lib/merge_helpers.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 preview_sort_name has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def preview_sort_name(target)
    result = ""

    case target['jsonmodel_type']
    when 'name_person'
Severity: Minor
Found in backend/app/lib/merge_helpers.rb - About 1 hr to fix

    Method merge_details has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def merge_details(target, victim, selections, params)
        target[:linked_events] = []
        victim[:linked_events] = []
    
        subrec_add_replacements = []
    Severity: Minor
    Found in backend/app/lib/merge_helpers.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 merge_details has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def merge_details(target, victim, selections, params)
        target[:linked_events] = []
        victim[:linked_events] = []
    
        subrec_add_replacements = []
    Severity: Minor
    Found in backend/app/lib/merge_helpers.rb - About 1 hr to fix

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

        def parse_selections(selections, path=[], all_values={})
          selections.each_pair do |k, v|
            path << k
      
            position = selections['position']
      Severity: Minor
      Found in backend/app/lib/merge_helpers.rb - About 1 hr to fix

        Method process_subrecord_for_merge has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def process_subrecord_for_merge(target, subrecord, jsonmodel_type, mode, ind)
            target_id = target['id']
        
            if jsonmodel_type == 'names'
              # an agent name can only have one authorized or display name.
        Severity: Minor
        Found in backend/app/lib/merge_helpers.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_subrecord_for_merge has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def process_subrecord_for_merge(target, subrecord, jsonmodel_type, mode, ind)
        Severity: Minor
        Found in backend/app/lib/merge_helpers.rb - About 35 mins to fix

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

            def set_agent_id(target_id, subrecord)
              if subrecord['agent_person_id']
                subrecord['agent_person_id'] = target_id
          
              elsif subrecord['agent_family_id']
          Severity: Minor
          Found in backend/app/lib/merge_helpers.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

          There are no issues that match your filters.

          Category
          Status