crowbar/crowbar-core

View on GitHub
crowbar_framework/app/models/api/crowbar.rb

Summary

Maintainability
D
2 days
Test Coverage

Method deployment_check has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

      def deployment_check
        ret = {}
        # Only allow the upgrade for mariadb setup
        # TODO: update the search if we allow multiple proposals
        db_node = ::Node.find("roles:database-server").first
Severity: Minor
Found in crowbar_framework/app/models/api/crowbar.rb - About 6 hrs 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 ha_config_check has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

      def ha_config_check
        prop = Proposal.where(barclamp: "cinder").first

        unless prop.nil?
          backends = prop["attributes"]["cinder"]["volumes"].select do |volume|
Severity: Minor
Found in crowbar_framework/app/models/api/crowbar.rb - About 5 hrs 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 ha_config_check has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def ha_config_check
        prop = Proposal.where(barclamp: "cinder").first

        unless prop.nil?
          backends = prop["attributes"]["cinder"]["volumes"].select do |volume|
Severity: Major
Found in crowbar_framework/app/models/api/crowbar.rb - About 3 hrs to fix

Method upgrade! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def upgrade!
        if upgrading?
          return {
            status: :unprocessable_entity,
            message: I18n.t("api.crowbar.upgrade_ongoing")
Severity: Minor
Found in crowbar_framework/app/models/api/crowbar.rb - About 1 hr to fix

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 upgrade! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def upgrade!
        if upgrading?
          return {
            status: :unprocessable_entity,
            message: I18n.t("api.crowbar.upgrade_ongoing")
Severity: Minor
Found in crowbar_framework/app/models/api/crowbar.rb - About 25 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

There are no issues that match your filters.

Category
Status