Showing 722 of 1,271 total issues
Method normalize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def normalize(facts)
max = Setting[:maximum_structured_facts]
flat_counts = {}
dropped = 0
# Remove empty values first, so nil facts added by flatten_composite imply compose
- 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_taxonomies
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set_host_taxonomies(facts)
['location', 'organization'].each do |taxonomy|
taxonomy_class = taxonomy.classify.constantize
taxonomy_fact = Setting["#{taxonomy}_fact"]
- 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 power
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def power(args)
# get "/bmc/:host/chassis/power/:action"
# put "/bmc/:host/chassis/power/:action"
case args[:action]
when "on?", "off?", "status"
- 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_filtered_scope_components
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_filtered_scope_components(resource_class, all_filters, options)
result = { where: [], includes: [], joins: [] }
if all_filters.empty? || (!@base_collection.nil? && @base_collection.empty?)
Foreman::Logging.logger('permissions').debug 'no filters found for given permission' if all_filters.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 parse_string_value
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_string_value(val)
case settings_type
when "boolean"
boolean = Foreman::Cast.to_bool(val)
Method details
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def details(audit, path = audits_path(:search => "id=#{audit.id}"))
if audit.action == 'update'
return [] unless audit.audited_changes.present?
audit.audited_changes.map do |name, change|
next if change.nil? || change.to_s.empty?
Method operatingsystem
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def operatingsystem
os_name = facts['lsb::id'] || facts['platform']
release = facts['lsb::release'] || facts['platform_version']
# if we have no release information we can't assign OS properly (e.g. missing redhat-lsb)
if release.nil?
Function renderPrimaryRows
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const renderPrimaryRows = (
[node, ...remainingNodes],
level = 1,
posinset = 1,
rowIndex = 0,
Function WelcomeConfigReports
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const WelcomeConfigReports = () => {
const description = (
<>
{__("You don't seem to have any reports.")}
Function HostStatuses
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const HostStatuses = () => {
const url = foremanUrl('/api/v2/host_statuses?per_page=all');
const { status = STATUS.PENDING } = useAPI('get', url, API_OPTIONS);
const Skeleton = () => (
Method compute_resource_params_filter
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def compute_resource_params_filter
Foreman::ParameterFilter.new(::ComputeResource).tap do |filter|
filter.permit :description,
:display_type,
:name,
Function fetchResourcePools
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fetchResourcePools(url, clusterId) {
// eslint-disable-next-line camelcase
const data = { cluster_id: clusterId };
const $selectbox = $('select[id$="resource_pool"]');
Function submit_with_all_params
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function submit_with_all_params() {
$('form.hostresource-form input[type="submit"]').attr('disabled', true);
stop_pooling = false;
$('body').css('cursor', 'progress');
clear_errors();
Function initializeEditor
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const initializeEditor = initializeData => dispatch => {
const {
template,
locked,
type,
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {
show,
isLoading,
onChange,
Function handleMenuKeys
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleMenuKeys = event => {
if (
isAutocompleteOpen &&
searchInputRef.current &&
searchInputRef.current === event.target
Method search_by_user
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search_by_user(key, operator, value)
clean_key = key.sub(/^.*\./, '')
if value == "current_user"
value = User.current.id
clean_key = "id"
Method build_pxe_default
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.build_pxe_default
return [:unprocessable_entity, _("No TFTP proxies defined, can't continue")] if (proxies = SmartProxy.with_features("TFTP")).empty?
error_msgs = []
used_templates = []
TemplateKind::PXE.each do |kind|
Method method_missing
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.method_missing(method, *args, **kwargs, &block)
type = "Host::Managed"
case method.to_s
when /create/, 'new'
# in this case args should contain a hash with host attributes
Method id_to_label
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def id_to_label(name, change, audit: @audit, truncate: true)
return _("N/A") if change.nil?
case name
when "ancestry"
label = change.blank? ? "" : change.split('/').map { |i| Hostgroup.find(i).name rescue _("N/A") }.join('/')