Showing 719 of 1,266 total issues
Class PuppetFactParser
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class PuppetFactParser < FactParser
attr_reader :facts
def operatingsystem
orel = os_release.dup
File audits_helper.rb
has 367 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
File Layout.fixtures.js
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
const mockOnClick = jest.fn();
const subItemsA = [
{
title: 'Aa',
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 form_helper.rb
has 361 lines of code (exceeds 250 allowed). Consider refactoring. Open
module FormHelper
def text_f(f, attr, options = {})
field(f, attr, options) do
addClass options, "form-control"
options[:focus_on_load] = true if options[:focus_on_load].nil? && attr.to_s == 'name'
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,
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 351 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/
Class Filter
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class Filter < ApplicationRecord
audited :associated_with => :role
include Taxonomix
include Authorizable
Class TemplateSnapshotService
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class TemplateSnapshotService
TEMPLATES_DIRECTORY = Rails.root.join('app', 'views', 'unattended', 'provisioning_templates')
def self.templates
new.templates
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_controller.rb
has 330 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
include ApplicationShared
include Foreman::Controller::Flash
include Foreman::Controller::Authorize
File application_helper.rb
has 329 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] || '#'
File index.js
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable max-lines */
import React, { useState, useEffect, useCallback } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import {
File operatingsystem.rb
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ostruct'
require 'uri'
class Operatingsystem < ApplicationRecord
audited
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"