Showing 719 of 1,266 total issues
Method permit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def permit(*args, &block)
new_filter = block_given? ? block : ->(ctx) { ctx.permit(*args) unless ctx.nested? }
@parameter_filters << new_filter
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 filter_params
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def filter_params(params, context, top_level_hash = nil)
top_level_hash ||= context.controller_name.singularize
if top_level_hash == :none
params.permit(*filter(context)).to_h
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 get_subnets_by_group
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_subnets_by_group(group)
raise "group must be provided" if group.blank?
response = parse get("/groups/#{CGI.escape(group)}/subnets")
raise(response['error']) if response.is_a?(Hash) && response['error'].present?
response
- 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 decoded_payload
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def decoded_payload
return @decoded_payload if defined?(@decoded_payload)
@decoded_payload = JWT.decode(token, nil, false).first
unless @decoded_payload.is_a?(Hash)
- 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 interfaces
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def interfaces
interfaces = super
return interfaces unless use_legacy_facts?
underscore_device_regexp = /\A([^_]*)_(\d+)\z/
interfaces.clone.each do |identifier, _|
- 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
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set(subnet, args)
raise "Must define a subnet" if subnet.empty?
raise "Must provide arguments" unless args.is_a?(Hash)
parse(post(args, subnet.to_s))
rescue => e
- 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_additional_attributes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def set_additional_attributes(attributes, name)
if name =~ VIRTUAL_NAMES
attributes[:virtual] = true
if Regexp.last_match(1).nil? && name =~ BRIDGES
attributes[:bridge] = true
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
record.errors.add attribute, _("must contain valid hostnames") unless value.all? do |item|
item.to_s.match(URI::HOST) || (IPAddr.new(item.to_s) rescue nil)
end
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 templates_status
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def templates_status
fail!(:templates, _('No templates found for this host.')) if available_template_kinds.empty?
available_template_kinds.each do |template|
Rails.logger.info "Rendering #{template}"
- 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 update_plugin_role_permissions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_plugin_role_permissions(role, permissions)
Role.ignore_locking do
missing_permissions = role.missing_permissions(permissions)
role.add_permissions!(missing_permissions) unless missing_permissions.empty?
extra_permissions = role.extra_permissions(permissions)
- 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_host_token?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def valid_host_token?
return true unless @needs_token
return true unless for_host_template
return true unless @host&.token_expired?
- 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_mac
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.validate_mac(mac)
return false if mac.nil?
case mac.size
when 17
- 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 update_role_permissions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_role_permissions(role, options)
desired_permissions = options[:permissions].map(&:to_s)
existing_permissions = role.permissions.where(:name => PermissionsList.permissions.map(&:last)).pluck(:name)
role.ignore_locking do
- 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 os_minor
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def os_minor
if os_name == 'Ubuntu'
_, _, minor = os_release&.split('.', 3)
else
_, minor = os_release&.split('.', 2) ||
- 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 sequence_hostgroup_param_next
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sequence_hostgroup_param_next(hostgroup_name, increment = 1, name = "default", prefix = 1)
# This helper cannot be in a host-context because it was built mainly for discovery naming
# where host-hostgroup was not yet set. This macro allows accessing hostgroup parameters
# named starting with "sequence_num_" and increasing those counters which is not a security
# threat.
- 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 update_facts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_facts
time = Time.now.utc
updated = 0
db_facts = host.fact_values.joins(:fact_name).where(fact_names: {type: fact_name_class_name}).reorder(nil).pluck(:name, :value, :id)
db_facts.each do |name, value, 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 validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate
errors = []
os = entity.try(:operatingsystem)
medium = entity.try(:medium)
arch = entity.try(:architecture)
- 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 save_to_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_to_file(filename, content, verbatim: false)
delimiter = 'EOF-' + Digest::SHA512.hexdigest(filename)[0..7]
if content.empty?
"cp /dev/null #{filename}"
elsif verbatim
- 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 authenticated?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def authenticated?
return false unless (self.user = request.env[CAS_USERNAME])
attrs = { :login => user }.merge(additional_attributes)
attrs[:mail] = nil if attrs[:mail] == "(null)"
if request.env.has_key?('HTTP_REMOTE_USER_GROUPS')
- 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"