crowbar/crowbar-core

View on GitHub

Showing 6,062 of 6,062 total issues

Method queue_proposal has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def queue_proposal(inst, element_order, elements, deps, bc = @bc_name, pre_cached_nodes = {})
Severity: Minor
Found in crowbar_framework/app/models/service_object.rb - About 45 mins to fix

Method evacuate_network_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def evacuate_network_node(controller, network_node, delete_namespaces = false)
        save_node_action("evacuating dhcp networks")
        hostname = network_node["hostname"]
        migrated_file = "/var/lib/crowbar/upgrade/crowbar-network-evacuated"
        if network_node.file_exist? migrated_file
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.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 start_remote_resources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def start_remote_resources(controller, hostname)
        save_node_action("starting services at remote node #{hostname}")
        out = controller.run_ssh_cmd(
          "crm --wait node ready remote-#{hostname}",
          "60s"
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.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 health_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def health_check
        ret = {}
        unready = []
        NodeObject.all.each do |node|
          unready << node.name unless node.ready?
Severity: Minor
Found in crowbar_framework/app/models/api/crowbar.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 stop_nova_services has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def stop_nova_services
        nova_nodes = if upgrade_mode == :normal
          ::Node.find("roles:nova-controller")
        else
          ::Node.find("roles:nova-*").sort do |n|
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.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 process_barclamp! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def process_barclamp!(barclamp)
      [].tap do |result|
        Proposal.where(
          barclamp: barclamp
        ).each do |proposal|
Severity: Minor
Found in crowbar_framework/app/models/batch/export.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 reload_nova_services has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def reload_nova_services
        nova_nodes = if upgrade_mode == :normal
          ::Node.find("roles:nova-controller")
        else
          ::Node.find("roles:nova-*").sort do |n|
Severity: Minor
Found in crowbar_framework/app/models/api/upgrade.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

Avoid deeply nested control flow statements.
Open

            unless unallocated_nodes.empty?
              flash[:alert] = t(
                "barclamp.proposal_show.commit_proposal_queued_unallocated",
                nodes: unallocated_nodes.join(", ")
              )
Severity: Major
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      elsif params[:submit] == t("barclamp.proposal_show.destroy_active")
        begin
          answer = @service_object.destroy_active(params[:name])
          set_flash(answer, "barclamp.proposal_show.destroy_active_%s")
        rescue StandardError => e
Severity: Major
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 45 mins to fix

Method delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    params[:id] = params[:id] || params[:name]
    ret = [500, "Server Problem"]
    begin
      ret = @service_object.destroy_active(params[:id])
Severity: Minor
Found in crowbar_framework/app/controllers/barclamp_controller.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

Avoid deeply nested control flow statements.
Open

            if unready_nodes.empty? && unallocated_nodes.empty?
              # find out which proposals were not applied yet
              deps = @service_object.proposal_dependencies(
                ServiceObject.proposal_to_role(@proposal, params[:barclamp])
              )
Severity: Major
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 45 mins to fix

Method validate_alias has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_alias(value, unique_check = true)
    if ! value.empty? && value !~ /^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$/
      Rails.logger.warn "Alias #{value} not saved because it did not conform to valid DNS hostnames"
      raise "#{I18n.t('model.node.invalid_dns_alias')}: #{value}"
    end
Severity: Minor
Found in crowbar_framework/app/models/node.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 upgrade has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def upgrade
    if request.post?
      ::Crowbar::UpgradeStatus.new.start_step(:admin)
      crowbar_upgrade = Api::Crowbar.upgrade!

Severity: Minor
Found in crowbar_framework/app/controllers/api/crowbar_controller.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

Avoid deeply nested control flow statements.
Open

        rescue StandardError => e
          flash_and_log_exception(e)
Severity: Major
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            unless unready_nodes.empty?
              flash[:notice] = t(
                "barclamp.proposal_show.commit_proposal_queued",
                nodes: (unready_nodes - unallocated_nodes).join(", ")
              )
Severity: Major
Found in crowbar_framework/app/controllers/barclamp_controller.rb - About 45 mins to fix

Method check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def check
    respond_to do |format|
      format.json do
        if Crowbar::Sanity.refresh_cache
          render json: Rails.cache.fetch(:sanity_check_errors)
Severity: Minor
Found in crowbar_framework/app/controllers/sanities_controller.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 exec_failure has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def self.exec_failure(node, cmd, shell, out, err, status)
Severity: Minor
Found in crowbar_framework/lib/crowbar/lock/shared_non_blocking.rb - About 45 mins to fix

Method proposal_nodes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def proposal_nodes(nodes = Node.all, include_roles = nil, exclude_roles = nil)
    assigned_nodes = {}
    elements.each do |role_name, node_names|
      next if !include_roles.nil? && !include_roles.include?(role_name)
      next if !exclude_roles.nil? && exclude_roles.include?(role_name)
Severity: Minor
Found in crowbar_framework/app/models/role_object.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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @errors = Rails.cache.read(:sanity_check_errors)

    respond_to do |format|
      if @errors.empty?
Severity: Minor
Found in crowbar_framework/app/controllers/sanities_controller.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 provided_with_enabled has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def provided_with_enabled(feature,
                                platform = nil,
                                arch = nil,
                                check_enabled = true,
                                ignore_cloud = false,
Severity: Minor
Found in crowbar_framework/lib/crowbar/repository.rb - About 45 mins to fix
Severity
Category
Status
Source
Language