Showing 722 of 1,271 total issues
Method setup_roles!
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def setup_roles!
return false if Foreman.in_setup_db_rake? || !permission_table_exists? || User.unscoped.find_by_login(User::ANONYMOUS_ADMIN).nil?
Role.without_auditing do
Filter.without_auditing do
default_roles.each do |name, 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 auth_smart_proxy
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def auth_smart_proxy(proxies = SmartProxy.unscoped.all)
request_hosts = nil
if request.ssl?
# If we have the client certficate in the request environment we can extract the dn and sans from there
# if not we use the dn in the request environment
- 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
Function interface_subnet_selected
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
function interface_subnet_selected(element, ip_field, skip_mac) {
// mark the selected value to preserve it for form hiding
preserve_selected_options($(element));
if ($(element).attr('disabled')) return;
File Editor.js
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import PropTypes from 'prop-types';
import { ToastNotification } from 'patternfly-react';
import { noop } from '../../common/helpers';
File TableHooks.js
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
import { isEmpty } from 'lodash';
import { useLocation } from 'react-router-dom';
class ReactConnectedSet extends Set {
Class TaxHost
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class TaxHost
FOREIGN_KEYS = [:location_id, :organization_id, :hostgroup_id,
:domain_id, :medium_id, :subnet_id,
:compute_resource_id, :realm_id, :ptable_id]
Function ConfirmModal
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
const ConfirmModal = () => {
const {
id,
isOpen,
title,
Function methodSignature
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const methodSignature = (method, isSnippet) => {
if (isEmpty(method.params)) return method.name;
let currParam = 1;
const params = method.params.map(p => {
- 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_tags
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def parse_tags(args)
# Merge AWS EC2 tags
tags = {}
if (name = args[:name])
tags = {:Name => name}
- 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
File base.rb
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Nic
class Base < ApplicationRecord
audited associated_with: :host
prepend Foreman::STI
include Encryptable
File compute_resources_controller.rb
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Api
module V2
class ComputeResourcesController < V2::BaseController
include Api::Version2
include Foreman::Controller::Parameters::ComputeResource
Class ProvisioningTemplate
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class ProvisioningTemplate < Template
audited
has_many :audits, :as => :auditable, :class_name => Audited.audit_class.name
include Authorizable
Class EC2
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class EC2 < ComputeResource
GOV_CLOUD_REGION = 'us-gov-west-1'
include KeyPairComputeResource
delegate :flavors, :subnets, :to => :client
Method determine_os_type
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def determine_os_type(host)
return nil unless host
return host.params['ovirt_ostype'] if host.params['ovirt_ostype']
ret = "other_linux"
return ret unless host.operatingsystem
- 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 dhcp_attrs
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def dhcp_attrs(record_mac)
raise ::Foreman::Exception.new(N_("DHCP not supported for this NIC")) unless dhcp?
dhcp_attr = {
:name => dhcp_record_name(record_mac),
- 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_pxe_default
has a Cognitive Complexity of 20 (exceeds 5 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|
- 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_or_create_external_user
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.find_or_create_external_user(attrs, auth_source_name)
external_groups = attrs.delete(:groups)
auth_source = AuthSource.find_by_name(auth_source_name.to_s)
# existing user, we'll update them
- 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 register_rails
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def register_rails
if enabled?
ActiveSupport::Notifications.subscribe(/process_action.action_controller/) do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
controller = event.payload[:controller].underscore
- 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 icon
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def icon(record, opts = {})
return "" if record.blank? || record.name.blank?
size = opts[:size] ||= '16x16'
name = case record.name.downcase
when /fedora|fcos|coreos/i
File openstack.rb
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Foreman::Model
class Openstack < ComputeResource
include KeyPairComputeResource
attr_accessor :scheduler_hint_value
delegate :flavors, :to => :client