team-umlaut/umlaut-primo

View on GitHub

Showing 16 of 16 total issues

Method handle has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

  def handle(request)
    search = search(request)
    return request.dispatched(self, true) if search.nil?
    records = search.records
    if records.blank? && /^dedupmrg/ === @record_id
Severity: Minor
Found in lib/umlaut_primo/primo_service.rb - About 6 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

Class PrimoService has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class PrimoService < Service

  required_config_params :base_url, :vid, :institution
  # For matching purposes.
  attr_reader :title, :author
Severity: Minor
Found in lib/umlaut_primo/primo_service.rb - About 3 hrs to fix

    File primo_service.rb has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'exlibris-primo'
    class PrimoService < Service
    
      required_config_params :base_url, :vid, :institution
      # For matching purposes.
    Severity: Minor
    Found in lib/umlaut_primo/primo_service.rb - About 2 hrs to fix

      Method handle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def handle(request)
          primo_sources = request.get_service_type('primo_source', {:refresh => true})
          sources = [] # for de-duplicating holdings from catalog.
          primo_sources.each do |primo_source|
            # Call PrimoService#to_primo_source with the ServiceResponse
      Severity: Minor
      Found in lib/umlaut_primo/primo_source.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_link_services has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_link_services(request, links, service_type, suppress_links, &block)
          links_seen = [] # for de-duplicating urls
          links.each do |link|
            next if links_seen.include?(link.url)
            # Check the list of URLs to suppress, array of strings or regexps.
      Severity: Minor
      Found in lib/umlaut_primo/primo_service.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_holding_services has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_holding_services(request, holdings)
          holdings.each do |holding|
            next if @suppress_holdings.find {|suppress_holding| suppress_holding === holding.availlibrary}
            service_data = {}
            # Availability status from Primo is probably out of date, so set to "check_holdings"
      Severity: Minor
      Found in lib/umlaut_primo/primo_service.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 handle has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def handle(request)
          search = search(request)
          return request.dispatched(self, true) if search.nil?
          records = search.records
          if records.blank? && /^dedupmrg/ === @record_id
      Severity: Minor
      Found in lib/umlaut_primo/primo_service.rb - About 1 hr to fix

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

          def reliable_match?(record_metadata)
            return true unless (@record_id.nil? or @record_id.empty?)
            return true unless (@issn.nil? or @issn.empty?) and (@isbn.nil? or @isbn.empty?)
            return false if (record_metadata.nil? or record_metadata.empty? or record_metadata[:title].nil? or record_metadata[:title].empty?)
            # Titles must be equal
        Severity: Minor
        Found in lib/umlaut_primo/primo_service.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 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(config)
            @holding_search_text = "Search for this title."
            # Configure Primo
            configure_primo
            # Attributes for holding service data.
        Severity: Minor
        Found in lib/umlaut_primo/primo_service.rb - About 1 hr to fix

          Method handle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def handle(request)
              primo_sources = request.get_service_type('primo_source', {:refresh => true})
              sources = [] # for de-duplicating holdings from catalog.
              primo_sources.each do |primo_source|
                # Call PrimoService#to_primo_source with the ServiceResponse
          Severity: Minor
          Found in lib/umlaut_primo/primo_source.rb - About 1 hr to fix

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

              def enhance_referent(request, record)
                @referent_enhancements.each do |key, options|
                  metadata_element = (options[:value].nil?) ? key : options[:value]
                  # Enhance the referent from the 'addata' section
                  metadata_method = "addata_#{metadata_element}".to_sym
            Severity: Minor
            Found in lib/umlaut_primo/primo_service.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 search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def search(request, skip_id = false)
                # Get the possible search params
                @identifier = request.referrer_id
                @record_id = record_id(request) unless skip_id
                @isbn = isbn(request)
            Severity: Minor
            Found in lib/umlaut_primo/primo_service.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 add_link_services has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def add_link_services(request, links, service_type, suppress_links, &block)
            Severity: Minor
            Found in lib/umlaut_primo/primo_service.rb - About 35 mins to fix

              Avoid too many return statements within this method.
              Open

                  return true
              Severity: Major
              Found in lib/umlaut_primo/primo_service.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return false unless record_metadata[:author].to_s.downcase.eql?(@author.downcase)
                Severity: Major
                Found in lib/umlaut_primo/primo_service.rb - About 30 mins to fix

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

                    def backward_compatibility(config)
                      # For backward compatibility, re-map "old" config values to new more
                      # Umlaut-y names and print deprecation warning in the logs.
                      old_to_new_mappings = {
                        :base_path => :base_url,
                  Severity: Minor
                  Found in lib/umlaut_primo/primo_service.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

                  Severity
                  Category
                  Status
                  Source
                  Language