glitch-soc/mastodon

View on GitHub
lib/mastodon/migration_helpers.rb

Summary

Maintainability
D
2 days
Test Coverage

File migration_helpers.rb has 411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Mastodon
  module MigrationHelpers
    class CorruptionError < StandardError
      attr_reader :index_name

Severity: Minor
Found in lib/mastodon/migration_helpers.rb - About 5 hrs to fix

    Method update_column_in_batches has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_column_in_batches(table_name, column, value)
          if transaction_open?
            raise 'update_column_in_batches can not be run inside a transaction, ' \
              'you can disable transactions by calling disable_ddl_transaction! ' \
              'in the body of your migration class'
    Severity: Minor
    Found in lib/mastodon/migration_helpers.rb - About 4 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 cleanup_concurrent_column_type_change has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def cleanup_concurrent_column_type_change(table, column)
          temp_column = rename_column_name(column)
    
          # Wait for the indices to be built
          indexes_for(table, column).each do |index|
    Severity: Major
    Found in lib/mastodon/migration_helpers.rb - About 2 hrs to fix

      Method update_column_in_batches has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update_column_in_batches(table_name, column, value)
            if transaction_open?
              raise 'update_column_in_batches can not be run inside a transaction, ' \
                'you can disable transactions by calling disable_ddl_transaction! ' \
                'in the body of your migration class'
      Severity: Major
      Found in lib/mastodon/migration_helpers.rb - About 2 hrs to fix

        Method cleanup_concurrent_column_type_change has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def cleanup_concurrent_column_type_change(table, column)
              temp_column = rename_column_name(column)
        
              # Wait for the indices to be built
              indexes_for(table, column).each do |index|
        Severity: Minor
        Found in lib/mastodon/migration_helpers.rb - About 1 hr 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 rename_column_concurrently has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def rename_column_concurrently(table, old, new, type: nil)
              if transaction_open?
                raise 'rename_column_concurrently can not be run inside a transaction'
              end
        
        
        Severity: Minor
        Found in lib/mastodon/migration_helpers.rb - About 1 hr to fix

          Method copy_indexes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def copy_indexes(table, old, new)
                old = old.to_s
                new = new.to_s
          
                indexes_for(table, old).each do |index|
          Severity: Minor
          Found in lib/mastodon/migration_helpers.rb - About 1 hr 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 rename_column_concurrently has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def rename_column_concurrently(table, old, new, type: nil)
                if transaction_open?
                  raise 'rename_column_concurrently can not be run inside a transaction'
                end
          
          
          Severity: Minor
          Found in lib/mastodon/migration_helpers.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