Showing 11 of 11 total issues
Class Scheduler
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Scheduler
# We expect rufus jobs to have #params
Rufus::Scheduler::Job.module_eval do
alias_method :params, :opts
end
Method set_current_scheduler_options
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set_current_scheduler_options(config)
enabled = SidekiqScheduler::Scheduler.enabled
dynamic = SidekiqScheduler::Scheduler.dynamic
dynamic_every = SidekiqScheduler::Scheduler.dynamic_every
listened_queues_only = SidekiqScheduler::Scheduler.listened_queues_only
- Read upRead up
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 load_schedule!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def load_schedule!
if enabled
Sidekiq.logger.info 'Loading Schedule'
# Load schedule from redis for the first time if dynamic
- Read upRead up
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 check_using_old_sidekiq_scheduler_config!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.check_using_old_sidekiq_scheduler_config!(sidekiq_config)
%i[enabled dynamic dynamic_every schedule listened_queues_only rufus_scheduler_options].each do |option|
if SIDEKIQ_GTE_7_0_0
if sidekiq_config.key?(option)
raise OptionNotSupportedAnymore, ":#{option} option should be under the :scheduler: key"
- Read upRead up
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 load_schedule_job
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def load_schedule_job(name, config)
# If rails_env is set in the config, enforce ENV['RAILS_ENV'] as
# required for the jobs to be scheduled. If rails_env is missing, the
# job should be scheduled regardless of what ENV['RAILS_ENV'] is set
# to.
- Read upRead up
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 sidekiq_queues
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.sidekiq_queues(sidekiq_config)
if SIDEKIQ_GTE_7_0_0
if sidekiq_config.nil? || (sidekiq_config.respond_to?(:empty?) && sidekiq_config.empty?)
Sidekiq.instance_variable_get(:@config).queues.map(&:to_s)
else
- Read upRead up
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 new_job
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def new_job(name, interval_type, config, schedule, options)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.stringify_keys(object)
if object.is_a?(Hash)
Hash[[*object.map { |k, v| [k.to_s, stringify_keys(v) ]} ]]
elsif object.is_a?(Array) || object.is_a?(Set)
- Read upRead up
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 35.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def self.symbolize_keys(object)
if object.is_a?(Hash)
Hash[[*object.map { |k, v| [k.to_sym, symbolize_keys(v) ]} ]]
elsif object.is_a?(Array) || object.is_a?(Set)
- Read upRead up
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 35.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method symbolize_keys
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.symbolize_keys(object)
if object.is_a?(Hash)
Hash[[*object.map { |k, v| [k.to_sym, symbolize_keys(v) ]} ]]
elsif object.is_a?(Array) || object.is_a?(Set)
- Read upRead up
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 stringify_keys
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.stringify_keys(object)
if object.is_a?(Hash)
Hash[[*object.map { |k, v| [k.to_s, stringify_keys(v) ]} ]]
elsif object.is_a?(Array) || object.is_a?(Set)
- Read upRead up
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"