theforeman/foreman_maintain

View on GitHub

Showing 98 of 98 total issues

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Invalid
    class CheckPendingState < ForemanMaintain::Check
      metadata do
        label :check_foreman_tasks_in_pending_state
        for_feature :foreman_tasks
Severity: Minor
Found in definitions/checks/foreman_tasks/invalid/check_pending_state.rb and 1 other location - About 45 mins to fix
definitions/checks/foreman_tasks/invalid/check_planning_state.rb on lines 2..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 41.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  module Invalid
    class CheckPlanningState < ForemanMaintain::Check
      metadata do
        label :check_foreman_tasks_in_planning_state
        for_feature :foreman_tasks
definitions/checks/foreman_tasks/invalid/check_pending_state.rb on lines 2..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 41.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  class ServiceStart < ForemanMaintain::Scenario
    metadata do
      description 'Start Services'
      tags :service_start
      label :service_start
Severity: Major
Found in definitions/scenarios/services.rb and 3 other locations - About 45 mins to fix
definitions/scenarios/services.rb on lines 27..45
definitions/scenarios/services.rb on lines 92..110
definitions/scenarios/services.rb on lines 114..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  class ServiceDisable < ForemanMaintain::Scenario
    metadata do
      description 'Disable Services'
      tags :service_disable
      label :service_disable
Severity: Major
Found in definitions/scenarios/services.rb and 3 other locations - About 45 mins to fix
definitions/scenarios/services.rb on lines 27..45
definitions/scenarios/services.rb on lines 49..67
definitions/scenarios/services.rb on lines 92..110

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

Function sack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def sack(self):
        if self.cli is not None and self.cli.command._basecmd not in PROTECT_COMMANDS:
            return
        if os.environ.get('LEAPP_IPU_IN_PROGRESS') is not None:
            return
Severity: Minor
Found in extras/foreman_protector/dnf/foreman-protector.py - 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 status_for_maintenance_mode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def status_for_maintenance_mode(mode_on)
    cron_service = system_service(service_name)
    if cron_service.running?
      [
        'cron jobs: running',
Severity: Minor
Found in definitions/features/cron.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 compose has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def compose
        if Packages.skip_installer_run?(context.get(:packages))
          add_step_with_context(Procedures::Packages::Update,
            :force => true, :warn_on_errors => true)
        else
Severity: Minor
Found in definitions/scenarios/packages.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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  class ServiceEnable < ForemanMaintain::Scenario
    metadata do
      description 'Enable Services'
      tags :service_enable
      label :service_enable
Severity: Major
Found in definitions/scenarios/services.rb and 3 other locations - About 45 mins to fix
definitions/scenarios/services.rb on lines 27..45
definitions/scenarios/services.rb on lines 49..67
definitions/scenarios/services.rb on lines 114..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method interactive_option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.interactive_option(opts = %w[assumeyes whitelist force plaintext])
        delete_duplicate_assumeyes_if_any

        if opts.include?('assumeyes')
          option ['-y', '--assumeyes'], :flag,
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

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  class ServiceStop < ForemanMaintain::Scenario
    metadata do
      description 'Stop Services'
      tags :service_stop
      label :service_stop
Severity: Major
Found in definitions/scenarios/services.rb and 3 other locations - About 45 mins to fix
definitions/scenarios/services.rb on lines 49..67
definitions/scenarios/services.rb on lines 92..110
definitions/scenarios/services.rb on lines 114..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def execute
          run_scenario_or_rescue do
            locked = ForemanMaintain.package_manager.versions_locked?
            puts "Packages are#{locked ? '' : ' not'} locked"
            exit_code = locked ? 0 : 1
Severity: Minor
Found in lib/foreman_maintain/cli/packages_command.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