team-umlaut/umlaut

View on GitHub
app/service_adaptors/open_library.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method enhance_metadata has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def enhance_metadata(referent, editions)
    # Which one should we use to enhance? Whichever has the largest
    # oclcnum, or if none of them have an oclcnum, then whichever
    # has the most metadata elements. 
    winner = nil
Severity: Minor
Found in app/service_adaptors/open_library.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 get_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def get_data(request)
    ids = get_identifiers(request.referent)
    return nil if ids.blank?
    ol_keys = do_id_query(ids)    
    return nil if ol_keys.blank?
Severity: Minor
Found in app/service_adaptors/open_library.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_download_link has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_download_link(request, editions)
    return nil unless editions
    ed = editions[0] if editions.length
    return nil unless ed['ocaid']
    server = "www.archive.org"
Severity: Minor
Found in app/service_adaptors/open_library.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

Method get_identifiers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def get_identifiers(rft)
    isbn = get_identifier(:urn, "isbn", rft)
    oclcnum = get_identifier(:info, "oclcnum", rft)
    lccn = get_identifier(:info, "lccn", rft)
    
Severity: Minor
Found in app/service_adaptors/open_library.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 score_metadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def score_metadata(edition)
    oclcnum = edition["oclc_numbers"].collect {|i| i.to_i}.max unless edition["oclc_numbers"].blank?
    oclcnum = nil if oclcnum == 0

    score = 0
Severity: Minor
Found in app/service_adaptors/open_library.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