dpla/heidrun

View on GitHub

Showing 14 of 14 total issues

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

  def enumerate_uris
    Enumerator.new do |yielder|
      # For each of the sets
      opts[:uris].each do |uri|
        loop do
Severity: Minor
Found in app/harvesters/loc_harvester.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 enumerate_records has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def enumerate_records(identifiers)
    batch = []
    # get meta.xml for each identifier in the batch
    identifiers.each do |id|
      meta_uri = "#{DOWNLOAD_BASE_URI}/#{id}/#{id}_meta.xml"
Severity: Minor
Found in app/harvesters/ia_harvester.rb - About 1 hr to fix

    Method enumerate_records has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def enumerate_records
        Enumerator.new do |en|
          request_opts = opts.deep_dup
          @id_source.batches.each do |ids|
            request_opts['params']['naIds'] = ids.join(',')
    Severity: Minor
    Found in app/harvesters/nara_harvester.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 record_ids has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def record_ids
        Enumerator.new do |en|
          cursor = nil
          loop do
            cursor_param = cursor ? "&cursor=#{cursor}" : ''
    Severity: Minor
    Found in app/harvesters/ia_harvester.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 enumerate_records has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def enumerate_records(identifiers)
        batch = []
        # get meta.xml for each identifier in the batch
        identifiers.each do |id|
          meta_uri = "#{DOWNLOAD_BASE_URI}/#{id}/#{id}_meta.xml"
    Severity: Minor
    Found in app/harvesters/ia_harvester.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 language has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def language(opts)
              genres = []
    
              return genres unless language_material?(opts[:leader])
    
    
    Severity: Minor
    Found in lib/heidrun/mapping_tools/marc/genre.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 enumerate_records has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def enumerate_records
        Enumerator.new do |en|
          request_opts = opts.deep_dup
          @id_source.batches.each do |ids|
            request_opts['params']['naIds'] = ids.join(',')
    Severity: Minor
    Found in app/harvesters/nara_harvester.rb - About 1 hr to fix

      Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(uri, threads, max_records, record_class,
                         id_minter, harvester_name)
      Severity: Minor
      Found in app/harvesters/uva_harvester.rb - About 45 mins to fix

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

          def records
            Enumerator.new do |en|
              list_collections.each do |collection_uuid|
                page_count = collection_page_count(collection_uuid, @opts[:batchsize])
        
        
        Severity: Minor
        Found in app/harvesters/nypl_harvester.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 each_collection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def each_collection
            Dir.open(uri).each do |path|
              next unless path =~ /\.xml(\.gz)?/i
        
              File.open(File.join(uri, path)) do |fh|
        Severity: Minor
        Found in app/harvesters/smithsonian_harvester.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 enumerate_records has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def enumerate_records
            Enumerator.new do |yielder|
              enumerate_uris.lazy.each_slice(opts[:threads]).each do |uris|
                batch = []
        
        
        Severity: Minor
        Found in app/harvesters/loc_harvester.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 projected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def projected(opts)
                  return [] unless projected_medium?(opts[:leader])
                  
                  opts[:cf_007].each_with_object([]) do |cf, genres|
                    if slide?(cf) || transparency?(cf)
        Severity: Minor
        Found in lib/heidrun/mapping_tools/marc/genre.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 enrich_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def enrich_value(value)
            if value.is_a? String
              return nil if is_placeholder? value
            elsif value.respond_to?(:providedLabel)
              return nil if value.providedLabel.find { |l| !is_placeholder?(l) }.nil?
        Severity: Minor
        Found in app/enrichments/remove_placeholder.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 name_tag_condition has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def name_tag_condition(name, tag)
                lambda do |node| 
                  return false unless node.name == name
                  tag.is_a?(Regexp) ? (node[:tag] =~ tag) : (node[:tag] == tag)
                end
        Severity: Minor
        Found in lib/heidrun/mapping_tools/marc.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