app/models/foreman_salt/concerns/host_managed_extensions.rb
Method salt_modules_in_host_environment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def salt_modules_in_host_environment
return unless salt_modules.any?
if salt_environment
errors.add(:base, _('Salt states must be in the environment of the host')) unless (salt_modules - salt_environment.salt_modules).empty?
- 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 derive_salt_grains
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def derive_salt_grains(use_autosign: false)
grains = {}
begin
Rails.logger.info('Derive Salt Grains from host_params and autosign_key')
grains[autosign_grain_name] = salt_autosign_key if use_autosign && !salt_autosign_key.nil?
- 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"