Showing 88 of 88 total issues
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
- 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 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
- 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 valid_environment?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def valid_environment?
return false unless installation_valid?
if ipa_client_configured?
show_current_configuration
return false unless agree("\nIPA Client already configured on this Appliance, Un-Configure first? (Y/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 ask_for_password
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ask_for_password(prompt, default = nil)
pass = just_ask(prompt, default.present? ? "********" : nil) do |q|
q.echo = '*'
yield q if block_given?
end
- 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 request
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def request
undo_tracking if complete?
if should_request_key?
principal.register
- 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_question_loop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ask_question_loop
loop do
return false unless ask_questions
return true if activate
return false unless agree("Try again? (Y/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 show_updates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show_updates
updates_todo = ""
EXT_AUTH_OPTIONS.keys.each do |key|
next unless @updates.key?(key)
updates_todo << ", " if updates_todo.present?
- 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_cluster_database_credentials
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ask_for_cluster_database_credentials
self.database_name = just_ask("cluster database name", database_name)
self.database_user = just_ask("cluster database username", database_user)
count = 0
- 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 ipa_client_configure
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ipa_client_configure(realm, domain, server, principal, password)
- Create a ticketCreate a ticket
Method ask_for_ip
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ask_for_ip(prompt, default, validate = IP_REGEXP, error_text = "a valid IP Address.", &block)
- Create a ticketCreate a ticket
Method ask_for_many
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ask_for_many(prompt, collective = nil, default = nil, max_length = 255, max_count = 6)
- Create a ticketCreate a ticket
Method just_ask
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def just_ask(prompt, default = nil, validate = nil, error_text = nil, klass = nil)
- Create a ticketCreate a ticket
Method ask_for_domain
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ask_for_domain(prompt, default = nil, validate = DOMAIN_REGEXP, error_text = "a valid Domain.", &block)
- Create a ticketCreate a ticket
Method ask_for_hostname
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ask_for_hostname(prompt, default = nil, validate = HOSTNAME_REGEXP, error_text = "a valid Hostname.", &block)
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
def unconfigure
raise "Appliance is not currently configured for OpenID-Connect" unless configured?
say("Unconfiguring OpenID-Connect Authentication ...")
remove_apache_oidc_configfiles
- Read upRead up
- Create a ticketCreate a ticket
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 36.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def unconfigure
raise "Appliance is not currently configured for SAML" unless configured?
say("Unconfiguring SAML Authentication ...")
remove_apache_saml_configfiles
- Read upRead up
- Create a ticketCreate a ticket
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 36.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method db_region
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.db_region
result = AwesomeSpawn.run(
"bin/rails runner",
:params => ["puts ApplicationRecord.my_region_number"],
:chdir => ManageIQ::ApplianceConsole::RAILS_ROOT
- 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 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 create_client_properties
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_client_properties
say(__method__.to_s.tr("_", " ").titleize)
return if file_found?(client_properties_path)
- 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 default_to_index
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def default_to_index(default, options)
return unless default
default_index = if options.kind_of?(Hash)
options.values.index(default) || options.keys.index(default)
else
- 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"