team-umlaut/umlaut

View on GitHub

Showing 234 of 234 total issues

Method handle has a Cognitive Complexity of 30 (exceeds 5 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: Minor
Found in app/service_adaptors/scopus2.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 enhance_referent has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def enhance_referent(request, perl_data)


    ActiveRecord::Base.connection_pool.with_connection do
      metadata = request.referent.metadata
Severity: Minor
Found in app/service_adaptors/sfx.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

File internet_archive.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class InternetArchive < Service
  require 'open-uri' #
  require 'cgi'
  require 'multi_json' #we ask IA for json
  require 'timeout' # used to timeout our requests
Severity: Minor
Found in app/service_adaptors/internet_archive.rb - About 4 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        if options[:coverage_sensitive] == true
          # roll up targets with same prefix only if coverage is a strict
          # subset of an existing one. If two are equal, take first.
          list = list.reject.each_with_index do |item, index|
            prefix = prefixes.find {|p| item[:sfx_target_name].start_with?(p)}
    Severity: Critical
    Found in app/service_adaptors/sfx.rb - About 4 hrs to fix

      Method gen_lamr_request has a Cognitive Complexity of 27 (exceeds 5 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: Minor
      Found in app/service_adaptors/jcr.rb - About 3 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 included has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.included(klass)
              klass.class_eval do
                self.table_name = 'AZ_TITLE'
                self.primary_key = 'AZ_TITLE_ID'
      
      
      Severity: Minor
      Found in app/models/sfx4/abstract/az_title.rb - About 3 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_copies has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_copies(request, bib_array, options = {})
          #debugger
          
          # default    
          options[:match_reliability] ||= ServiceResponse::MatchExact
      Severity: Minor
      Found in app/service_adaptors/hip3_service.rb - About 3 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

      Function HtmlUpdater has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function HtmlUpdater(first_arg, second_arg, third_arg) {
          if (typeof(first_arg) == "object") {
            // Simply merge arguments object as properties on ourselves. 
           $.extend(this, first_arg);
          } else {
      Severity: Major
      Found in app/assets/javascripts/umlaut/update_html.js - About 3 hrs to fix

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

          def handle(request)
            
            # Only do anything if we have no holdings results from someone else.
            holdings = request.service_types.where(:service_type_value_name => "holding")
            
        Severity: Major
        Found in app/service_adaptors/hip_holding_search.rb - About 3 hrs to fix

          File bootstrap3-typeahead.js has 307 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* =============================================================
           * bootstrap3-typeahead.js v3.0.3
           * https://github.com/bassjobsen/Bootstrap-3-Typeahead
           * =============================================================
           * Original written by @mdo and @fat
          Severity: Minor
          Found in app/assets/javascripts/bootstrap3-typeahead.js - About 3 hrs to fix

            Method add_aws_service_responses has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def add_aws_service_responses(request, aws_response)
                return_hash = Hash.new
                    
                aws = Nokogiri::XML(aws_response.body)
                # extract and collect info from the xml    
            Severity: Major
            Found in app/service_adaptors/amazon.rb - About 3 hrs to fix

              Class WorldcatIdentities has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class WorldcatIdentities < Service
                require 'open-uri' # SRU is too slow even though we use an SRU-like link
                require 'nokogiri'
                include MetadataHelper
                
              Severity: Minor
              Found in app/service_adaptors/worldcat_identities.rb - About 3 hrs to fix

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

                  def handle(request)
                    scopus_search = scopus_search(request)
                
                    # we can't make a good query, nevermind. 
                    return request.dispatched(self, true) if scopus_search.blank? 
                Severity: Minor
                Found in app/service_adaptors/scopus.rb - About 3 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  $(document).on("show.bs.collapse", ".collapse", function(event) {
                      // Update the icon
                      $(this).parent().find('.collapse-toggle i').removeClass("umlaut_icons-list-closed").addClass("umlaut_icons-list-open");
                      // Update the action label
                      $(this).parent().find(".expand_contract_action_label").text("Hide ");
                Severity: Major
                Found in app/assets/javascripts/umlaut/expand_contract_toggle.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/umlaut/expand_contract_toggle.js on lines 19..25

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 97.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  $(document).on("hide.bs.collapse", ".collapse", function(event) {
                      // Update the icon
                      $(this).parent().find('.collapse-toggle i').removeClass("umlaut_icons-list-open").addClass("umlaut_icons-list-closed");
                      // Update the action label
                      $(this).parent().find(".expand_contract_action_label").text("Show ");
                Severity: Major
                Found in app/assets/javascripts/umlaut/expand_contract_toggle.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/umlaut/expand_contract_toggle.js on lines 12..18

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 97.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method should_skip_menu has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                  def should_skip_menu
                    # From usabilty test, do NOT skip if coming from A-Z list/journal lookup.
                    # First, is it over-ridden in url?
                    if ( params['umlaut.skip_resolve_menu'] == 'false')
                      return nil
                Severity: Minor
                Found in app/controllers/resolve_controller.rb - About 3 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 brief_citation has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                  def brief_citation(request, options = {})
                    options[:include_labels] ||= false
                    rv =""
                    cite = request.referent.to_citation
                    title = truncate(cite[:title].strip, :length => 70,  :separator => ' ')
                Severity: Minor
                Found in app/helpers/emailer_helper.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 a Cognitive Complexity of 21 (exceeds 5 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: Minor
                Found in app/service_adaptors/internet_archive.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 http_fetch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  def http_fetch(uri, options = {})
                    options[:max_redirects] ||= 8
                    options[:redirects_left] ||= options[:max_redirects]
                    options[:raise_on_http_error_code] = true unless options.has_key?(:raise_on_http_error_code)
                
                
                Severity: Minor
                Found in app/mixin_logic/umlaut_http.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 normalize_title has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                Open

                  def normalize_title(arg_title, options = {})
                    # default options
                    options[:rstrip_parens] ||= true
                    options[:remove_all_parens] ||= true
                    options[:strip_gmd] ||= true
                Severity: Minor
                Found in app/mixin_logic/metadata_helper.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