team-umlaut/umlaut

View on GitHub
app/mixin_logic/marc_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

Method add_856_links has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def add_856_links(request, marc_records, options = {})
    options[:default_service_type] ||= "fulltext"
    options[:match_reliability] ||= ServiceResponse::MatchExact

    responses_added = Hash.new
Severity: Minor
Found in app/mixin_logic/marc_helper.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 edition_statement has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def edition_statement(marc, options = {})
    options[:include_repro_info] ||= true
    options[:exclude_533_fields] = ['7','f','b', 'e']

    parts = Array.new
Severity: Minor
Found in app/mixin_logic/marc_helper.rb - About 4 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 add_856_links has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add_856_links(request, marc_records, options = {})
    options[:default_service_type] ||= "fulltext"
    options[:match_reliability] ||= ServiceResponse::MatchExact

    responses_added = Hash.new
Severity: Minor
Found in app/mixin_logic/marc_helper.rb - About 1 hr to fix

    Method edition_statement has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def edition_statement(marc, options = {})
        options[:include_repro_info] ||= true
        options[:exclude_533_fields] = ['7','f','b', 'e']
    
        parts = Array.new
    Severity: Minor
    Found in app/mixin_logic/marc_helper.rb - About 1 hr to fix

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

        def service_type_for_856(field, options)
          options[:default_service_type] ||= "fulltext_title_level"
      
          # LC records here at hopkins have "Table of contents only" in the 856$3
          # Think that's a convention from LC?
      Severity: Minor
      Found in app/mixin_logic/marc_helper.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 get_years has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_years(marc)
          array = []
      
          # no marc 008? Weird, but okay.
          return array unless marc['008']
      Severity: Minor
      Found in app/mixin_logic/marc_helper.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

      Avoid too many return statements within this method.
      Open

            return options[:default_service_type]
      Severity: Major
      Found in app/mixin_logic/marc_helper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return "highlighted_link"
        Severity: Major
        Found in app/mixin_logic/marc_helper.rb - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status