CartoDB/cartodb20

View on GitHub
services/importer/lib/importer/runner.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Runner has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Runner
      include CartoDB::Importer2::QuotaCheckHelpers
      include CartoDB::Importer2::RunnerHelper
      include ::LoggerHelper

Severity: Minor
Found in services/importer/lib/importer/runner.rb - About 4 hrs to fix

    File runner.rb has 345 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative './loader'
    require_relative './tiff_loader'
    require_relative './sql_loader'
    require_relative './unp'
    require_relative './column'
    Severity: Minor
    Found in services/importer/lib/importer/runner.rb - About 4 hrs to fix

      Method import has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

            def import(source_file, downloader, loader_object = nil)
              loader = loader_object || loader_for(source_file).new(@job, source_file)
      
              raise EmptyFileError if source_file.empty?
      
      
      Severity: Minor
      Found in services/importer/lib/importer/runner.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 single_resource_import has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

            def single_resource_import
              @importer_stats.timing('resource') do
                @importer_stats.timing('download') do
                  @downloader.run(available_quota)
                  return self unless remote_data_updated?
      Severity: Minor
      Found in services/importer/lib/importer/runner.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 import has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def import(source_file, downloader, loader_object = nil)
              loader = loader_object || loader_for(source_file).new(@job, source_file)
      
              raise EmptyFileError if source_file.empty?
      
      
      Severity: Major
      Found in services/importer/lib/importer/runner.rb - About 2 hrs to fix

        Method single_resource_import has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def single_resource_import
                @importer_stats.timing('resource') do
                  @importer_stats.timing('download') do
                    @downloader.run(available_quota)
                    return self unless remote_data_updated?
        Severity: Minor
        Found in services/importer/lib/importer/runner.rb - About 1 hr to fix

          Method multi_resource_import has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def multi_resource_import
                  log.append "Starting multi-resources import"
                  # [ {:id, :title} ]
                  @downloader.item_metadata[:subresources].each_with_index { |subresource, index|
                    @job.new_table_name if index > 0
          Severity: Minor
          Found in services/importer/lib/importer/runner.rb - About 1 hr to fix

            Method multi_resource_import has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                  def multi_resource_import
                    log.append "Starting multi-resources import"
                    # [ {:id, :title} ]
                    @downloader.item_metadata[:subresources].each_with_index { |subresource, index|
                      @job.new_table_name if index > 0
            Severity: Minor
            Found in services/importer/lib/importer/runner.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 result_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def result_for(job, source_file, table_names, support_table_names=[], exception_klass=nil)
            Severity: Minor
            Found in services/importer/lib/importer/runner.rb - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status