NYULibraries/exlibris-primo

View on GitHub

Showing 8 of 12 total issues

Method display_name has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def display_name
        return @display_name ||= (ISO_639.find(name).english_name || name) if facet.name.eql? "lang"
        return @display_name ||= (config.libraries[name] || name) if facet.name.eql? "library"
        return @display_name ||= (config.facet_top_level[name] || name) if facet.name.eql? "tlevel"
        return @display_name ||= (config.facet_collections[name] || name) if facet.name.eql? "domain"
Severity: Minor
Found in lib/exlibris/primo/facet_value.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 method_missing has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def method_missing(method, *args, &block)
          if(duplicated_control_attributes.include? method)
            control_attribute = method.id2name.singularize
            self.class.send(:define_method, method) do
              variable_name = "@#{method}"
Severity: Minor
Found in lib/exlibris/primo/pnx/dedup_mgr.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 search_elements_xml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def search_elements_xml
            lambda { |xml|
              search_elements.each do |element|
                value = (send element) ? (send element) : default_search_elements[element]
                name = element.id2name.camelize
Severity: Minor
Found in lib/exlibris/primo/web_service/request/search/search_elements.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_review has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def add_review(value, rating, user_display_name, status=2, allow_user_name = true)
Severity: Minor
Found in lib/exlibris/primo/reviews.rb - About 35 mins to fix

    Method openurl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def openurl
              @openurl ||= ""
              if @openurl.blank?
                xml.root.xpath("addata/*").each do |addata|
                  @openurl << "rft.#{addata.name}=#{addata.inner_text}&" unless (addata.inner_text.nil? or addata.inner_text.strip.empty?)
    Severity: Minor
    Found in lib/exlibris/primo/pnx/openurl.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

    Avoid too many return statements within this method.
    Open

            return @display_name ||= (config.facet_resource_types[name] || name) if facet.name.eql? "rtype"
    Severity: Major
    Found in lib/exlibris/primo/facet_value.rb - About 30 mins to fix

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

              def links(link)
                xml.root.xpath("links/#{link}").collect do |link|
                  subfields = parse_subfields link.inner_text
                  # Get original id for dealing w/ dedup merger records
                  original_id = (subfields["O"]) ? subfields["O"] : recordid
      Severity: Minor
      Found in lib/exlibris/primo/pnx/links.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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def method_missing(method, *args, &block)
                if(attr_read(method))
                  self.class.send(:define_method, method) {
                    if "#{method}".start_with? "all_"
                      eval("@#{method} ||= #{attr_read(method).inspect}")
      Severity: Minor
      Found in lib/exlibris/primo/pnx/elements.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