app/services/carto/visualizations_export_service_2.rb
File visualizations_export_service_2.rb
has 391 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
require 'json'
require_dependency 'carto/export/layer_exporter'
require_dependency 'carto/export/data_import_exporter'
# Version History
Method build_visualization_from_hash
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def build_visualization_from_hash(exported_visualization)
exported_layers = exported_visualization[:layers]
exported_overlays = exported_visualization[:overlays]
visualization = Carto::Visualization.new(
Method export_visualization
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Method link_synchronization_with_connection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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?
- Read upRead up
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"