theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

Function generateExports has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateExports(directoryPath, exportFileContent = '') {
  fs.readdirSync(directoryPath, { withFileTypes: true }).forEach(dirent => {
    if (
      dirent.isDirectory() &&
      dirent.name !== '__mocks__' &&
Severity: Minor
Found in webpack/assets/javascripts/exportAll.js - About 1 hr to fix

    Function ForemanModal has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ForemanModal = props => {
      const {
        id,
        title,
        onClose,

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

        render() {
          const { locale } = this.props;
          const popover = (
            <div
              className="row bootstrap-datetimepicker-widget timepicker-sbs"

        Method builtin_widgets has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def builtin_widgets
                [
                  (registered_report_orgins + ['All']).sort.flat_map do |origin|
                    [
                      {
        Severity: Minor
        Found in app/services/dashboard/manager.rb - About 1 hr to fix

          Method process has 40 lines of code (exceeds 25 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 1 hr to fix

            Method find_collection has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def find_collection(resource_class, options = {})
                permission = options.delete :permission
                resource_class = Host if resource_class == Host::Base
            
                Foreman::Logging.logger('permissions').debug "checking permission #{permission} for class #{resource_class}"
            Severity: Minor
            Found in app/services/authorizer.rb - About 1 hr to fix

              Function HostDetails has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              const HostDetails = ({
                match: {
                  params: { id },
                },
                location: { hash },

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

                def find_address(type)
                  vm_addresses = filter_ip_addresses(vm.ip_addresses, type)
              
                  # We can exit early if the host already has any kind of ip and the vm does not
                  # provide one for this kind to speed up things
              Severity: Minor
              Found in app/models/concerns/orchestration/compute.rb - About 1 hr 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 create_volumes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def create_volumes(args)
                    args[:volumes].each { |vol| validate_volume_capacity(vol) }
              
                    # if using image creation, the first volume needs a backing disk set
                    if args[:backing_id].present?
              Severity: Minor
              Found in app/models/compute_resources/foreman/model/libvirt.rb - About 1 hr 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 lookup_values_attributes= has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def lookup_values_attributes=(lookup_values_attributes)
                    lookup_values_attributes.each do |_, attribute|
                      attr = attribute.dup
              
                      id = attr.delete(:id)
              Severity: Minor
              Found in app/models/concerns/host_common.rb - About 1 hr 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 default_image_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def default_image_file
                  return "" unless operatingsystem&.supports_image
                  if medium
                    nfs_path = medium.try :image_path
                    if operatingsystem.try(:media) && operatingsystem.media.size == 1
              Severity: Minor
              Found in app/models/concerns/host_common.rb - About 1 hr 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 boot_filename has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def boot_filename(host = nil)
                  return default_boot_filename if host.nil? || host.pxe_loader.nil?
                  return host.foreman_url('iPXE') if host.pxe_loader == 'iPXE Embedded'
                  architecture = host.arch.nil? ? '' : host.arch.bootfilename_efi
                  if host.subnet&.httpboot? && host.pxe_loader =~ /UEFI HTTP/
              Severity: Minor
              Found in app/models/operatingsystem.rb - About 1 hr 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 prop has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def prop(method, title = nil)
                  content_tag :tr do
                    result = content_tag(:td) do
                      title || method.to_s.humanize
                    end
              Severity: Minor
              Found in app/helpers/compute_resources_vms_helper.rb - About 1 hr 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 template_changes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def template_changes
                  actual_changes = changes
              
                  # Locked & Default are Special
                  if actual_changes.include?('locked') && !modify_locked
              Severity: Minor
              Found in app/models/template.rb - About 1 hr 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 clone_vm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def clone_vm(raw_args)
                    args = parse_args(raw_args)
              
                    opts = {
                      "datacenter" => datacenter,
              Severity: Minor
              Found in app/models/compute_resources/foreman/model/vmware.rb - About 1 hr 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 sso_authentication has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def sso_authentication
                  if available_sso.present?
                    if available_sso.authenticated?
                      user = available_sso.current_user
                      update_activity_time unless api_request?
              Severity: Minor
              Found in app/controllers/concerns/foreman/controller/authentication.rb - About 1 hr 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 setBuild has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def setBuild
                  forward_url_options
                  if @host.setBuild
                    if (params[:host] && params[:host][:build] == '1')
                      begin
              Severity: Minor
              Found in app/controllers/hosts_controller.rb - About 1 hr 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 action_buttons has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def action_buttons(*args)
                  # the no-buttons code is needed for users with less permissions
                  args = args.flatten.select(&:present?)
                  return if args.blank?
              
              
              Severity: Minor
              Found in app/helpers/application_helper.rb - About 1 hr 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 audit_title has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def audit_title(audit)
                  type_name = audited_type audit
                  case type_name
                    when 'Puppet Class'
                      (id_to_label audit.audited_changes.keys[0], audit.audited_changes.values[0], audit: audit).to_s
              Severity: Minor
              Found in app/helpers/audits_helper.rb - About 1 hr 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 authenticate! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def authenticate!
                    unless Setting['oauth_active']
                      Rails.logger.warn 'Trying to authenticate with OAuth, but OAuth is not active'
                      return nil
                    end
              Severity: Minor
              Found in app/services/sso/oauth.rb - About 1 hr 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