CartoDB/cartodb20

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

Summary

Maintainability
B
6 hrs
Test Coverage

Class Unp has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Unp
      HIDDEN_FILE_REGEX     = /^(\.|\_{2})/
      COMPRESSED_EXTENSIONS = %w{ .zip .gz .tgz .tar.gz .bz2 .tar .kmz .rar .carto }.freeze
      SUPPORTED_FORMATS     = %w{
        .csv .shp .ods .xls .xlsx .tif .tiff .kml .kmz
Severity: Minor
Found in services/importer/lib/importer/unp.rb - About 2 hrs to fix

    Method crawl has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def crawl(path, files=[])
            Dir.foreach(path) do |subpath|
              raise EncodingError unless filename_valid_encoding?(subpath)
              next if hidden?(subpath)
              next if subpath =~ /.*readme.*\.txt/i
    Severity: Minor
    Found in services/importer/lib/importer/unp.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 extract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def extract(path)
            raise ExtractionError unless File.exists?(path)
    
            local_path = "#{temporary_directory}/#{File.basename(path)}"
            FileUtils.cp(path, local_path)
    Severity: Minor
    Found in services/importer/lib/importer/unp.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

    There are no issues that match your filters.

    Category
    Status