theforeman/foreman_maintain

View on GitHub

Showing 98 of 98 total issues

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

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 3 locations. Consider refactoring.
Open

  module Online
    class PulpcoreDB < ForemanMaintain::Procedure
      metadata do
        description 'Backup Pulpcore database online'
        tags :backup
Severity: Major
Found in definitions/procedures/backup/online/pulpcore_db.rb and 2 other locations - About 45 mins to fix
definitions/procedures/backup/online/candlepin_db.rb on lines 2..15
definitions/procedures/backup/online/foreman_db.rb on lines 2..15

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 39.

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 3 locations. Consider refactoring.
Open

  module Online
    class CandlepinDB < ForemanMaintain::Procedure
      metadata do
        description 'Backup Candlepin database online'
        tags :backup
Severity: Major
Found in definitions/procedures/backup/online/candlepin_db.rb and 2 other locations - About 45 mins to fix
definitions/procedures/backup/online/foreman_db.rb on lines 2..15
definitions/procedures/backup/online/pulpcore_db.rb on lines 2..15

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 39.

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 3 locations. Consider refactoring.
Open

  module Online
    class ForemanDB < ForemanMaintain::Procedure
      metadata do
        description 'Backup Foreman database online'
        tags :backup
Severity: Major
Found in definitions/procedures/backup/online/foreman_db.rb and 2 other locations - About 45 mins to fix
definitions/procedures/backup/online/candlepin_db.rb on lines 2..15
definitions/procedures/backup/online/pulpcore_db.rb on lines 2..15

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 39.

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 option has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def self.option(switches, type, description, opts = {}, &block)
Severity: Minor
Found in lib/foreman_maintain/cli/base.rb - About 35 mins to fix

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

        def run
          assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
          packages_action(:remove, @packages, :assumeyes => assumeyes_val)
        rescue ForemanMaintain::Error::ExecutionError => e
          if @warn_on_errors
    Severity: Minor
    Found in definitions/procedures/packages/uninstall.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def run
          assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
          packages_action(:install, @packages, :assumeyes => assumeyes_val)
        rescue ForemanMaintain::Error::ExecutionError => e
          if @warn_on_errors
    Severity: Minor
    Found in definitions/procedures/packages/install.rb - About 35 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

        def enabled_sync_plans
          default_storage = ForemanMaintain.storage(:default)
          feature(:sync_plans).load_from_storage(default_storage)
          with_spinner('re-enabling sync plans') do |spinner|
            record_ids = feature(:sync_plans).make_enable
    Severity: Minor
    Found in definitions/procedures/sync_plans/enable.rb and 1 other location - About 35 mins to fix
    definitions/procedures/sync_plans/disable.rb on lines 20..30

    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 35.

    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

        def disable_all_enabled_sync_plans
          default_storage = ForemanMaintain.storage(:default)
          feature(:sync_plans).load_from_storage(default_storage)
          with_spinner('disabling sync plans') do |spinner|
            record_ids = feature(:sync_plans).make_disable
    Severity: Minor
    Found in definitions/procedures/sync_plans/disable.rb and 1 other location - About 35 mins to fix
    definitions/procedures/sync_plans/enable.rb on lines 21..31

    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 35.

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

          def validate_interfaces
            # I wanted to do `Socket.getifaddrs.map(&:name).uniq`,
            # but this has to work with Ruby 2.0, and Socket.getifaddrs is 2.1+
            errors = {}
            system_interfaces = Dir.entries('/sys/class/net') - ['.', '..']
    Severity: Minor
    Found in lib/foreman_maintain/utils/backup.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def run
          logger.debug("Invoking tar from #{FileUtils.pwd}")
          tar_cmd = tar_command
          attempt_no = 1
          loop do
    Severity: Minor
    Found in definitions/procedures/backup/config_files.rb - About 35 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 deep_merge! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.deep_merge!(hash, other_hash)
          other_hash = symbolize_hash(other_hash)
    
          hash.merge!(other_hash) do |_key, old_val, new_val|
            if old_val.is_a?(Hash) && new_val.is_a?(Hash)
    Severity: Minor
    Found in lib/foreman_maintain/utils/hash_tools.rb - About 35 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 rollback_pre_migrations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def rollback_pre_migrations
          raise "Unexpected phase #{phase}, expecting pre_migrations" unless phase == :pre_migrations
    
          rollback_needed = scenario(:pre_migrations).steps.any? { |s| s.executed? && s.success? }
          if rollback_needed
    Severity: Minor
    Found in lib/foreman_maintain/upgrade_runner.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def run
          @scenarios.each do |scenario|
            run_scenario(scenario)
            next unless @quit
    
    
    Severity: Minor
    Found in lib/foreman_maintain/runner.rb - About 35 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 dumps_for_hybrid_db_setup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def dumps_for_hybrid_db_setup(dbs_hash)
            present = []
            absent = []
            dbs_hash.each do |data_file, dbs|
              dbs.each do |db|
    Severity: Minor
    Found in lib/foreman_maintain/utils/backup.rb - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def run
          self.class.current_target_version = @version
          PHASES.each do |phase|
            return run_rollback if quit?
    
    
    Severity: Minor
    Found in lib/foreman_maintain/upgrade_runner.rb - About 35 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

      class EnableMaintenanceMode < ForemanMaintain::Procedure
        include ForemanMaintain::Concerns::Firewall::MaintenanceMode
        metadata do
          label :enable_maintenance_mode
          description 'Add maintenance_mode tables/chain to nftables/iptables'
    definitions/procedures/maintenance_mode/disable_maintenance_mode.rb on lines 2..15

    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 31.

    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

      class DisableMaintenanceMode < ForemanMaintain::Procedure
        include ForemanMaintain::Concerns::Firewall::MaintenanceMode
        metadata do
          label :disable_maintenance_mode
          description 'Remove maintenance mode table/chain from nftables/iptables'
    definitions/procedures/maintenance_mode/enable_maintenance_mode.rb on lines 2..15

    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 31.

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

      def config_files(for_features = ['all'])
        configs = default_config_files
        backup_features = backup_features(for_features)
    
        configs.push(certs_tar) if certs_tar
    Severity: Minor
    Found in definitions/features/foreman_proxy.rb - About 25 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