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 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
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
Method run_interactive
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def run_interactive
ask_questions
clear_screen
say "Activating the configuration using the following settings...\n#{friendly_inspect}\n"
- 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 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)
- 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 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)
- 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
private
(on line 239) does not make singleton methods private. Use private_class_method
or private
inside a class << self
block instead. Open
def self.load_current
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for private
or protected
access modifiers which are
applied to a singleton method. These access modifiers do not make
singleton methods private/protected. private_class_method
can be
used for that.
Example:
# bad
class C
private
def self.method
puts 'hi'
end
end
Example:
# good
class C
def self.method
puts 'hi'
end
private_class_method :method
end
Example:
# good
class C
class << self
private
def method
puts 'hi'
end
end
end
private
(on line 239) does not make singleton methods private. Use private_class_method
or private
inside a class << self
block instead. Open
def self.encrypt_decrypt_password(settings)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for private
or protected
access modifiers which are
applied to a singleton method. These access modifiers do not make
singleton methods private/protected. private_class_method
can be
used for that.
Example:
# bad
class C
private
def self.method
puts 'hi'
end
end
Example:
# good
class C
def self.method
puts 'hi'
end
private_class_method :method
end
Example:
# good
class C
class << self
private
def method
puts 'hi'
end
end
end