orange-cloudfoundry/cf-ops-automation

View on GitHub
lib/coa/env_bootstrapper/bosh.rb

Summary

Maintainability
A
25 mins
Test Coverage
B
88%

Method has too many lines. [12/10]
Open

      def deploy_git_server(manifest)
        raise NoActiveStepConfigError.new('git_server_manifest', 'git_server_manifest') unless manifest

        if client.release_uploaded?("git-server", "3")
          logger.log_and_puts :info, "BOSH release git-server/3 already uploaded."
Severity: Minor
Found in lib/coa/env_bootstrapper/bosh.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for deploy_git_server is too high. [16.16/15]
Open

      def deploy_git_server(manifest)
        raise NoActiveStepConfigError.new('git_server_manifest', 'git_server_manifest') unless manifest

        if client.release_uploaded?("git-server", "3")
          logger.log_and_puts :info, "BOSH release git-server/3 already uploaded."
Severity: Minor
Found in lib/coa/env_bootstrapper/bosh.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Coa::EnvBootstrapper::Bosh#update_cloud_config refers to 'file' more than self (maybe move it to another class?)
Open

        file.write(cloud_config.to_yaml)
        file.close
        client.update_cloud_config(file.path)
Severity: Minor
Found in lib/coa/env_bootstrapper/bosh.rb by reek

Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

Example

Running Reek on:

class Warehouse
  def sale_price(item)
    (item.price - item.rebate) * @vat
  end
end

would report:

Warehouse#total_price refers to item more than self (FeatureEnvy)

since this:

(item.price - item.rebate)

belongs to the Item class, not the Warehouse.

Coa::EnvBootstrapper::Bosh#prepare_environment refers to 'prereqs' more than self (maybe move it to another class?)
Open

        upload_stemcell(prereqs.stemcell)              unless prereqs.inactive_step?("upload_stemcell")
        update_cloud_config(prereqs.cloud_config)      unless prereqs.inactive_step?("update_cloud_config")
        deploy_git_server(prereqs.git_server_manifest) unless prereqs.inactive_step?("deploy_git_server")
Severity: Minor
Found in lib/coa/env_bootstrapper/bosh.rb by reek

Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.

Feature Envy reduces the code's ability to communicate intent: code that "belongs" on one class but which is located in another can be hard to find, and may upset the "System of Names" in the host class.

Feature Envy also affects the design's flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application's domain, and creates a loss of cohesion in the unwilling host class.

Feature Envy often arises because it must manipulate other objects (usually its arguments) to get them into a useful form, and one force preventing them (the arguments) doing this themselves is that the common knowledge lives outside the arguments, or the arguments are of too basic a type to justify extending that type. Therefore there must be something which 'knows' about the contents or purposes of the arguments. That thing would have to be more than just a basic type, because the basic types are either containers which don't know about their contents, or they are single objects which can't capture their relationship with their fellows of the same type. So, this thing with the extra knowledge should be reified into a class, and the utility method will most likely belong there.

Example

Running Reek on:

class Warehouse
  def sale_price(item)
    (item.price - item.rebate) * @vat
  end
end

would report:

Warehouse#total_price refers to item more than self (FeatureEnvy)

since this:

(item.price - item.rebate)

belongs to the Item class, not the Warehouse.

Method prepare_environment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def prepare_environment(prereqs)
        logger.log_and_puts :debug, 'Preparing BOSH environment'
        upload_stemcell(prereqs.stemcell)              unless prereqs.inactive_step?("upload_stemcell")
        update_cloud_config(prereqs.cloud_config)      unless prereqs.inactive_step?("update_cloud_config")
        deploy_git_server(prereqs.git_server_manifest) unless prereqs.inactive_step?("deploy_git_server")
Severity: Minor
Found in lib/coa/env_bootstrapper/bosh.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