scotdalton/exlibris-primo

View on GitHub

Showing 12 of 12 total issues

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 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

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

          module ClassAttributes
            def base_elements
              @base_elements ||= self.superclass.respond_to?(:base_elements) ?
                self.superclass.base_elements.dup : []
            end
Severity: Minor
Found in lib/exlibris/primo/web_service/request/base/base_elements.rb and 1 other location - About 50 mins to fix
lib/exlibris/primo/pnx/dedup_mgr.rb on lines 15..34

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 42.

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

        module ClassAttributes
          def duplicated_control_attributes
            @duplicated_control_attributes ||= self.superclass.respond_to?(:duplicated_control_attributes) ?
              self.superclass.duplicated_control_attributes.dup : []
          end
Severity: Minor
Found in lib/exlibris/primo/pnx/dedup_mgr.rb and 1 other location - About 50 mins to fix
lib/exlibris/primo/web_service/request/base/base_elements.rb on lines 12..31

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 42.

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 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

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

      module Primo
        module WebService
          module Request
            module Languages
              # 
    Severity: Minor
    Found in lib/exlibris/primo/web_service/request/search/languages.rb and 1 other location - About 35 mins to fix
    lib/exlibris/primo/web_service/request/search/sort_bys.rb on lines 2..26

    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 35.

    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

      module Primo
        module WebService
          module Request
            module SortBys
              # 
    Severity: Minor
    Found in lib/exlibris/primo/web_service/request/search/sort_bys.rb and 1 other location - About 35 mins to fix
    lib/exlibris/primo/web_service/request/search/languages.rb on lines 2..26

    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 35.

    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 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