CartoDB/cartodb20

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

Summary

Maintainability
D
2 days
Test Coverage

Method save_import has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
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
Severity: Minor
Found in app/services/carto/visualizations_export_persistence_service.rb - About 1 day 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_import has 80 lines of code (exceeds 25 allowed). Consider refactoring.
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
Severity: Major
Found in app/services/carto/visualizations_export_persistence_service.rb - About 3 hrs to fix

    Method apply_user_limits has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    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?
    Severity: Minor
    Found in app/services/carto/visualizations_export_persistence_service.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

    There are no issues that match your filters.

    Category
    Status