team-umlaut/umlaut

View on GitHub

Showing 202 of 234 total issues

File referent.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'i18n'
require 'truncate_to_db_limit'

# Note: There are a few actual attributes stored as Columns in referent --
# these were originally used for identifying a Referent identifying the
Severity: Minor
Found in app/models/referent.rb - About 2 hrs to fix

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

      def handle(request, session_id)
        return if (@services.nil? || @services.empty?)
    
        bundle_start = Time.now
        Rails.logger.info(TermColor.color("Umlaut: Launching service wave #{@priority_level} #{'(non-threaded)' unless config.lookup!("threaded_service_wave", true) }", :yellow) + ", request #{request.id}") if @log_timing
    Severity: Major
    Found in app/models/service_wave.rb - About 2 hrs to fix

      Method gen_lamr_request has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def gen_lamr_request(request)
          output = ""
          
          builder = Builder::XmlMarkup.new(:target => output, :indent => 2)
          builder.instruct!(:xml, :encoding => "UTF-8")    
      Severity: Major
      Found in app/service_adaptors/isi.rb - About 2 hrs to fix

        Method add_asin_service_responses has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_asin_service_responses(request, asin, item_url)
            # we want to highlight Amazon to link to 'search in this book', etc.
            if asin
              # Search or Look inside the book offered? We only know by trying and
              # then screen-scraping.
        Severity: Minor
        Found in app/service_adaptors/amazon.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 handle has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def handle(request)
            ids_processed = []
            holdings_added = 0
            
            if (@identifier_search && url = blacklight_precise_search_url(request) )
        Severity: Minor
        Found in app/service_adaptors/blacklight.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

        File google_book_search.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class GoogleBookSearch < Service
          require 'multi_json'
          
          
          # Identifiers used in API response to indicate viewability level
        Severity: Minor
        Found in app/service_adaptors/google_book_search.rb - About 2 hrs to fix

          Method normalize_params has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def normalize_params
              # citation search params
          
              # sfx.title_search and umlaut.title_search_type are synonyms
              params["sfx.title_search"] = params["umlaut.title_search_type"] if params["sfx.title_search"].blank?
          Severity: Major
          Found in app/controllers/search_controller.rb - About 2 hrs to fix

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

              def handle(request)
                scopus_query = scopus_query(request)
            
                # we can't make a good query, nevermind. 
                return request.dispatched(self, true) if scopus_query.blank? 
            Severity: Major
            Found in app/service_adaptors/scopus2.rb - About 2 hrs to fix

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

                def create_partial_volume_responses(request, ht_json)
                  items =  ht_json.values.first["items"]
                  full_ids = items.collect do |i| 
                    i["fromRecord"] if (is_serial_part?(i) && full_view?(i))
                  end.compact.uniq
              Severity: Minor
              Found in app/service_adaptors/hathi_trust.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 do_query has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def do_query(request)
                  # get the search terms for use in both fulltext search and highlighted_link
                  # IA does index apostrophes, although not generally other puncutation. Need to keep em.
                  search_terms = {:title => get_search_title(request.referent ,:keep_apostrophes=>true),
                  :creator => get_search_creator(request.referent)}
              Severity: Major
              Found in app/service_adaptors/internet_archive.rb - About 2 hrs to fix

                Class SectionRenderer has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class SectionRenderer
                  include ActionView::Helpers::TagHelper
                
                  # First argument is the current umlaut Request object.
                  # Second argument is a session description hash. See class overview
                Severity: Minor
                Found in app/presentation/section_renderer.rb - About 2 hrs to fix

                  Method to_citation has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def to_citation
                      citation = {}
                      # call self.metadata once and use the array for efficiency, don't
                      # keep calling it. profiling shows it DOES make a difference. 
                      my_metadata = self.metadata
                  Severity: Major
                  Found in app/models/referent.rb - About 2 hrs to fix

                    Method enhance_referent has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def enhance_referent(body, request)   
                        doc = Nokogiri::XML(body)
                        return unless cite = doc.at("PubmedArticleSet/PubmedArticle/MedlineCitation") # Nothing of interest here
                        
                        return unless article = cite.at("Article") # No more useful metadata   
                    Severity: Major
                    Found in app/service_adaptors/pubmed.rb - About 2 hrs to fix

                      Method freshen_dispatches! has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def freshen_dispatches!
                          umlaut_request.dispatched_services.each do | ds |
                            # go through dispatched_services and set still in progress but too long to failed temporary
                            if ( (ds.status == DispatchedService::InProgress ||
                                  ds.status == DispatchedService::Queued ) &&
                      Severity: Minor
                      Found in app/models/collection.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 searchPath has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def searchPath(args = {})
                            args[:xml] = true if args[:xml].nil?
                            
                                  path = self.hip_base_url.path() + '?'             "menu=search&aspect=power&npp=30&ipp=20&spp=20&profile=general&ri=2"
                      
                      
                      Severity: Minor
                      Found in app/models/hip3/bib_searcher.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 preempted_by has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                       def preempted_by(uml_request, for_type_generated=nil)
                         preempted_by = @preempted_by
                         return false if preempted_by.nil?
                         preempted_by = [preempted_by] unless preempted_by.kind_of?(Array)
                         preemption = nil
                      Severity: Minor
                      Found in app/service_adaptors/service.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

                      Class Bib has 21 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                          class Bib 
                              attr_accessor :httpSession, :hip_base_url
                              # should have copies or items, not both
                              attr_accessor :bibNum, :copies, :items
                          attr_writer :title
                      Severity: Minor
                      Found in app/models/hip3/bib.rb - About 2 hrs to fix

                        Class Referent has 21 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Referent < ActiveRecord::Base
                          # for shortcut metadata manipulations
                          include MetadataHelper
                          
                          has_many :requests
                        Severity: Minor
                        Found in app/models/referent.rb - About 2 hrs to fix

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

                            def handle(request)
                              isbn = get_identifier(:urn, "isbn", request.referent)
                              issn = get_identifier(:urn, "issn", request.referent)
                              oclcnum = get_identifier(:info, "oclcnum", request.referent)
                              
                          Severity: Major
                          Found in app/service_adaptors/worldcat.rb - About 2 hrs to fix

                            Method determine_coverage_boundaries has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def determine_coverage_boundaries(target)
                                # machine actionable coverage elements, used for collapsing
                                if (in_node = target.at_xpath("./coverage/in"))
                                    year = in_node.at_xpath("year").try(:text).try(:to_i)
                                    if year && year != 0
                            Severity: Minor
                            Found in app/service_adaptors/sfx.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

                            Severity
                            Category
                            Status
                            Source
                            Language