CartoDB/cartodb20

View on GitHub
app/services/carto/visualizations_export_service_2.rb

Summary

Maintainability
C
1 day
Test Coverage

File visualizations_export_service_2.rb has 391 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require_dependency 'carto/export/layer_exporter'
require_dependency 'carto/export/data_import_exporter'

# Version History
Severity: Minor
Found in app/services/carto/visualizations_export_service_2.rb - About 5 hrs to fix

    Method build_visualization_from_hash has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_visualization_from_hash(exported_visualization)
          exported_layers = exported_visualization[:layers]
          exported_overlays = exported_visualization[:overlays]
    
          visualization = Carto::Visualization.new(
    Severity: Minor
    Found in app/services/carto/visualizations_export_service_2.rb - About 1 hr to fix

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

          def export_visualization(visualization, user, with_mapcaps: true, with_password: false)
            layers = visualization.layers_with_data_readable_by(user)
            active_layer_id = visualization.active_layer_id
            layer_exports = layers.map do |layer|
              export_layer(layer, active_layer: active_layer_id == layer.id)
      Severity: Minor
      Found in app/services/carto/visualizations_export_service_2.rb - About 1 hr to fix

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

            def link_synchronization_with_connection(synchronization, user_data)
              return if synchronization.blank? || synchronization.service_name != 'connector'
        
              user = Carto::User.find_by(username: user_data.try(:[], :username))
              return if user.blank?
        Severity: Minor
        Found in app/services/carto/visualizations_export_service_2.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

        There are no issues that match your filters.

        Category
        Status