activesupport/lib/active_support/callbacks.rb

Summary

Maintainability
D
2 days
Test Coverage

File callbacks.rb has 559 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "active_support/concern"
require "active_support/descendants_tracker"
require "active_support/core_ext/array/extract_options"
require "active_support/core_ext/class/attribute"
require "active_support/core_ext/string/filters"
Severity: Major
Found in activesupport/lib/active_support/callbacks.rb - About 1 day to fix

    Method run_callbacks has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_callbacks(kind, type = nil)
          callbacks = __callbacks[kind.to_sym]
    
          if callbacks.empty?
            yield if block_given?
    Severity: Minor
    Found in activesupport/lib/active_support/callbacks.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 run_callbacks has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def run_callbacks(kind, type = nil)
          callbacks = __callbacks[kind.to_sym]
    
          if callbacks.empty?
            yield if block_given?
    Severity: Minor
    Found in activesupport/lib/active_support/callbacks.rb - About 1 hr to fix

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

              def skip_callback(name, *filter_list, &block)
                type, filters, options = normalize_callback_params(filter_list, block)
      
                options[:raise] = true unless options.key?(:raise)
      
      
      Severity: Minor
      Found in activesupport/lib/active_support/callbacks.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 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                def initialize(user_callback, user_conditions, chain_config, filter, name)
      Severity: Minor
      Found in activesupport/lib/active_support/callbacks.rb - About 35 mins to fix

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

                def initialize(name, filter, kind, options, chain_config)
        Severity: Minor
        Found in activesupport/lib/active_support/callbacks.rb - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status