theforeman/foreman

View on GitHub

Showing 713 of 1,254 total issues

Class TemplateSnapshotService has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class TemplateSnapshotService
    TEMPLATES_DIRECTORY = Rails.root.join('app', 'views', 'unattended', 'provisioning_templates')

    def self.templates
      new.templates
Severity: Minor
Found in app/services/foreman/template_snapshot_service.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

      File TableIndexPage.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /* eslint-disable max-lines */
      import React, { useMemo } from 'react';
      import PropTypes from 'prop-types';
      import { QuestionCircleIcon } from '@patternfly/react-icons';
      import { useHistory } from 'react-router-dom';

        File operatingsystem.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'ostruct'
        require 'uri'
        
        class Operatingsystem < ApplicationRecord
          audited
        Severity: Minor
        Found in app/models/operatingsystem.rb - About 3 hrs to fix

          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

          Function useBulkSelect has a Cognitive Complexity of 24 (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 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

          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,

            File index.js has 308 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 {

              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

                    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

                    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 process has a Cognitive Complexity of 23 (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

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

                            def setup_roles!
                              return false if Foreman.in_setup_db_rake? || !permission_table_exists? || User.unscoped.find_by_login(User::ANONYMOUS_ADMIN).nil?
                              Role.without_auditing do
                                Filter.without_auditing do
                                  default_roles.each do |name, permissions|
                      Severity: Minor
                      Found in app/registries/foreman/plugin/rbac_registry.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