theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Function render has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { time, toggleTimeTable } = this.props;
    const minutes = time.getMinutes();
    const hours = time.getHours() % 12 || 12;

    File index.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable camelcase */
    import PropTypes from 'prop-types';
    import React, { useEffect } from 'react';
    import { useSelector, shallowEqual } from 'react-redux';
    import { Link } from 'react-router-dom';
    Severity: Minor
    Found in webpack/assets/javascripts/react_app/components/HostDetails/index.js - About 2 hrs to fix

      Class Hostgroup has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Hostgroup < ApplicationRecord
        audited
        include Authorizable
        extend FriendlyId
        friendly_id :title
      Severity: Minor
      Found in app/models/hostgroup.rb - About 2 hrs to fix

        Class Taxonomy has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Taxonomy < ApplicationRecord
          validates_lengths_from_database
        
          include Authorizable
          include NestedAncestryCommon
        Severity: Minor
        Found in app/models/taxonomy.rb - About 2 hrs to fix

          Method create_vm has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_vm(args = {})
                boot_from_volume(args) if Foreman::Cast.to_bool(args[:boot_from_volume])
                network = args.delete(:network)
                # fix internal network format for fog.
                args[:nics].delete_if(&:blank?)
          Severity: Minor
          Found in app/models/compute_resources/foreman/model/openstack.rb - About 2 hrs to fix

          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 setup_search_options has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def setup_search_options
              @original_search_parameter = params[:search]
              params[:search] ||= ""
              params.each do |param, value|
                case param
          Severity: Minor
          Found in app/controllers/filters_controller.rb - About 2 hrs to fix

          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 update_multiple_parameters has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_multiple_parameters
              if params[:name].empty?
                warning _("No parameters were allocated to the selected hosts, can't mass assign")
                redirect_to hosts_path
                return
          Severity: Minor
          Found in app/controllers/hosts_controller.rb - About 2 hrs to fix

          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 operatingsystem has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def operatingsystem
              orel = os_release.dup
          
              if orel.present?
                if os_name =~ /ubuntu/i
          Severity: Minor
          Found in app/services/puppet_fact_parser.rb - About 2 hrs to fix

          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 render has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render() {
              const {
                locale,
                weekStartsOn,
                inputProps,

            File puppet_fact_parser.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class PuppetFactParser < FactParser
              attr_reader :facts
            
              def operatingsystem
                orel = os_release.dup
            Severity: Minor
            Found in app/services/puppet_fact_parser.rb - About 2 hrs to fix

              File role.rb has 268 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class Role < ApplicationRecord
                audited
                include Authorizable
                include ScopedSearchExtensions
                extend FriendlyId
              Severity: Minor
              Found in app/models/role.rb - About 2 hrs to fix

                Method select_f has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def select_f(f, attr, array, id, method, select_options = {}, html_options = {})
                    array = array.to_a.dup
                    disable_button = select_options.delete(:disable_button)
                    include_blank = select_options.delete(:include_blank)
                    disable_button_enabled = select_options.delete(:disable_button_enabled)
                Severity: Minor
                Found in app/helpers/form_helper.rb - About 2 hrs to fix

                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 field has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def field(f, attr, options = {}, &block)
                    table_field = options.delete(:table_field)
                    error       = options.delete(:error) || get_attr_error(f, attr)
                    help_inline = help_inline(options.delete(:help_inline), error)
                    help_inline += options[:help_inline_permanent] unless options[:help_inline_permanent].nil?
                Severity: Minor
                Found in app/helpers/form_helper.rb - About 2 hrs to fix

                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 freeip has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def freeip
                    unless (s = params[:subnet_id].to_i) > 0
                      invalid_request
                      return
                    end
                Severity: Minor
                Found in app/controllers/subnets_controller.rb - About 2 hrs to fix

                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 process_error has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def process_error(hash = {})
                    hash[:object] ||= instance_variable_get("@#{controller_name.singularize}")
                    if hash[:render].blank? && hash[:redirect].blank?
                      case action_name
                      when "create" then hash[:render] = "new"
                Severity: Minor
                Found in app/controllers/application_controller.rb - About 2 hrs to fix

                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 detect_matching_host has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def detect_matching_host(allowed_hosts, request_hosts)
                    allowed_hosts.product(request_hosts).each do |allowed, request|
                      if request.starts_with?('*')
                        # certificate wildcard name
                        rex = /\A#{Regexp.escape(request).sub('\\*', '.*')}\Z/
                Severity: Minor
                Found in app/controllers/concerns/foreman/controller/smart_proxy_auth.rb - About 2 hrs to fix

                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 libvirt.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module Foreman::Model
                  class Libvirt < ComputeResource
                    include ComputeResourceConsoleCommon
                
                    ALLOWED_DISPLAY_TYPES = %w(vnc spice)
                Severity: Minor
                Found in app/models/compute_resources/foreman/model/libvirt.rb - About 2 hrs to fix

                  File EditorNavbar.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React, { useState } from 'react';
                  import PropTypes from 'prop-types';
                  import { Nav, Spinner, Alert, Button } from 'patternfly-react';
                  import { translate as __ } from '../../../common/I18n';
                  import EditorRadioButton from './EditorRadioButton';

                    File SettingRecords.fixtures.js has 264 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    export const settings = [
                      {
                        description: 'The default administrator email address',
                        category: 'General',
                        settingsType: 'string',

                      Class SettingRegistry has 22 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class SettingRegistry
                        include Singleton
                        include Enumerable
                        extend ScopedSearch::ClassMethods
                      
                      
                      Severity: Minor
                      Found in app/registries/setting_registry.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language