theforeman/foreman_maintain

View on GitHub

Showing 66 of 98 total issues

Method run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
      if feature(:instance).postgresql_local? && backup.online_backup?
        errors = []
        [:candlepin_dump, :foreman_dump, :pulpcore_dump].each do |dump|
Severity: Minor
Found in definitions/checks/restore/validate_postgresql_dump_permissions.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 compose has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def compose
      backup = ForemanMaintain::Utils::Backup.new(context.get(:backup_dir))

      add_steps(find_checks(:root_user))
      add_steps_with_context(Checks::Restore::ValidateBackup,
Severity: Minor
Found in definitions/scenarios/restore.rb - About 1 hr to fix

    Method compose has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def compose
          add_steps(
            Checks::Foreman::FactsNames, # if Foreman database present
            Checks::ForemanProxy::CheckTftpStorage, # if Satellite with foreman-proxy+tftp
            Checks::ForemanProxy::VerifyDhcpConfigSyntax, # if foreman-proxy+dhcp-isc
    Severity: Minor
    Found in definitions/scenarios/update.rb - About 1 hr to fix

      Method compose has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def compose
            add_steps(
              Checks::Foreman::FactsNames, # if Foreman database present
              Checks::ForemanProxy::CheckTftpStorage, # if Satellite with foreman-proxy+tftp
              Checks::ForemanProxy::VerifyDhcpConfigSyntax, # if foreman-proxy+dhcp-isc
      Severity: Minor
      Found in definitions/scenarios/foreman_upgrade.rb - About 1 hr to fix

        Method include_unregistered_services has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def include_unregistered_services(service_list, services_filter)
            return service_list unless services_filter
            return service_list unless services_filter.any?
        
            services_filter = services_filter.reject do |obj|
        Severity: Minor
        Found in definitions/features/service.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 setup_protector has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def setup_protector(enabled)
              config = protector_config
              config += "\n" unless config[-1] == "\n"
              enabled_re = /^\s*enabled\s*=.*$/
              if enabled_re.match(config)
        Severity: Minor
        Found in lib/foreman_maintain/package_manager/dnf.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 run_action_on_services has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def run_action_on_services(action, options, spinner)
            status = 0
            failed_services = []
            filtered_services(options, action).each_value do |group|
              fork_threads_for_services(action, group, spinner).each do |service, status_and_output|
        Severity: Minor
        Found in definitions/features/service.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 status_for_maintenance_mode has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def status_for_maintenance_mode(mode_on)
            default_storage = ForemanMaintain.storage(:default)
            load_from_storage(default_storage)
            return ['sync plans: empty data', []] if both_empty?
        
        
        Severity: Minor
        Found in definitions/features/sync_plans.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 find_http_error_msg has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def find_http_error_msg(array_output, curl_http_status)
            if curl_http_status == 0
              'No valid HTTP response (Connection failed)'
            else
              http_line = ''
        Severity: Minor
        Found in definitions/features/foreman_proxy.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 katello_ping has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def katello_ping
            res = server_connection.get('/katello/api/ping')
            logger.debug('Called /katello/api/ping')
            logger.debug("Response: #{res.code}, #{res.body}")
            response = JSON.parse(res.body)
        Severity: Minor
        Found in definitions/features/instance.rb - About 55 mins 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 ask_about_offered_steps has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def ask_about_offered_steps(step, scenario)
              if step.next_steps && !step.next_steps.empty?
                @last_decision_step = step
                @procedure_step_counter += 1
                steps = step.next_steps.map(&:ensure_instance)
        Severity: Minor
        Found in lib/foreman_maintain/runner.rb - About 55 mins 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 add_feature_by_label has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_feature_by_label(feature_label, feature, allow_duplicities)
              if @features_by_label.key?(feature_label)
                if allow_duplicities
                  unless @features_by_label[feature_label].is_a? Array
                    @features_by_label[feature_label] = Array(@features_by_label[feature_label])
        Severity: Minor
        Found in lib/foreman_maintain/detector.rb - About 55 mins 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 run_scenario has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def run_scenario(scenario)
              return if scenario.steps.empty?
              raise 'The runner is already in quit state' if quit? && !rescue?
        
              confirm_scenario(scenario)
        Severity: Minor
        Found in lib/foreman_maintain/runner.rb - About 55 mins 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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def run
              assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
              package_manager.clean_cache(:assumeyes => assumeyes_val) if @clean_cache
              opts = {
                :assumeyes => assumeyes_val,
        Severity: Minor
        Found in definitions/procedures/packages/update.rb - About 55 mins 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 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def process(value)
              # default values imply we can not pass nil if there is non-nil default
              value = @default if value.nil?
              value = process_array(value) if array?
              value = @block.call(value) if @block
        Severity: Minor
        Found in lib/foreman_maintain/param.rb - About 55 mins 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 compose has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def compose
              backup = ForemanMaintain::Utils::Backup.new(context.get(:backup_dir))
        
              add_steps(find_checks(:root_user))
              add_steps_with_context(Checks::Restore::ValidateBackup,
        Severity: Minor
        Found in definitions/scenarios/restore.rb - About 55 mins 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 installed_packages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def installed_packages
            packages = []
            IO.popen(['dnf', 'repoquery', '-a', '--installed', '--qf', query_format]) do |io|
              io.each do |line|
                repo, pkg = line.chomp.split
        Severity: Minor
        Found in definitions/checks/check_hotfix_installed.rb - About 45 mins 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 __run__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __run__(execution)
              setup_execution_state(execution)
              unless skipped?
                if defined?(self.class.present?)
                  run if self.class.present?
        Severity: Minor
        Found in lib/foreman_maintain/executable.rb - About 45 mins 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 traverse_tree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def traverse_tree(dict, path)
                  return [dict, []] if path.nil? || path.empty?
                  if dict.key?(path.first)
                    if path.first.start_with?('-')
                      parse_option(dict, path)
        Severity: Minor
        Found in lib/foreman_maintain/utils/bash.rb - About 45 mins 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 option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.option(switches, type, description, opts = {}, &block)
                multivalued = opts.delete(:multivalued)
                completion_type = opts.delete(:completion)
                completion_type = { :type => :flag } if completion_type.nil? && type == :flag
                completion_type ||= { :type => :value }
        Severity: Minor
        Found in lib/foreman_maintain/cli/base.rb - About 45 mins 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