rpanachi/core_ext

View on GitHub
lib/core_ext/callbacks.rb

Summary

Maintainability
D
1 day
Test Coverage

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

require 'core_ext/concern'
require 'core_ext/descendants_tracker'
require 'core_ext/array/extract_options'
require 'core_ext/class/attribute'
require 'core_ext/kernel/reporting'
Severity: Minor
Found in lib/core_ext/callbacks.rb - About 7 hrs to fix

    Method make_lambda has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def make_lambda(filter)
            case filter
            when Symbol
              lambda { |target, _, &blk| target.send filter, &blk }
            when String
    Severity: Minor
    Found in lib/core_ext/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 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)
    
            __update_callbacks(name) do |target, chain|
    Severity: Minor
    Found in lib/core_ext/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 make_lambda has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def make_lambda(filter)
            case filter
            when Symbol
              lambda { |target, _, &blk| target.send filter, &blk }
            when String
    Severity: Minor
    Found in lib/core_ext/callbacks.rb - About 1 hr to fix

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

            def deprecated_false_terminator # :nodoc:
              Proc.new do |target, result_lambda|
                terminate = true
                catch(:abort) do
                  result = result_lambda.call if result_lambda.is_a?(Proc)
      Severity: Minor
      Found in lib/core_ext/callbacks.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

                def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
        Severity: Minor
        Found in lib/core_ext/callbacks.rb - About 35 mins to fix

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

                  def self.build(callback_sequence, user_callback, user_conditions, chain_config, filter)
          Severity: Minor
          Found in lib/core_ext/callbacks.rb - About 35 mins to fix

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

                    def self.build(callback_sequence, user_callback, user_conditions, chain_config)
                      if chain_config[:skip_after_callbacks_if_terminated]
                        if user_conditions.any?
                          halting_and_conditional(callback_sequence, user_callback, user_conditions)
                        else
            Severity: Minor
            Found in lib/core_ext/callbacks.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 halting_and_conditional has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def self.halting_and_conditional(callback_sequence, user_callback, user_conditions, halted_lambda, filter)
                      callback_sequence.before do |env|
                        target = env.target
                        value  = env.value
                        halted = env.halted
            Severity: Minor
            Found in lib/core_ext/callbacks.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 halting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def self.halting(callback_sequence, user_callback, halted_lambda, filter)
                      callback_sequence.before do |env|
                        target = env.target
                        value  = env.value
                        halted = env.halted
            Severity: Minor
            Found in lib/core_ext/callbacks.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

            There are no issues that match your filters.

            Category
            Status