Showing 712 of 1,256 total issues
File audits_helper.rb
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
module AuditsHelper
AUDIT_ADD = 'add'
AUDIT_REMOVE = 'remove'
# lookup the Model representing the numerical id and return its label
Method id_to_label
has a Cognitive Complexity of 32 (exceeds 5 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('/')
- 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 compute_resource.rb
has 360 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ComputeResource < ApplicationRecord
audited :except => [:attrs]
include Taxonomix
include Encryptable
include Authorizable
Method try_to_login
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def self.try_to_login(login, password, api_request = false)
# Make sure no one can sign in with an empty password
return nil if password.to_s.empty?
# user is already in local database
- 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 get
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
get: async url => {
if (url === '/api/v2/roles?per_page=all&search=locked=false') {
return {
data: {
total: 3,
Class PuppetFactParser
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class PuppetFactParser < FactParser
attr_reader :facts
def operatingsystem
orel = os_release.dup
File subnet.rb
has 353 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ipaddr'
class Subnet < ApplicationRecord
audited
IP_FIELDS = [:network, :mask, :gateway, :dns_primary, :dns_secondary, :from, :to]
File host_edit_interfaces.js
has 352 lines of code (exceeds 250 allowed). Consider refactoring. Open
$(document).ready(function() {
$('#host_name').select();
$('#host_name').focus();
});
Method set_taxonomy
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def set_taxonomy
TopbarSweeper.expire_cache
user = User.current
return if user.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 FactParser
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class FactParser
delegate :logger, :to => :Rails
VIRTUAL = /\A([a-z0-9]+)[_|\.|:]([a-z0-9]+)\Z/
BRIDGES = /\A(vir|lxc)?br(\d+|-[a-z0-9]+)(_nic)?\Z/
BONDS = /\A(bond\d+)\Z|\A(lagg\d+)\Z/
Method details
has a Cognitive Complexity of 28 (exceeds 5 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?
- 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 Filter
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Filter < ApplicationRecord
audited :associated_with => :role
include Taxonomix
include Authorizable
File application_controller.rb
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
include ApplicationShared
include Foreman::Controller::Flash
include Foreman::Controller::Authorize
File lookup_keys.js
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
//on load
$(document).on('ContentLoad', function() {
//select the first tab
select_first_tab();
$(document).on('click', '.nav-tabs a[data-toggle="tab"]', function() {
File application_helper.rb
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
module ApplicationHelper
def link_to_function(name, function, html_options = {})
onclick_tag = "#{html_options[:onclick]}; " if html_options[:onclick]
onclick = "#{onclick_tag}#{function}; return false;"
href = html_options[:href] || '#'
Method load
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load
Manager.map :header_menu
Manager.map :side_menu do |menu|
menu.sub_menu :user_menu, :caption => N_('User'), :icon => 'fa fa-user' do
Method setComputeDetails
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def setComputeDetails
if vm
attrs = compute_resource.provided_attributes
attrs.each do |foreman_attr, fog_attr|
- 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 index.js
has 322 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable max-lines */
import React, { createContext, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useSelector, useDispatch, shallowEqual } from 'react-redux';
import { Tr, Td, ActionsColumn } from '@patternfly/react-table';
Class Setting
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Setting < ApplicationRecord
audited :except => [:name]
extend FriendlyId
friendly_id :name
include ActiveModel::Validations
Class HostsController
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class HostsController < V2::BaseController
include Api::Version2
include Api::V2::BulkHostsExtension
include ScopesPerAction
include Foreman::Controller::SmartProxyAuth