theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Consider simplifying this complex logical expression.
Open

    return true if ((old.ip != ip) ||
      (old.hostname != hostname) ||
      provision_mac_addresses_changed? ||
      (old.subnet != subnet) ||
      (old&.operatingsystem&.boot_filename(old.host) != operatingsystem&.boot_filename(host)) ||
Severity: Critical
Found in app/models/concerns/orchestration/dhcp.rb - About 2 hrs to fix

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

    class AuthSourceLdap < AuthSource
      SERVER_TYPES = { :free_ipa => 'FreeIPA', :active_directory => 'Active Directory',
                       :posix    => 'POSIX', :netiq => "NetIQ"}
    
      extend FriendlyId
    Severity: Minor
    Found in app/models/auth_sources/auth_source_ldap.rb - About 2 hrs to fix

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

      class UnattendedController < ApplicationController
        include ::Foreman::Controller::TemplateRendering
      
        layout false
      
      
      Severity: Minor
      Found in app/controllers/unattended_controller.rb - About 2 hrs to fix

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

          class RhsmFactParser < ::FactParser
            def architecture
              name = facts['lscpu.architecture'] || facts['uname.machine']
              name = "x86_64" if name == "amd64"
              name = "i386" if name == "i686"
        Severity: Minor
        Found in app/services/katello/rhsm_fact_parser.rb - About 2 hrs to fix

          Function update_interface_row has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function update_interface_row(row, interface_form) {
            var has_errors = interface_form.find('.has-error').length > 0;
            row.toggleClass('has-error', has_errors);
          
            var virtual = interface_form.find('.virtual').is(':checked');
          Severity: Major
          Found in app/assets/javascripts/host_edit_interfaces.js - About 2 hrs to fix

            File EditorActions.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { debounce, toString } from 'lodash';
            import { API } from '../../redux/API';
            import { sprintf, translate as __ } from '../../common/I18n';
            
            import {

              File FiltersForm.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React, { useState } from 'react';
              import PropTypes from 'prop-types';
              import { useDispatch } from 'react-redux';
              import {
                Form,

                Function parseDocs has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const parseDocs = cache => {
                  // Do nothing if the editor is not being used for templates
                  if (!cache) return;
                  // Custom basic snippets
                  /* eslint-disable */

                  Function attribute_hash has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function attribute_hash(attributes) {
                    var attrs = {};
                    for (i = 0; i < attributes.length; i++) {
                      var attr = $('*[id$=' + attributes[i] + ']');
                      if (attr.length > 0) {
                  Severity: Minor
                  Found in app/assets/javascripts/application.js - 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 initializeEditor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const initializeEditor = initializeData => dispatch => {
                    const {
                      template,
                      locked,
                      type,

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

                    def queue_external_ipam_update
                      return false if old.nil?
                      return unless (external_ipam?(subnet) || external_ipam?(subnet6) || external_ipam?(old.subnet) || external_ipam?(old.subnet6)) && errors.empty?
                      logger.debug "Updating IP reservation in external IPAM for #{self}"
                      queue.create(id: generate_external_ipam_task_id("create", subnet.network_type), name: _("Creating IPv4 in External IPAM for %s") % self, priority: 10, action: [self, :set_add_external_ip, {:ip => ip, :subnet => subnet}]) if (ipv4_added? || ipv4_changed?) && external_ipam?(subnet)
                  Severity: Minor
                  Found in app/models/concerns/orchestration/external_ipam.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 Navigation has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const Navigation = ({
                    navigate,
                    items,
                    navigationActiveItem,
                    setNavigationActiveItem,
                  Severity: Minor
                  Found in webpack/assets/javascripts/react_app/components/Layout/Navigation.js - 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 validate_params has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def validate_params(mail_notification_id)
                          mail_notification = MailNotification.find(mail_notification_id)
                          raise ::Foreman::Exception.new(N_("Interval or subscription option is missing")) if params[:interval].nil? && params[:subscription].nil?
                          deny_access N_("You do not have permission to add a mail notification to another user") unless @user == User.current || User.current.admin?
                          raise ::Foreman::Exception.new(N_("Interval option is needed")) if mail_notification.subscription_type == 'report' && params[:interval].nil?
                  Severity: Minor
                  Found in app/controllers/api/v2/mail_notifications_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 build_layout has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def build_layout(enable_colors = true)
                        pattern, colorize = @config[:pattern], @config[:colorize]
                        pattern = @config[:sys_pattern] if @config[:type] =~ /^(journald?|syslog)$/i
                        colorize = nil unless enable_colors
                        case @config[:layout]
                  Severity: Minor
                  Found in lib/foreman/logging.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 set_additional_attributes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def set_additional_attributes(attributes, name)
                      if name =~ VIRTUAL_NAMES
                        attributes[:virtual] = true
                        if Regexp.last_match(1).nil? && name =~ BRIDGES
                          attributes[:bridge] = true
                  Severity: Minor
                  Found in app/services/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

                  Method import_raw_template has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def import_raw_template(contents, vendor = 'Foreman')
                        metadata = Template.parse_metadata(contents)
                        raise "Attribute 'name' is required in metadata in order to seed the template" if metadata['name'].nil?
                        raise "Attribute 'model' is required in metadata in order to seed the template" if metadata['model'].nil?
                  
                  
                  Severity: Minor
                  Found in lib/seed_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

                  Class SmartProxy has 21 methods (exceeds 20 allowed). Consider refactoring.
                  Open

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

                    Class TemplatesController has 21 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class TemplatesController < ApplicationController
                      include Foreman::Controller::ProvisioningTemplates
                      include Foreman::Controller::AutoCompleteSearch
                      include AuditsHelper
                    
                    
                    Severity: Minor
                    Found in app/controllers/templates_controller.rb - About 2 hrs to fix

                      Class SmartProxiesController has 21 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class SmartProxiesController < ApplicationController
                        include Foreman::Controller::AutoCompleteSearch
                        include Foreman::Controller::Parameters::SmartProxy
                      
                        before_action :find_resource, :only => [:show, :edit, :update, :refresh, :ping, :tftp_server, :destroy, :log_pane, :failed_modules, :errors_card, :modules_card, :expire_logs]
                      Severity: Minor
                      Found in app/controllers/smart_proxies_controller.rb - About 2 hrs to fix

                        Class FactImporter has 21 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class FactImporter
                          include Foreman::TelemetryHelper
                        
                          delegate :logger, :to => :Rails
                          attr_reader :counters
                        Severity: Minor
                        Found in app/services/fact_importer.rb - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language