dougyouch/db-purger

View on GitHub

Showing 6 of 10 total issues

Method purge_in_batches! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def purge_in_batches!
      scope = model
      scope = scope.where(@table.conditions) if @table.conditions

      instrumentation_name = 'next_batch.db_purger'
Severity: Minor
Found in lib/db-purger/purge_table_scanner.rb - About 1 hr to fix

    Method build has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def build(base_table_name, field)
          write_table('base', base_table_name.to_s, field, [], nil)
          line_break
          model = find_model_for_table(base_table_name)
          foreign_key = foreign_key_name(model)
    Severity: Minor
    Found in lib/db-purger/dynamic_plan_builder.rb - About 55 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 write_table has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def write_table(table_type, table_name, field, child_models, foreign_key)
    Severity: Minor
    Found in lib/db-purger/dynamic_plan_builder.rb - About 35 mins to fix

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

          def purge_foreign_tables(batch)
            @table.nested_plan.child_tables.each do |table|
              next unless table.foreign_key
              next if (purge_values = batch_values(batch, table.foreign_key)).empty?
      
      
      Severity: Minor
      Found in lib/db-purger/purge_table_helper.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 add_parent_tables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_parent_tables(base_table_name, field)
            @database.models.each do |model|
              next if model.table_name == base_table_name.to_s
              next unless column?(model, field)
      
      
      Severity: Minor
      Found in lib/db-purger/dynamic_plan_builder.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 purge_in_batches! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def purge_in_batches!
            scope = model
            scope = scope.where(@table.conditions) if @table.conditions
      
            instrumentation_name = 'next_batch.db_purger'
      Severity: Minor
      Found in lib/db-purger/purge_table_scanner.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