lowjoel/database_transform

View on GitHub

Showing 7 of 7 total issues

Method transform_record_columns! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def transform_record_columns!(schema, old, new)
    @columns.each do |column|
      fail ArgumentError.new unless column.is_a?(Hash)

      new_value = transform_record_field!(schema, old, new, column[:from], column[:block])
Severity: Minor
Found in lib/database_transform/schema_table.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 transform_record_field! has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def transform_record_field!(schema, source, destination, from = nil, block = nil)
Severity: Minor
Found in lib/database_transform/schema_table.rb - About 35 mins to fix

    Method execute_transform_block! has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def execute_transform_block!(schema, source_record, self_, block, args)
    Severity: Minor
    Found in lib/database_transform/schema_table.rb - About 35 mins to fix

      Method save_transformed_record has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def save_transformed_record(old, new)
          # Save. Skip if the conditional callback is given
          return if @save && @save[:if] && !new.instance_exec(&@save[:if])
          validate = @save ? @save[:validate] : nil
      
      
      Severity: Minor
      Found in lib/database_transform/schema_table.rb - About 35 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 column has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def column(*args, &block)
          raise ArgumentError if args.length < 1
      
          # Get the columns
          options = args.extract_options!
      Severity: Minor
      Found in lib/database_transform/schema_table.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

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

        def save(options = {})
          raise ArgumentError.new('unless and if cannot be both specified') if options[:unless] && options[:if]
          raise ArgumentError.new('Cannot specify a save clause twice for the same table') if @save
      
          if options[:unless]
      Severity: Minor
      Found in lib/database_transform/schema_table.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

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

        def validate_column_options!(source_columns, to_column, options, block)
          raise ArgumentError.new unless to_column.nil? || to_column.is_a?(Symbol)
          raise ArgumentError.new if !block && source_columns.length > 1
          raise ArgumentError.new if options[:null] == false && !to_column
        end
      Severity: Minor
      Found in lib/database_transform/schema_table.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