CartoDB/cartodb20

View on GitHub
services/twitter-search/lib/twitter-search/json_to_csv_converter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method process has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

      def process(input_data, add_headers = true, additional_fields = {})
        results = []

        if add_headers
          results_row = INDIVIDUAL_FIELDS.map { |field|
Severity: Minor
Found in services/twitter-search/lib/twitter-search/json_to_csv_converter.rb - About 5 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 process has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def process(input_data, add_headers = true, additional_fields = {})
        results = []

        if add_headers
          results_row = INDIVIDUAL_FIELDS.map { |field|
Severity: Major
Found in services/twitter-search/lib/twitter-search/json_to_csv_converter.rb - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                if !location[:geo].nil? && !location[:geo].empty? && !location[:geo][:type].nil? &&
                   !location[:geo][:type].empty? && location[:geo][:type] == 'point' && output.nil?
    
                  output = ::JSON.dump(location[:geo])
                end
    Severity: Major
    Found in services/twitter-search/lib/twitter-search/json_to_csv_converter.rb - About 40 mins to fix

      Method calculate_the_geom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def calculate_the_geom(row)
              output = nil
      
              # Point
              if !row[:geo].nil? && !row[:geo].empty?
      Severity: Minor
      Found in services/twitter-search/lib/twitter-search/json_to_csv_converter.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