app/models/concerns/foreman_remote_execution/host_extensions.rb
Method prepended
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.prepended(base)
base.instance_eval do
has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id', :dependent => :destroy
Method remote_execution_proxies
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def remote_execution_proxies(provider, authorized = true)
proxies = {}
proxies[:subnet] = []
proxies[:subnet] += execution_interface.subnet6.remote_execution_proxies.with_features(provider) if execution_interface&.subnet6
proxies[:subnet] += execution_interface.subnet.remote_execution_proxies.with_features(provider) if execution_interface&.subnet
- 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 search_by_job_invocation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def search_by_job_invocation(key, operator, value)
if key == 'job_invocation.result'
operator = operator == '=' ? 'IN' : 'NOT IN'
value = TemplateInvocation::TaskResultMap.status_to_task_result(value)
end
- 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"