theforeman/foreman_maintain

View on GitHub

Showing 105 of 105 total issues

Class Backup has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Backup
      include Concerns::SystemHelpers

      attr_accessor :standard_files, :katello_online_files, :katello_offline_files,
        :foreman_online_files, :foreman_offline_files, :fpc_offline_files,
Severity: Minor
Found in lib/foreman_maintain/utils/backup.rb - About 4 hrs to fix

    Class ForemanProxy has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Features::ForemanProxy < ForemanMaintain::Feature
      metadata do
        label :foreman_proxy
        confine do
          find_package('foreman-proxy')
    Severity: Minor
    Found in definitions/features/foreman_proxy.rb - About 4 hrs to fix

      Class Executable has 31 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Executable
          extend Forwardable
          extend Concerns::Finders
          attr_reader :options
      
      
      Severity: Minor
      Found in lib/foreman_maintain/executable.rb - About 3 hrs to fix

        Class Dnf has 30 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Dnf < Base
            PROTECTOR_CONFIG_FILE = '/etc/dnf/plugins/foreman-protector.conf'.freeze
            PROTECTOR_WHITELIST_FILE = '/etc/dnf/plugins/foreman-protector.whitelist'.freeze
        
            def self.parse_envra(envra)
        Severity: Minor
        Found in lib/foreman_maintain/package_manager/dnf.rb - About 3 hrs to fix

          File cli_reporter.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'highline'
          
          module ForemanMaintain
            class Reporter
              class CLIReporter < Reporter
          Severity: Minor
          Found in lib/foreman_maintain/reporter/cli_reporter.rb - About 3 hrs to fix

            Class Instance has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Features::Instance < ForemanMaintain::Feature
              metadata do
                label :instance
              end
            
            
            Severity: Minor
            Found in definitions/features/instance.rb - About 3 hrs to fix

              Class CLIReporter has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class CLIReporter < Reporter
                    include Concerns::Logger
                    # Simple spinner able to keep updating current line
                    class Spinner
                      def initialize(reporter, interval = 0.1)
              Severity: Minor
              Found in lib/foreman_maintain/reporter/cli_reporter.rb - About 3 hrs to fix

                Class Scenario has 25 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Scenario
                    include Concerns::Logger
                    include Concerns::SystemHelpers
                    include Concerns::ScenarioMetadata
                    include Concerns::Finders
                Severity: Minor
                Found in lib/foreman_maintain/scenario.rb - About 2 hrs to fix

                  Class Base has 24 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class Base < Clamp::Command
                        include Concerns::Finders
                  
                        attr_reader :runner
                  
                  
                  Severity: Minor
                  Found in lib/foreman_maintain/cli/base.rb - About 2 hrs to fix

                    Class UpgradeRunner has 23 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                      class UpgradeRunner < Runner
                        include Concerns::Finders
                    
                        # Phases of the upgrade, see README.md for more info
                        PHASES = [:pre_upgrade_checks,
                    Severity: Minor
                    Found in lib/foreman_maintain/upgrade_runner.rb - About 2 hrs to fix

                      Class Hammer has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Features::Hammer < ForemanMaintain::Feature
                        attr_reader :configuration, :config_files
                      
                        metadata do
                          label :hammer
                      Severity: Minor
                      Found in definitions/features/hammer.rb - About 2 hrs to fix

                        Method scenario_failure_message has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def scenario_failure_message(scenario)
                                return if scenario.passed? && !scenario.warning?
                        
                                message = []
                                message << <<~MESSAGE
                        Severity: Major
                        Found in lib/foreman_maintain/reporter/cli_reporter.rb - About 2 hrs to fix

                          Method ensure_dir_unchanged has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def ensure_dir_unchanged
                                matching = false
                                backup_file = File.join(@backup_dir, '.pulp.snar')
                                alternate_backup = File.join(@backup_dir, '.pulp.snar.backup')
                                until matching
                          Severity: Minor
                          Found in definitions/procedures/backup/pulp.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 scenario_failure_message has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def scenario_failure_message(scenario)
                                  return if scenario.passed? && !scenario.warning?
                          
                                  message = []
                                  message << <<~MESSAGE
                          Severity: Minor
                          Found in lib/foreman_maintain/reporter/cli_reporter.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 facts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def facts
                                  unless defined?(@facts)
                                    @facts = {}
                                    regex = /^(["'])(.*)(\1)$/
                                    File.open(os_release_file) do |file|
                          Severity: Minor
                          Found in lib/foreman_maintain/concerns/os_facts.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

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

                            class PulpcoreDump < ForemanMaintain::Procedure
                              metadata do
                                description 'Restore pulpcore postgresql dump from backup'
                                param :backup_dir,
                                  'Path to backup directory',
                          Severity: Major
                          Found in definitions/procedures/restore/pulpcore_dump.rb and 2 other locations - About 1 hr to fix
                          definitions/procedures/restore/candlepin_dump.rb on lines 2..26
                          definitions/procedures/restore/foreman_dump.rb on lines 2..26

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

                          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

                            class CandlepinDump < ForemanMaintain::Procedure
                              metadata do
                                description 'Restore candlepin postgresql dump from backup'
                                param :backup_dir,
                                  'Path to backup directory',
                          Severity: Major
                          Found in definitions/procedures/restore/candlepin_dump.rb and 2 other locations - About 1 hr to fix
                          definitions/procedures/restore/foreman_dump.rb on lines 2..26
                          definitions/procedures/restore/pulpcore_dump.rb on lines 2..26

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

                          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

                            class ForemanDump < ForemanMaintain::Procedure
                              metadata do
                                description 'Restore foreman postgresql dump from backup'
                                param :backup_dir,
                                  'Path to backup directory',
                          Severity: Major
                          Found in definitions/procedures/restore/foreman_dump.rb and 2 other locations - About 1 hr to fix
                          definitions/procedures/restore/candlepin_dump.rb on lines 2..26
                          definitions/procedures/restore/pulpcore_dump.rb on lines 2..26

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

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

                            def tar_command(options)
                              volume_size = options.fetch(:volume_size, nil)
                              absolute_names = options.fetch(:absolute_names, nil)
                              validate_volume_size(volume_size) unless volume_size.nil?
                          
                          
                          Severity: Minor
                          Found in definitions/features/tar.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 ask_to_select has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def ask_to_select(message, steps, run_strategy)
                                  if assumeyes?
                                    step = steps[@select_option_counter]
                                    @select_option_counter += 1
                                    puts("(assuming option #{@select_option_counter})")
                          Severity: Minor
                          Found in lib/foreman_maintain/reporter/cli_reporter.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