app/services/carto/visualizations_export_persistence_service.rb
Method save_import
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
Open
def save_import(user, visualization, renamed_tables: {}, full_restore: false)
old_username = visualization.user.username if visualization.user
apply_user_limits(user, visualization)
ActiveRecord::Base.transaction do
visualization.id = random_uuid unless visualization.id && full_restore
- 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"
Further reading
Method save_import
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def save_import(user, visualization, renamed_tables: {}, full_restore: false)
old_username = visualization.user.username if visualization.user
apply_user_limits(user, visualization)
ActiveRecord::Base.transaction do
visualization.id = random_uuid unless visualization.id && full_restore
Method apply_user_limits
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Open
def apply_user_limits(user, visualization)
can_be_private = visualization.derived? ? user.private_maps_enabled : user.private_tables_enabled
unless can_be_private
visualization.privacy = Carto::Visualization::PRIVACY_PUBLIC
visualization.user_table.privacy = Carto::UserTable::PRIVACY_PUBLIC if visualization.canonical?
- 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"