ManageIQ/manageiq-appliance_console

View on GitHub

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
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

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 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): ")

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
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 45 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 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
Severity: Minor
Found in lib/manageiq/appliance_console/certificate.rb - About 45 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 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) ")
Severity: Minor
Found in lib/manageiq/appliance_console/key_configuration.rb - About 45 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 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?
Severity: Minor
Found in lib/manageiq/appliance_console/external_auth_options.rb - About 45 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 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
Severity: Minor
Found in lib/manageiq/appliance_console/database_replication.rb - About 45 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 ipa_client_configure has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def ipa_client_configure(realm, domain, server, principal, password)

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)
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 35 mins to fix

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)
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 35 mins to fix

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)
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 35 mins to fix

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)
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 35 mins to fix

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)
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 35 mins to fix

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
Severity: Minor
Found in lib/manageiq/appliance_console/oidc_authentication.rb and 1 other location - About 35 mins to fix
lib/manageiq/appliance_console/saml_authentication.rb on lines 41..56

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

Further Reading

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
Severity: Minor
Found in lib/manageiq/appliance_console/saml_authentication.rb and 1 other location - About 35 mins to fix
lib/manageiq/appliance_console/oidc_authentication.rb on lines 38..53

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

Further Reading

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
Severity: Minor
Found in lib/manageiq/appliance_console/utilities.rb - About 35 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 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"
Severity: Minor
Found in lib/manageiq/appliance_console/database_configuration.rb - About 35 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 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)

Severity: Minor
Found in lib/manageiq/appliance_console/message_configuration.rb - About 35 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 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
Severity: Minor
Found in lib/manageiq/appliance_console/prompts.rb - About 35 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