theforeman/foreman

View on GitHub

Showing 719 of 1,266 total issues

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
Severity: Minor
Found in app/models/setting.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in app/controllers/api/v2/hosts_controller.rb - About 3 hrs to fix

      File compute.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'socket'
      require 'timeout'
      
      module Orchestration::Compute
        extend ActiveSupport::Concern
      Severity: Minor
      Found in app/models/concerns/orchestration/compute.rb - About 3 hrs to fix

        Function ColumnSelector has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        const ColumnSelector = props => {
          const {
            data: { url, controller, categories, hasPreference },
          } = props;
        
        

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

        export const useBulkSelect = ({
          results,
          metadata,
          initialArry = [],
          initialExclusionArry = [],

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

              def search_by_os_minor(key, operator, value)
                y, z = value.split(".")
                z ||= 0
                operatingsystem_ids = []
                Operatingsystem.where.not(minor: [nil, '']).find_each do |os|
        Severity: Minor
        Found in app/models/concerns/hostext/search.rb - About 3 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 method_missing has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.method_missing(method, *args, **kwargs, &block)
            type = "Host::Managed"
            case method.to_s
            when /create/, 'new'
              # in this case args should contain a hash with host attributes
        Severity: Minor
        Found in app/models/host.rb - About 3 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 details has a Cognitive Complexity of 24 (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?
        Severity: Minor
        Found in app/helpers/audits_helper.rb - About 3 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 PersonalAccessTokenModal.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable max-lines */
        import React, { useState } from 'react';
        import { useDispatch, useSelector } from 'react-redux';
        import {
          DatePicker,

          fixtures has 28 functions (exceeds 20 allowed). Consider refactoring.
          Open

          const fixtures = {
            'should return editor': () => selectEditor(state),
            'should return selected host': () => selectChosenHost(state),
            'should return selectPreviewResult': () => selectPreviewResult(state),
            'should return selectErrorText': () => selectErrorText(state),

            Class LookupKey has 28 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class LookupKey < ApplicationRecord
              audited :associated_with => :audit_class
              include Authorizable
              include HiddenValue
              include Classification
            Severity: Minor
            Found in app/models/lookup_keys/lookup_key.rb - About 3 hrs to fix

              Class ComputeResourcesController has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class ComputeResourcesController < V2::BaseController
                    include Api::Version2
                    include Foreman::Controller::Parameters::ComputeResource
              
                    wrap_parameters ComputeResource, :include => compute_resource_params_filter.accessible_attributes(parameter_filter_context)
              Severity: Minor
              Found in app/controllers/api/v2/compute_resources_controller.rb - About 3 hrs to fix

                Function ErrorsTree has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const ErrorsTree = props => {
                  const [expandedNodeNames, setExpandedNodeNames] = React.useState([]);
                  const [
                    expandedDetailsNodeNames,
                    setExpandedDetailsNodeNames,

                  Method nested_attribute_for has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def nested_attribute_for(*fields)
                        @nested_attribute_fields = fields
                        @nested_attribute_fields.each do |field|
                          # Example method
                          # def inherited_compute_profile_id
                  Severity: Minor
                  Found in app/models/concerns/nested_ancestry_common.rb - About 3 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 TableIndexPage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const TableIndexPage = ({
                    apiOptions,
                    apiUrl,
                    beforeToolbarComponent,
                    breadcrumbOptions,

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

                      def sanitize_inherited_vm_attributes(args, template, instance_type)
                        # Override memory an cores values if template and/or instance type is/are provided.
                        # Take template values if blank values for VM attributes, because oVirt will fail if empty values are present in VM definition
                        # Instance type values always take precedence on templates or vm provided values
                        if template
                  Severity: Minor
                  Found in app/models/compute_resources/foreman/model/ovirt.rb - About 3 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 base_host_overview_fields has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def base_host_overview_fields(host)
                      fields = []
                      fields << { :field => [_("Build duration"), build_duration(host)], :priority => 90 }
                      fields << { :field => [_("Build errors"), link_to("Logs from OS installer", build_errors_host_path(:id => host.id))], :priority => 91 } if host.build_errors.present?
                      fields << { :field => [_("Token"), host.token || _("N/A")], :priority => 92 } if User.current.admin
                  Severity: Minor
                  Found in app/helpers/host_description_helper.rb - About 3 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 interfaces has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def interfaces
                        interfaces = {}
                  
                        facts.each do |fact, value|
                          next unless value && fact.to_s =~ /^ip_interfaces/
                  Severity: Minor
                  Found in app/services/foreman_salt/fact_parser.rb - About 3 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 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    render() {
                      const {
                        breadcrumbItems,
                        isSwitchable,
                        resource,

                    Method process has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def process(queue_name)
                        processed = 0
                        return true if skip_orchestration?
                    
                        # queue is empty - nothing to do.
                    Severity: Minor
                    Found in app/models/concerns/orchestration.rb - About 3 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

                    Severity
                    Category
                    Status
                    Source
                    Language