Showing 722 of 1,271 total issues
Method schedule_report
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def schedule_report
@composer = ReportComposer.from_api_params(params)
if @composer.valid?
job = @composer.schedule_rendering
response = { job_id: job.provider_job_id }
- 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 set_host_type
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_host_type
return unless params[:host] && params[:host][:type]
type = params[:host].delete(:type) # important, otherwise mass assignment will save the type.
if type.constantize.new.is_a?(Host::Base)
@host = @host.becomes(type.constantize)
- 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 process_hostgroup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_hostgroup
@hostgroup = Hostgroup.find(params[:host][:hostgroup_id]) if params[:host][:hostgroup_id].to_i > 0
return head(:not_found) unless @hostgroup
refresh_host
@host.attributes = @host.apply_inherited_attributes(host_params) unless @host.new_record?
- 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 associate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def associate
if @compute_resource.supports_host_association?
associator = ComputeResourceHostAssociator.new(@compute_resource)
associator.associate_hosts
messages = []
- 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 operatingsystem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def operatingsystem
args = { :name => os_name, :major => os_major, :minor => os_minor }
args[:release_name] = os_release_name if os_name == 'Debian' || os_name == 'Ubuntu'
# for Ansible, the CentOS Stream can be identified by missing minor version only
args[:name] = "CentOS_Stream" if os_name == 'CentOS' && os_minor.blank?
- 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 valid?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def valid?
return false unless valid_host_token?
return false unless host_found?
return false unless host_os?
return false unless host_os_family?
- 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 find_interface_by_name
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_interface_by_name(host_name)
resolver = Resolv::DNS.new
resolver.timeouts = PRIMARY_INTERFACE_RESOLVE_TIMEOUTS
interfaces.detect do |int, values|
if (ip = values[:ipaddress]).present?
- 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 available?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def available?
if session.present? && (session[:sso_method] == "SSO::OpenidConnect")
session.delete(:sso_method) unless session[:user]
return true
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"
Further reading
Method add_ip_to_subnet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_ip_to_subnet(ip, subnet, group = "")
raise "subnet cannot be nil" if subnet.nil?
raise "ip cannot be nil" if ip.nil?
response = parse post({}, "/subnet/#{subnet}/#{ip}?group=#{CGI.escape(group.to_s)}")
raise(response['error']) if response.is_a?(Hash) && response['error'].present?
- 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 decode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.decode(node_id)
raise InvalidGlobalIdException.new(node_id, 'Not base64 encoded') unless base64_encoded?(node_id)
decoded = Base64.decode64(node_id)
version, payload = decoded.split(VERSION_SEPARATOR, 2)
raise InvalidGlobalIdException.new(node_id, "Version [#{version}] and payload [#{payload}]") unless version.present? && payload.present?
- 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 validate_each
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
subnet = record.public_send(@options[:subnet] || :subnet)
return if subnet.nil? || value.nil?
unless subnet.contains? value
record.errors.add(attribute, _("does not match selected 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 initiate_connection!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initiate_connection!
Timeout.timeout(Setting[:ssh_timeout].to_i) do
Timeout.timeout(8) do
ssh.run('pwd')
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"
Further reading
Method delete_ip_from_subnet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def delete_ip_from_subnet(ip, subnet, group = "")
raise "subnet cannot be nil" if subnet.nil?
raise "ip cannot be nil" if ip.nil?
response = parse delete("/subnet/#{subnet}/#{ip}?group=#{CGI.escape(group.to_s)}")
raise(response['error']) if response.is_a?(Hash) && response['error'].present?
- 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 mail
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def mail(headers = {}, &block)
if headers.present?
headers[:to] = utf8_encode(headers[:to])
headers[:subject] = "#{Setting[:email_subject_prefix]} #{headers[:subject]}" if (headers[:subject] && Setting[:email_subject_prefix].present?)
headers['X-Foreman-Server'] = URI.parse(Setting[:foreman_url]).host if Setting[:foreman_url].present?
- 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 render_all
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def render_all
self.errors = {}
templates.each do |template|
next if template.snippet
if template.operatingsystems.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 build
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def build(reboot: false)
# returns missed hosts
@hosts.select do |host|
success = true
begin
- 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 required?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def required?(attribute)
return false unless resource_class
return true if resource_class.columns_hash[attribute.to_s]&.null == false
- 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 install_packages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def install_packages(packages)
return '' if packages.blank?
banner = <<~CMD
echo '#'
- 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
Consider simplifying this complex logical expression. Open
if attrs.key?(:ip) || attrs.key?(:ip6)
logger.info "Waiting for #{name} to become ready"
compute_resource.vm_ready vm
logger.info "waiting for instance to acquire ip address"
vm.wait_for do
Consider simplifying this complex logical expression. Open
elsif input.value_type == 'plain' || input.value_type.nil?
textarea_f(f, :value, options.merge(rows: 2, class: input.hidden_value? ? 'masked-input' : ''))
else
input_type = input.value_type
case input_type