ManageIQ/manageiq-appliance_console

View on GitHub

Showing 54 of 88 total issues

Class Cli has 67 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Cli
    attr_accessor :options

    # machine host
    def host
Severity: Major
Found in lib/manageiq/appliance_console/cli.rb - About 1 day to fix

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

    def run
      Optimist.educate unless set_host? || key? || database? || db_dump? || db_backup? ||
                              db_restore? || tmp_disk? || log_disk? ||
                              uninstall_ipa? || install_ipa? || certs? || extauth_opts? ||
                              set_server_state? || set_replication? || openscap? ||
Severity: Minor
Found in lib/manageiq/appliance_console/cli.rb - About 7 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File cli.rb has 454 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'optimist'
require 'pathname'

# support for appliance_console methods
unless defined?(say)
Severity: Minor
Found in lib/manageiq/appliance_console/cli.rb - About 6 hrs to fix

Consider simplifying this complex logical expression.
Open

      Optimist.educate unless set_host? || key? || database? || db_dump? || db_backup? ||
                              db_restore? || tmp_disk? || log_disk? ||
                              uninstall_ipa? || install_ipa? || certs? || extauth_opts? ||
                              set_server_state? || set_replication? || openscap? ||
                              saml_config? || saml_unconfig? ||
Severity: Critical
Found in lib/manageiq/appliance_console/cli.rb - About 6 hrs to fix

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

  class DatabaseConfiguration
    include ManageIQ::ApplianceConsole::ManageiqUserMixin

    attr_accessor :adapter, :host, :username, :database, :port, :region, :run_as_evm_server
    attr_reader :password
Severity: Minor
Found in lib/manageiq/appliance_console/database_configuration.rb - About 3 hrs to fix

Method disk_usage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def self.disk_usage(file = nil)
      file_arg = file
      file_arg = "-l" if file.nil? || file == ""

      unless file_arg == "-l" || File.exist?(file)
Severity: Minor
Found in lib/manageiq/appliance_console/utilities.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method ask_for_database_credentials has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def ask_for_database_credentials(password_twice = true)
      self.host     = ask_for_ip_or_hostname("database hostname or IP address", host) if host.blank? || !local?
      self.port     = ask_for_integer("port number", nil, port) unless local?
      self.database = just_ask("name of the database on #{host}", database) unless local?
      self.username = just_ask("username", username) unless local?
Severity: Minor
Found in lib/manageiq/appliance_console/database_configuration.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

  class ExternalHttpdAuthentication
    module ExternalHttpdConfiguration
      #
      # External Authentication Definitions
      #

Method parse has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse(args)
      args.shift if args.first == "--" # Handle when called through script/runner
      self.options = Optimist.options(args) do
        banner "Usage: appliance_console_cli [options]"

Severity: Major
Found in lib/manageiq/appliance_console/cli.rb - About 2 hrs to fix

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

  class InternalDatabaseConfiguration < DatabaseConfiguration
    attr_accessor :disk

    DEDICATED_DB_SHARED_BUFFERS = "'1GB'".freeze
    SHARED_DB_SHARED_BUFFERS = "'128MB'".freeze
Severity: Minor
Found in lib/manageiq/appliance_console/internal_database_configuration.rb - About 2 hrs to fix

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

    class DatabaseAdmin < HighLine
      include ManageIQ::ApplianceConsole::Prompts

      DB_RESTORE_FILE      = "/tmp/evm_db.backup".freeze
      DB_DEFAULT_DUMP_FILE = "/tmp/evm_db.dump".freeze
Severity: Minor
Found in lib/manageiq/appliance_console/database_admin.rb - About 2 hrs to fix

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

    class MessageServerConfiguration < MessageConfiguration
      attr_reader :jaas_config_path,
                  :server_properties_path, :server_properties_sample_path,
                  :ca_cert_srl_path, :ca_key_path, :cert_file_path, :cert_signed_path,
                  :keystore_files, :installed_files, :message_persistent_disk
Severity: Minor
Found in lib/manageiq/appliance_console/message_configuration_server.rb - About 2 hrs to fix

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

  class Certificate
    STATUS_COMPLETE = :complete

    # map `getcert status` return codes to something more descriptive
    # 0 => :complete -- keys/certs generated
Severity: Minor
Found in lib/manageiq/appliance_console/certificate.rb - About 2 hrs to fix

Method run has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run
      Optimist.educate unless set_host? || key? || database? || db_dump? || db_backup? ||
                              db_restore? || tmp_disk? || log_disk? ||
                              uninstall_ipa? || install_ipa? || certs? || extauth_opts? ||
                              set_server_state? || set_replication? || openscap? ||
Severity: Minor
Found in lib/manageiq/appliance_console/cli.rb - About 1 hr to fix

Method ask_for_disk has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def ask_for_disk(disk_name, verify = true, silent = false)
      require "linux_admin"
      disks = LinuxAdmin::Disk.local.select { |d| d.partitions.empty? }

      if disks.empty?
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.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 configure_keystore has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def configure_keystore
        say(__method__.to_s.tr("_", " ").titleize)

        return if files_found?(keystore_files)

Severity: Minor
Found in lib/manageiq/appliance_console/message_configuration_server.rb - About 1 hr to fix

Method disk_usage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.disk_usage(file = nil)
      file_arg = file
      file_arg = "-l" if file.nil? || file == ""

      unless file_arg == "-l" || File.exist?(file)
Severity: Minor
Found in lib/manageiq/appliance_console/utilities.rb - About 1 hr to fix

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

    def ask_for_database_credentials(password_twice = true)
      self.host     = ask_for_ip_or_hostname("database hostname or IP address", host) if host.blank? || !local?
      self.port     = ask_for_integer("port number", nil, port) unless local?
      self.database = just_ask("name of the database on #{host}", database) unless local?
      self.username = just_ask("username", username) unless local?
Severity: Minor
Found in lib/manageiq/appliance_console/database_configuration.rb - About 1 hr to fix

Method just_ask has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def just_ask(prompt, default = nil, validate = nil, error_text = nil, klass = nil)
      ask("Enter the #{prompt}: ", klass) do |q|
        q.readline = true
        q.default = default.to_s if default
        q.validate = validate if validate
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.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 set_replication has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def set_replication
      if options[:replication] == "primary"
        db_replication = ManageIQ::ApplianceConsole::DatabaseReplicationPrimary.new
        say("Configuring Server as Primary")
      else
Severity: Minor
Found in lib/manageiq/appliance_console/cli.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

Severity
Category
Status
Source
Language