CartoDB/cartodb20

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

Summary

Maintainability
B
5 hrs
Test Coverage

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

      def set_downloaded_source_file(available_quota_in_bytes=nil)
        @checksum = @item_metadata[:checksum]
        return self unless modified?

        stream_to_file = @datasource.kind_of? CartoDB::Datasources::BaseFileStream
Severity: Minor
Found in services/importer/lib/importer/datasource_downloader.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 set_downloaded_source_file has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def set_downloaded_source_file(available_quota_in_bytes=nil)
        @checksum = @item_metadata[:checksum]
        return self unless modified?

        stream_to_file = @datasource.kind_of? CartoDB::Datasources::BaseFileStream
Severity: Minor
Found in services/importer/lib/importer/datasource_downloader.rb - About 1 hr to fix

    Method modified? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def modified?
            previous_checksum = @options.fetch(:checksum, false)
            previous_checksum = false if previous_checksum == ''  # If comes empty from DB, make pure false
            checksum          = (@checksum.nil? || @checksum.size == 0) ? false : @checksum
    
    
    Severity: Minor
    Found in services/importer/lib/importer/datasource_downloader.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(datasource, item_metadata, options = {}, logger = nil, repository = nil)
    Severity: Minor
    Found in services/importer/lib/importer/datasource_downloader.rb - About 35 mins to fix

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

            def store_retrieved_data(filename, resource_data, available_quota_in_bytes)
              if resource_data.is_a?(StringIO)
                return if resource_data.size.zero?
                data = resource_data
              else
      Severity: Minor
      Found in services/importer/lib/importer/datasource_downloader.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

      There are no issues that match your filters.

      Category
      Status