ManageIQ/manageiq-appliance_console

View on GitHub

Showing 86 of 86 total issues

Avoid parameter lists longer than 5 parameters. [7/5]
Open

def ask_for_new_password(prompt, default: nil, allow_empty: false, retry_limit: 1, confirm_password: true, validation: nil, validation_err: nil)

Method initialize_from_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def initialize_from_hash(hash)
hash.each do |k, v|
next if v.nil?
setter = "#{k}="
if self.respond_to?(setter)
Severity: Minor
Found in lib/manageiq/appliance_console/database_configuration.rb - About 25 mins to fix

Method ask_for_uri has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def ask_for_uri(prompt, expected_scheme, opts = {})
require 'uri'
just_ask(prompt, nil, nil, 'a valid URI') do |q|
q.validate = lambda do |a|
# Convert all backslashes in the URI to forward slashes and strip whitespace
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 25 mins to fix

Method ask_with_menu has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def ask_with_menu(prompt, options, default = nil, clear_screen_after = true)
say("#{prompt}\n\n")
 
default = default_to_index(default, options)
selection = nil
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 25 mins to fix

Method node_number_valid? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def node_number_valid?
rec = record_for_node_number
 
return true if rec.nil?
node_state = rec["active"] ? "active" : "inactive"
Severity: Minor
Found in lib/manageiq/appliance_console/database_replication_standby.rb - About 25 mins to fix

Method fetch_from_server has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def fetch_from_server(src_file, dst_file)
return if file_found?(dst_file)
 
FileUtils.mkdir_p(dst_file.dirname) unless dst_file.dirname.directory?
 
 
Severity: Minor
Found in lib/manageiq/appliance_console/message_configuration_client.rb - About 25 mins to fix

Method ask_questions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def ask_questions
return false unless valid_environment?
ask_for_parameters
show_parameters
return false unless agree("\nProceed? (Y/N): ")
Severity: Minor
Found in lib/manageiq/appliance_console/external_httpd_authentication.rb - About 25 mins to fix

Method set_server_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def set_server_state
case options[:server]
when "start"
EvmServer.start unless EvmServer.running?
when "stop"
Severity: Minor
Found in lib/manageiq/appliance_console/cli.rb - About 25 mins to fix

Method ask_yn? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def ask_yn?(prompt, default = nil)
ask("#{prompt}? (Y/N): ") do |q|
q.default = default if default
q.validate = ->(p) { (p.blank? && default) || %w(y n).include?(p.downcase[0]) }
q.responses[:not_valid] = "Please provide yes or no."
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 25 mins to fix

Method activate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def activate
if !key_exist? || force
if get_new_key
save_new_key
else
Severity: Minor
Found in lib/manageiq/appliance_console/key_configuration.rb - About 25 mins to fix

Method selected_verb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def selected_verb(key, flag)
if EXT_AUTH_OPTIONS[key][:logic]
flag ? "Enable" : "Disable"
else
flag ? "Disable" : "Enable"
Severity: Minor
Found in lib/manageiq/appliance_console/external_auth_options.rb - About 25 mins to fix

Method valid_environment? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def valid_environment?
if already_configured?
unconfigure if agree("\nAlready configured on this Appliance, Un-Configure first? (Y/N): ")
return false unless agree("\nProceed with Configuration? (Y/N): ")
end
Severity: Minor
Found in lib/manageiq/appliance_console/message_configuration.rb - About 25 mins to fix

Method ask_questions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def ask_questions
@current_config = load_current
apply = EXT_AUTH_OPTIONS.keys.count + 1
skip = apply + 1
selection = 0
Severity: Minor
Found in lib/manageiq/appliance_console/external_auth_options.rb - About 25 mins to fix

Method has too many optional parameters. [4/3]
Open

def ask_for_many(prompt, collective = nil, default = nil, max_length = 255, max_count = 6)
collective ||= "#{prompt}s"
validate = ->(p) { (p.length < max_length) && (p.split(/[\s,;]+/).length <= max_count) }
error_message = "up to #{max_count} #{prompt}s separated by a space and up to #{max_length} characters"
just_ask(collective, default, validate, error_message).split(/[\s,;]+/).collect(&:strip)

Method has too many optional parameters. [4/3]
Open

def just_ask(prompt, default = nil, validate = nil, error_text = nil, klass = nil)
ask("Enter the #{prompt}: ", klass) do |q|
q.default = default.to_s if default
q.validate = validate if validate
q.responses[:not_valid] = error_text ? "Please provide #{error_text}" : "Please provide in the specified format"

Method ask_questions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def ask_questions
clear_screen
say("Establish Replication Standby Server\n")
return false if !data_dir_empty? && !confirm_data_resync
self.disk = ask_for_disk("Standby database disk")
Severity: Minor
Found in lib/manageiq/appliance_console/database_replication_standby.rb - About 25 mins to fix

Method load_current has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def self.load_current
require 'yaml'
unless File.exist?(DB_YML)
require 'fileutils'
FileUtils.cp(DB_YML_TMPL, DB_YML) if File.exist?(DB_YML_TMPL)
Severity: Minor
Found in lib/manageiq/appliance_console/database_configuration.rb - About 25 mins to fix

Method set_db has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def set_db
raise "No encryption key (v2_key) present" unless key_configuration.key_exist?
raise "A password is required to configure a database" unless password?
if local?
set_internal_db
Severity: Minor
Found in lib/manageiq/appliance_console/cli.rb - About 25 mins to fix

Method rename_mellon_configfiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def rename_mellon_configfiles
debug_msg("Renaming mellon config files ...")
Dir.chdir(SAML2_CONFIG_DIRECTORY) do
Dir.glob("https_*.*") do |mellon_file|
saml2_file =
Severity: Minor
Found in lib/manageiq/appliance_console/saml_authentication.rb - About 25 mins to fix

Method activate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def activate
say("Configuring Replication Standby Server...")
stop_postgres
stop_repmgrd
initialize_postgresql_disk if disk
Severity: Minor
Found in lib/manageiq/appliance_console/database_replication_standby.rb - About 25 mins to fix
Severity
Category
Status
Source
Language