fairplaysk/datacamp

View on GitHub
lib/etl/vvo_extraction_v2.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def save
      procurement_digest = digest

      # TODO refactor
      case dataset_type
Severity: Minor
Found in lib/etl/vvo_extraction_v2.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 save has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def save
      procurement_digest = digest

      # TODO refactor
      case dataset_type
Severity: Minor
Found in lib/etl/vvo_extraction_v2.rb - About 1 hr to fix

    Method digest_attributes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def digest_attributes
          case dataset_type
            when :notice
              [
                  # Basic information
    Severity: Minor
    Found in lib/etl/vvo_extraction_v2.rb - About 1 hr to fix

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

          def self.dataset_type(document_type)
            return nil unless document_type
            if document_type.start_with?('V') || document_type.start_with?('IP')
              :notice
            elsif document_type.start_with?('IZ') || document_type.start_with?('ID')
      Severity: Minor
      Found in lib/etl/vvo_extraction_v2.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 parse_all_downloaded_documents_for_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.parse_all_downloaded_documents_for_type(dataset_type)
            ids = Dir.glob("data/#{Rails.env}/vvo/procurements/*/*.html").map { |n| File.basename(n, ".html").to_i }
            ids.each_with_index do |document_id, index|
              ext = Etl::VvoExtractionV2.new(document_id)
              if ext.dataset_type == dataset_type
      Severity: Minor
      Found in lib/etl/vvo_extraction_v2.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