pboling/resque-unique_by_arity

View on GitHub

Showing 6 of 8 total issues

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

      def initialize(**options)
        @logger = options.key?(:logger) ? options[:logger] : defcon(:logger) || Logger.new(STDOUT)
        @log_level = options.key?(:log_level) ? options[:log_level] : defcon(:log_level) || :debug
        @arity_for_uniqueness = options.key?(:arity_for_uniqueness) ? options[:arity_for_uniqueness] : defcon(:arity_for_uniqueness) || 1
        @arity_for_uniqueness_at_runtime = options.key?(:arity_for_uniqueness_at_runtime) ? options[:arity_for_uniqueness_at_runtime] : defcon(:arity_for_uniqueness_at_runtime) || @arity_for_uniqueness
Severity: Minor
Found in lib/resque/unique_by_arity/configuration.rb - About 6 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 to_mod has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

      def self.to_mod(configuration)
        Module.new do
          if configuration.unique_in_queue || configuration.unique_at_runtime || configuration.unique_across_queues
            # @return [Array<String, arguments>] the key base hash used to enforce uniqueness, and the arguments from the payload used to calculate it
            define_method(:redis_unique_hash) do |payload, arity_for_uniqueness|
Severity: Minor
Found in lib/resque/unique_by_arity/modulizer.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 to_mod has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.to_mod(configuration)
        Module.new do
          if configuration.unique_in_queue || configuration.unique_at_runtime || configuration.unique_across_queues
            # @return [Array<String, arguments>] the key base hash used to enforce uniqueness, and the arguments from the payload used to calculate it
            define_method(:redis_unique_hash) do |payload, arity_for_uniqueness|
Severity: Major
Found in lib/resque/unique_by_arity/modulizer.rb - About 2 hrs to fix

    Method included has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def included(base)
            return unless @configuration
    
            # We don't have access to the base class when initializing, but...
            #   we do initialize unique instances of the module for each class.
    Severity: Minor
    Found in lib/resque/plugins/unique_by_arity.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 included has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def included(base)
            return unless @configuration
    
            # We don't have access to the base class when initializing, but...
            #   we do initialize unique instances of the module for each class.
    Severity: Minor
    Found in lib/resque/plugins/unique_by_arity.rb - About 1 hr to fix

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

            def validate_arity(klass_string, perform_method)
              return true if skip_arity_validation?
      
              # method.arity -
              #   Returns an indication of the number of arguments accepted by a method.
      Severity: Minor
      Found in lib/resque/unique_by_arity/configuration.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

      Severity
      Category
      Status
      Source
      Language