theforeman/foreman

View on GitHub

Showing 722 of 1,271 total issues

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

class AnsibleFactParser < FactParser
  include ForemanAnsible::OperatingSystemParser
  attr_reader :facts

  def initialize(facts)
Severity: Minor
Found in app/services/ansible_fact_parser.rb - About 2 hrs to fix

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

      class LoggingImpl
        private_class_method :new
    
        attr_reader :config, :log_directory
    
    
    Severity: Minor
    Found in lib/foreman/logging.rb - About 2 hrs to fix

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

        render() {
          const {
            name,
            label,
            className,

        Function EmptyStatePattern has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const EmptyStatePattern = props => {
          const {
            documentation,
            action,
            secondaryActions,

          File compute_resources_vms_helper.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module ComputeResourcesVmsHelper
            def vm_power_actions(host, vm)
              button_group(
                if vm
                  html_opts = vm.ready? ? {:data => {:confirm => _('Are you sure?')}, :class => "btn btn-danger"} : {:class => "btn btn-success"}
          Severity: Minor
          Found in app/helpers/compute_resources_vms_helper.rb - About 2 hrs to fix

            Function filter_by_level has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function filter_by_level(item) {
              var level = $(item).val();
            
              // Note that class names don't map to log level names (label-info == notice)
              if (level == 'info') {
            Severity: Major
            Found in app/assets/javascripts/application.js - About 2 hrs to fix

              Function EditParametersTableRow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              export const EditParametersTableRow = ({
                param,
                rowIndex,
                setEditingRow,
                hostId,

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

              function update_provisioning_image() {
                var compute_id = $('[name$="[compute_resource_id]"]').val();
                var arch_id = $('[name$="[architecture_id]"]').val();
                var os_id = $('[name$="[operatingsystem_id]"]').val();
                if (
              Severity: Minor
              Found in app/assets/javascripts/host_edit.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 IntervalMiddleware has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

              export const IntervalMiddleware = store => next => action => {
                const { type, key, interval, payload = {} } = action;
                const intervalKey = key || payload.key;
              
                if (interval) {

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

                def dns_conflict_detected?
                  return false if ip.blank? || hostname.blank?
                  # can't validate anything if dont have an ip-address yet
                  return false unless require_ip4_validation? || require_ip6_validation?
                  # we should only alert on conflicts if overwrite mode is off
              Severity: Minor
              Found in app/models/concerns/orchestration/dns.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 parse_string_value has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse_string_value(val)
                  case settings_type
                  when "boolean"
                    boolean = Foreman::Cast.to_bool(val)
              
              
              Severity: Minor
              Found in app/models/setting.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 setup_search_options has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                def setup_search_options
                  @original_search_parameter = params[:search]
                  params[:search] ||= ""
                  params.each do |param, value|
                    if param =~ /(\w+)_id$/
              Severity: Minor
              Found in app/controllers/application_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 login has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                def login
                  User.current = nil
              
                  if bruteforce_attempt?
                    inline_error _("Too many tries, please try again in a few minutes.")
              Severity: Minor
              Found in app/controllers/users_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 subject_alternative_names has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                def subject_alternative_names
                  @subject_alternative_names || begin
                    @subject_alternative_names = []
                    if subject_alt_name_extension
                      _id, ostr = OpenSSL::ASN1.decode(subject_alt_name_extension).value
              Severity: Minor
              Found in app/services/certificate_extract.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 load_resource has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                        def load_resource(klass:, search:, permission:, batch: 1_000, includes: nil, limit: nil, select: nil, joins: nil, where: nil, preload: nil)
                          limit ||= 10 if preview?
              
                          base = klass
                          base = base.search_for(search)
              Severity: Minor
              Found in app/services/foreman/renderer/scope/macros/loaders.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 normalize_vm_attrs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def normalize_vm_attrs(vm_attrs)
                    normalized = slice_vm_attributes(vm_attrs, ['cpus', 'firmware', 'guest_id', 'annotation', 'resource_pool_id', 'image_id'])
              
                    normalized['cores_per_socket'] = vm_attrs['corespersocket']
                    normalized['memory'] = vm_attrs['memory_mb'].nil? ? nil : (vm_attrs['memory_mb'].to_i * 1024)
              Severity: Major
              Found in app/models/compute_resources/foreman/model/vmware.rb - About 2 hrs to fix

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

                import React from 'react';
                import {
                  render,
                  fireEvent,
                  screen,

                  Consider simplifying this complex logical expression.
                  Open

                              if (sub.isDivider) {
                                groups.push({ title: sub.title, groupItems: [] });
                                currIndex++;
                              } else {
                                const isCurrentLocation =
                  Severity: Critical
                  Found in webpack/assets/javascripts/react_app/components/Layout/Navigation.js - About 2 hrs to fix

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

                      render() {
                        const { history, children, fallback } = this.props;
                        const { hasError, error, info } = this.state;
                    
                        if (!hasError) return children;

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

                        render() {
                          const { locale, weekStartsOn, name, id, placement, required } = this.props;
                          const { value, hiddenValue } = this.state;
                          const popover = (
                            <div className="row bootstrap-datetimepicker-widget" id={id}>
                        Severity
                        Category
                        Status
                        Source
                        Language