pboling/resque-unique_by_arity

View on GitHub

Showing 8 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                    Resque::UniqueByArity.log("#{Resque::UniqueByArity::PLUGIN_TAG}#{Resque::UniqueAtRuntime::PLUGIN_TAG} #{ColorizedString['Purging'].red} #{keys.length} keys from #{ColorizedString[key_match].red}")
      Severity: Minor
      Found in lib/resque/unique_by_arity/modulizer.rb and 1 other location - About 20 mins to fix
      lib/resque/unique_by_arity/modulizer.rb on lines 66..66

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 28.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                    Resque::UniqueByArity.log("#{Resque::UniqueByArity::PLUGIN_TAG}#{Resque::UniqueInQueue::PLUGIN_TAG} #{ColorizedString['Purging'].red} #{keys.length} keys from #{ColorizedString[key_match].red}")
      Severity: Minor
      Found in lib/resque/unique_by_arity/modulizer.rb and 1 other location - About 20 mins to fix
      lib/resque/unique_by_arity/modulizer.rb on lines 108..108

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 28.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language