Showing 722 of 1,271 total issues
Consider simplifying this complex logical expression. Open
return true if ((old.ip != ip) ||
(old.hostname != hostname) ||
provision_mac_addresses_changed? ||
(old.subnet != subnet) ||
(old&.operatingsystem&.boot_filename(old.host) != operatingsystem&.boot_filename(host)) ||
Class AuthSourceLdap
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class AuthSourceLdap < AuthSource
SERVER_TYPES = { :free_ipa => 'FreeIPA', :active_directory => 'Active Directory',
:posix => 'POSIX', :netiq => "NetIQ"}
extend FriendlyId
Class UnattendedController
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class UnattendedController < ApplicationController
include ::Foreman::Controller::TemplateRendering
layout false
Class RhsmFactParser
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class RhsmFactParser < ::FactParser
def architecture
name = facts['lscpu.architecture'] || facts['uname.machine']
name = "x86_64" if name == "amd64"
name = "i386" if name == "i686"
Function update_interface_row
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function update_interface_row(row, interface_form) {
var has_errors = interface_form.find('.has-error').length > 0;
row.toggleClass('has-error', has_errors);
var virtual = interface_form.find('.virtual').is(':checked');
File EditorActions.js
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { debounce, toString } from 'lodash';
import { API } from '../../redux/API';
import { sprintf, translate as __ } from '../../common/I18n';
import {
File FiltersForm.js
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import {
Form,
Function parseDocs
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const parseDocs = cache => {
// Do nothing if the editor is not being used for templates
if (!cache) return;
// Custom basic snippets
/* eslint-disable */
Function attribute_hash
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function attribute_hash(attributes) {
var attrs = {};
for (i = 0; i < attributes.length; i++) {
var attr = $('*[id$=' + attributes[i] + ']');
if (attr.length > 0) {
- 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 initializeEditor
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export const initializeEditor = initializeData => dispatch => {
const {
template,
locked,
type,
- 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 queue_external_ipam_update
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def queue_external_ipam_update
return false if old.nil?
return unless (external_ipam?(subnet) || external_ipam?(subnet6) || external_ipam?(old.subnet) || external_ipam?(old.subnet6)) && errors.empty?
logger.debug "Updating IP reservation in external IPAM for #{self}"
queue.create(id: generate_external_ipam_task_id("create", subnet.network_type), name: _("Creating IPv4 in External IPAM for %s") % self, priority: 10, action: [self, :set_add_external_ip, {:ip => ip, :subnet => subnet}]) if (ipv4_added? || ipv4_changed?) && external_ipam?(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
Function Navigation
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const Navigation = ({
navigate,
items,
navigationActiveItem,
setNavigationActiveItem,
- 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_params
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def validate_params(mail_notification_id)
mail_notification = MailNotification.find(mail_notification_id)
raise ::Foreman::Exception.new(N_("Interval or subscription option is missing")) if params[:interval].nil? && params[:subscription].nil?
deny_access N_("You do not have permission to add a mail notification to another user") unless @user == User.current || User.current.admin?
raise ::Foreman::Exception.new(N_("Interval option is needed")) if mail_notification.subscription_type == 'report' && params[:interval].nil?
- 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_layout
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def build_layout(enable_colors = true)
pattern, colorize = @config[:pattern], @config[:colorize]
pattern = @config[:sys_pattern] if @config[:type] =~ /^(journald?|syslog)$/i
colorize = nil unless enable_colors
case @config[:layout]
- 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 17 (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 import_raw_template
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def import_raw_template(contents, vendor = 'Foreman')
metadata = Template.parse_metadata(contents)
raise "Attribute 'name' is required in metadata in order to seed the template" if metadata['name'].nil?
raise "Attribute 'model' is required in metadata in order to seed the template" if metadata['model'].nil?
- 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
Class SmartProxy
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class SmartProxy < ApplicationRecord
audited
include Authorizable
extend FriendlyId
friendly_id :name
Class TemplatesController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class TemplatesController < ApplicationController
include Foreman::Controller::ProvisioningTemplates
include Foreman::Controller::AutoCompleteSearch
include AuditsHelper
Class SmartProxiesController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class SmartProxiesController < ApplicationController
include Foreman::Controller::AutoCompleteSearch
include Foreman::Controller::Parameters::SmartProxy
before_action :find_resource, :only => [:show, :edit, :update, :refresh, :ping, :tftp_server, :destroy, :log_pane, :failed_modules, :errors_card, :modules_card, :expire_logs]
Class FactImporter
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class FactImporter
include Foreman::TelemetryHelper
delegate :logger, :to => :Rails
attr_reader :counters