bkayser/cleansweep

View on GitHub

Showing 8 of 8 total issues

Method execute_in_batches has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def execute_in_batches

    if @dry_run
      log :info, print_queries
      return 0
Severity: Minor
Found in lib/clean_sweep/purge_runner.rb - About 5 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 execute_in_batches has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def execute_in_batches

    if @dry_run
      log :info, print_queries
      return 0
Severity: Minor
Found in lib/clean_sweep/purge_runner.rb - About 1 hr to fix

    Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(options={})
        @model     = options[:model] or raise "source model class required"
        @limit            = options[:chunk_size] || 500
    
        @target_model     = options[:dest_model]
    Severity: Minor
    Found in lib/clean_sweep/purge_runner.rb - About 1 hr to fix

      Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(model, options={})
      
          traversing_key_name  = options[:index]
          ascending            = !options[:reverse]
          first_only           = options[:first_only]
      Severity: Minor
      Found in lib/clean_sweep/table_schema.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 initialize has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(model, options={})
      
          traversing_key_name  = options[:index]
          ascending            = !options[:reverse]
          first_only           = options[:first_only]
      Severity: Minor
      Found in lib/clean_sweep/table_schema.rb - About 1 hr to fix

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

          def initialize(options={})
            @model     = options[:model] or raise "source model class required"
            @limit            = options[:chunk_size] || 500
        
            @target_model     = options[:dest_model]
        Severity: Minor
        Found in lib/clean_sweep/purge_runner.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 with_reconnect_handling has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def with_reconnect_handling
            begin
              yield
            rescue ActiveRecord::StatementInvalid => e
              if e.message =~ /Lost connection to MySQL server during query/
        Severity: Minor
        Found in lib/clean_sweep/purge_runner.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 get_violations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_violations
            violations = {}
            if @max_history
              current = get_history_length
              violations["history length"] = "#{(current/1_000_000.0)} m" if threshold(@max_history) < current
        Severity: Minor
        Found in lib/clean_sweep/purge_runner/mysql_status.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