steverice/pt-osc

View on GitHub

Showing 6 of 6 total issues

Method command_flags has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def command_flags(options)
      options.flat_map do |key, value|
        next if key == 'execute'
        flag_options = self.class.percona_flags[key]

Severity: Minor
Found in lib/active_record/pt_osc_migration.rb - About 3 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

Class PtOscMigration has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class PtOscMigration < Migration
    # @TODO whitelist all valid pt-osc flags
    PERCONA_FLAGS = {
      'defaults-file' => {
        mutator: :make_path_absolute,
Severity: Minor
Found in lib/active_record/pt_osc_migration.rb - About 2 hrs to fix

    Method migrate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def migrate(direction)
          return unless respond_to?(direction)
    
          run_mode = percona_config[:run_mode] || 'print'
          raise ArgumentError.new('Invalid run_mode specified in database config') unless run_mode.in? %w(print execute)
    Severity: Minor
    Found in lib/active_record/pt_osc_migration.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

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

        def migrate(direction)
          return unless respond_to?(direction)
    
          run_mode = percona_config[:run_mode] || 'print'
          raise ArgumentError.new('Invalid run_mode specified in database config') unless run_mode.in? %w(print execute)
    Severity: Minor
    Found in lib/active_record/pt_osc_migration.rb - About 1 hr to fix

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

          def execute_sql_for_table(execute_sql, database_name, table_name, dry_run = true)
            command = percona_command(execute_sql, database_name, table_name, execute: !dry_run)
            logger.info "Command is #{self.class.sanitize_command(command)}"
      
            success = Kernel.system command
      Severity: Minor
      Found in lib/active_record/pt_osc_migration.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

      Method percona_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def percona_command(execute_sql, database_name, table_name, options = {})
            command = ['pt-online-schema-change', '--alter', execute_sql || '', "D=#{database_name},t=#{table_name}"]
      
            # Whitelist
            options = HashWithIndifferentAccess.new(options)
      Severity: Minor
      Found in lib/active_record/pt_osc_migration.rb - About 25 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

      Severity
      Category
      Status
      Source
      Language