Showing 88 of 88 total issues
Class Cli
has 67 methods (exceeds 20 allowed). Consider refactoring. Open
class Cli
attr_accessor :options
# machine host
def host
- Create a ticketCreate a ticket
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? ||
- Read upRead up
- Create a ticketCreate a ticket
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 452 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'optimist'
require 'pathname'
# support for appliance_console methods
unless defined?(say)
- Create a ticketCreate a ticket
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? ||
- Create a ticketCreate a ticket
Cyclomatic complexity for run is too high. [48/11] 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? ||
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
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
- Create a ticketCreate a ticket
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)
- Read upRead up
- Create a ticketCreate a ticket
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?
- Read upRead up
- Create a ticketCreate a ticket
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
#
- Create a ticketCreate a ticket
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]"
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
Cyclomatic complexity for disk_usage is too high. [15/11] Open
def self.disk_usage(file = nil)
file_arg = file
file_arg = "-l" if file.nil? || file == ""
unless file_arg == "-l" || File.exist?(file)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.
def each_child_node(*types) # count begins: 1
unless block_given? # unless: +1
return to_enum(__method__, *types)
children.each do |child| # each{}: +1
next unless child.is_a?(Node) # unless: +1
yield child if types.empty? || # if: +1, ||: +1
types.include?(child.type)
end
self
end # total: 6
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? ||
- Create a ticketCreate a ticket
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?
- Read upRead up
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
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?
- Create a ticketCreate a ticket