team-umlaut/umlaut

View on GitHub
app/service_adaptors/sfx.rb

Summary

Maintainability
F
5 days
Test Coverage

Method parse_response has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_response(resolver_response, request)
    doc = Nokogiri::XML(resolver_response)

    # Catch an SFX error message (in HTML) that's not an XML
    # document at all.
Severity: Minor
Found in app/service_adaptors/sfx.rb - About 1 day 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 sfx.rb has 425 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Sfx < Service
  require 'uri'
  require 'htmlentities'
  require 'cgi'
  require 'nokogiri'
Severity: Minor
Found in app/service_adaptors/sfx.rb - About 6 hrs to fix

    Method parse_response has 139 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse_response(resolver_response, request)
        doc = Nokogiri::XML(resolver_response)
    
        # Catch an SFX error message (in HTML) that's not an XML
        # document at all.
    Severity: Major
    Found in app/service_adaptors/sfx.rb - About 5 hrs to fix

      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

      Method parse_perl_data has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.parse_perl_data(doc)
      
          co = OpenURL::ContextObject.new
          co.referent.set_format('journal') # default
      
      
      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

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

        Method parse_perl_data has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.parse_perl_data(doc)
        
            co = OpenURL::ContextObject.new
            co.referent.set_format('journal') # default
        
        
        Severity: Minor
        Found in app/service_adaptors/sfx.rb - About 1 hr to fix

          Method roll_up_responses has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def roll_up_responses(list, options = {})
              options = options.reverse_merge(:coverage_sensitive => true)
          
              prefixes = @roll_up_prefixes
          
          
          Severity: Minor
          Found in app/service_adaptors/sfx.rb - About 1 hr to fix

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

              def roll_up_responses(list, options = {})
                options = options.reverse_merge(:coverage_sensitive => true)
            
                prefixes = @roll_up_prefixes
            
            
            Severity: Minor
            Found in app/service_adaptors/sfx.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 determine_coverage_boundaries has 29 lines of code (exceeds 25 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 1 hr to fix

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

                def sort_boosted_responses(list)
                  return list unless @boost_targets.present?
              
                  preferred = []
                  other_targets = list
              Severity: Minor
              Found in app/service_adaptors/sfx.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

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

                def sort_sunk_responses(list)
                  return list unless @sink_targets.present?
                  
                  sunk = []
                  other_targets = list
              Severity: Minor
              Found in app/service_adaptors/sfx.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

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

                def sort_boosted_responses(list)
                  return list unless @boost_targets.present?
              
                  preferred = []
                  other_targets = list
              Severity: Major
              Found in app/service_adaptors/sfx.rb and 1 other location - About 1 hr to fix
              app/service_adaptors/sfx.rb on lines 553..569

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

              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

                def sort_sunk_responses(list)
                  return list unless @sink_targets.present?
                  
                  sunk = []
                  other_targets = list
              Severity: Major
              Found in app/service_adaptors/sfx.rb and 1 other location - About 1 hr to fix
              app/service_adaptors/sfx.rb on lines 532..550

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

              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

                  if (from = target.at_xpath("./coverage/to"))
                    year   = from.at_xpath("year").try(:text).try(:to_i)
                    # set to end of year
                    end_date = Date.new(year, 12, 31) if year && year != 0
                  end
              Severity: Minor
              Found in app/service_adaptors/sfx.rb and 1 other location - About 15 mins to fix
              app/service_adaptors/sfx.rb on lines 438..442

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

              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

                  if (from = target.at_xpath("./coverage/from"))
                    year   = from.at_xpath("year").try(:text).try(:to_i)
                    # SFX KB does not have month/day, only year, set to begin of year
                    begin_date = Date.new(year, 1, 1) if year && year != 0
                  end
              Severity: Minor
              Found in app/service_adaptors/sfx.rb and 1 other location - About 15 mins to fix
              app/service_adaptors/sfx.rb on lines 444..448

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

              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

              There are no issues that match your filters.

              Category
              Status