theforeman/foreman

View on GitHub

Showing 712 of 1,256 total issues

Class Subnet has 50 methods (exceeds 20 allowed). Consider refactoring.
Open

class Subnet < ApplicationRecord
  audited
  IP_FIELDS = [:network, :mask, :gateway, :dns_primary, :dns_secondary, :from, :to]
  REQUIRED_IP_FIELDS = [:network, :mask]
  SUBNET_TYPES = {:'Subnet::Ipv4' => N_('IPv4'), :'Subnet::Ipv6' => N_('IPv6')}
Severity: Minor
Found in app/models/subnet.rb - About 7 hrs to fix

    Class Operatingsystem has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Operatingsystem < ApplicationRecord
      audited
      include Authorizable
      include ValidateOsFamily
      include PxeLoaderSupport
    Severity: Minor
    Found in app/models/operatingsystem.rb - About 6 hrs to fix

      File application.js has 451 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      //= require bootstrap
      //= require patternfly
      //= require jquery.extentions
      //= require jquery.multi-select
      //= require hidden_values
      Severity: Minor
      Found in app/assets/javascripts/application.js - About 6 hrs to fix

        Function ColumnSelector has 170 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          File base.rb has 423 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Foreman
            module Renderer
              module Scope
                module Macros
                  module Base
          Severity: Minor
          Found in app/services/foreman/renderer/scope/macros/base.rb - About 6 hrs to fix

            Class Openstack has 44 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Openstack < ComputeResource
                include KeyPairComputeResource
                attr_accessor :scheduler_hint_value
                delegate :flavors, :to => :client
                delegate :security_groups, :to => :client
            Severity: Minor
            Found in app/models/compute_resources/foreman/model/openstack.rb - About 6 hrs to fix

              Class Base has 44 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Base < ApplicationRecord
                  audited associated_with: :host
                  prepend Foreman::STI
                  include Encryptable
                  encrypts :password
              Severity: Minor
              Found in app/models/nic/base.rb - About 6 hrs to fix

                File basic_ruby_methods.rb has 413 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module Foreman
                  module Renderer
                    module DocTemplates
                      module BasicRubyMethods
                        module Object
                Severity: Minor
                Found in app/services/foreman/renderer/doc_templates/basic_ruby_methods.rb - About 5 hrs to fix

                  Class Template has 43 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Template < ApplicationRecord
                    include Exportable
                    attr_accessor :modify_locked, :modify_default
                  
                    has_many :template_inputs, :dependent => :destroy, :foreign_key => 'template_id', :autosave => true
                  Severity: Minor
                  Found in app/models/template.rb - About 5 hrs to fix

                    Function PersonalAccessTokenModal has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const PersonalAccessTokenModal = ({ controller, url }) => {
                      const dispatch = useDispatch();
                      const [isModalOpen, setIsModalOpen] = useState(false);
                      const [endsNever, setEndsNever] = useState(true);
                      const [isDateTimeDisabled, setIsDateTimeDisabled] = useState(true);

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

                    require_dependency 'foreman/plugin/logging'
                    require_dependency 'foreman/plugin/report_scanner_registry'
                    require_dependency 'foreman/plugin/report_origin_registry'
                    require_dependency 'foreman/plugin/medium_providers_registry'
                    require_dependency 'foreman/plugin/fact_importer_registry'
                    Severity: Minor
                    Found in app/registries/foreman/plugin.rb - About 5 hrs to fix

                      File hosts_controller.rb has 405 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module Api
                        module V2
                          class HostsController < V2::BaseController
                            include Api::Version2
                            include Api::V2::BulkHostsExtension
                      Severity: Minor
                      Found in app/controllers/api/v2/hosts_controller.rb - About 5 hrs to fix

                        File hosts_helper.rb has 389 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module HostsHelper
                          include OperatingsystemsHelper
                          include HostsAndHostgroupsHelper
                          include ComputeResourcesVmsHelper
                          include HostsNicHelper
                        Severity: Minor
                        Found in app/helpers/hosts_helper.rb - About 5 hrs to fix

                          Class ApplicationController has 40 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class ApplicationController < ActionController::Base
                            include ApplicationShared
                          
                            include Foreman::Controller::Flash
                            include Foreman::Controller::Authorize
                          Severity: Minor
                          Found in app/controllers/application_controller.rb - About 5 hrs to fix

                            File model_attributes.rb has 387 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            _('Architecture')
                            # TRANSLATORS: "Table name" or "Table name|Column name" for error messages
                            _('Architecture|Name')
                            # TRANSLATORS: "Table name" or "Table name|Column name" for error messages
                            _('Audit')
                            Severity: Minor
                            Found in locale/model_attributes.rb - About 5 hrs to fix

                              Class Libvirt has 38 methods (exceeds 20 allowed). Consider refactoring.
                              Open

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

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

                                  render() {
                                    const {
                                      changeDiffViewType,
                                      changeSetting,
                                      changeTab,

                                  Class Role has 37 methods (exceeds 20 allowed). Consider refactoring.
                                  Open

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

                                    File form_helper.rb has 366 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'
                                    Severity: Minor
                                    Found in app/helpers/form_helper.rb - About 4 hrs to fix

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

                                      const mockOnClick = jest.fn();
                                      
                                      const subItemsA = [
                                        {
                                          title: 'Aa',
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language