orange-cloudfoundry/cf-ops-automation

View on GitHub
lib/directory_initializer.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
98%

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

  def generate_default_ci_deployment_overview
    ci_deployment_overview = {}

    ci_deployment_overview['ci-deployment'] = {
      @root_deployment_name.to_s => {
Severity: Minor
Found in lib/directory_initializer.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.

DirectoryInitializer#add_deployment has approx 9 statements
Open

  def add_deployment(deployment_name, deployment_dependencies_content = DEFAULT_DEPLOYMENT_DEPENDENCIES_CONTENT)
Severity: Minor
Found in lib/directory_initializer.rb by reek

A method with Too Many Statements is any method that has a large number of lines.

Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

So the following method would score +6 in Reek's statement-counting algorithm:

def parse(arg, argv, &error)
  if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
    return nil, block, nil                                         # +1
  end
  opt = (val = parse_arg(val, &error))[1]                          # +2
  val = conv_arg(*val)                                             # +3
  if opt and !arg
    argv.shift                                                     # +4
  else
    val[0] = nil                                                   # +5
  end
  val                                                              # +6
end

(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

DirectoryInitializer#setup_templates! has approx 9 statements
Open

  def setup_templates!
Severity: Minor
Found in lib/directory_initializer.rb by reek

A method with Too Many Statements is any method that has a large number of lines.

Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

So the following method would score +6 in Reek's statement-counting algorithm:

def parse(arg, argv, &error)
  if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
    return nil, block, nil                                         # +1
  end
  opt = (val = parse_arg(val, &error))[1]                          # +2
  val = conv_arg(*val)                                             # +3
  if opt and !arg
    argv.shift                                                     # +4
  else
    val[0] = nil                                                   # +5
  end
  val                                                              # +6
end

(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

DirectoryInitializer has no descriptive comment
Open

class DirectoryInitializer
Severity: Minor
Found in lib/directory_initializer.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

DirectoryInitializer has missing safe method 'setup_templates!'
Open

  def setup_templates!
Severity: Minor
Found in lib/directory_initializer.rb by reek

A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

An exclamation mark in method names means (the explanation below is taken from here ):

The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

Example

Given

class C
  def foo; end
  def foo!; end
  def bar!; end
end

Reek would report bar! as Missing Safe Method smell but not foo!.

Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

class Parent
  def foo; end
end

module Dangerous
  def foo!; end
end

class Son < Parent
  include Dangerous
end

class Daughter < Parent
end

In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

DirectoryInitializer#create_non_existing_dirs doesn't depend on instance state (maybe move it to another class?)
Open

  def create_non_existing_dirs(dirs)
Severity: Minor
Found in lib/directory_initializer.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

DirectoryInitializer#validate_string doesn't depend on instance state (maybe move it to another class?)
Open

  def validate_string(cred)
Severity: Minor
Found in lib/directory_initializer.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

DirectoryInitializer has missing safe method 'setup_secrets!'
Open

  def setup_secrets!
Severity: Minor
Found in lib/directory_initializer.rb by reek

A candidate method for the Missing Safe Method smell are methods whose names end with an exclamation mark.

An exclamation mark in method names means (the explanation below is taken from here ):

The ! in method names that end with ! means, “This method is dangerous”—or, more precisely, this method is the “dangerous” version of an otherwise equivalent method, with the same name minus the !. “Danger” is relative; the ! doesn’t mean anything at all unless the method name it’s in corresponds to a similar but bang-less method name. So, for example, gsub! is the dangerous version of gsub. exit! is the dangerous version of exit. flatten! is the dangerous version of flatten. And so forth.

Such a method is called Missing Safe Method if and only if her non-bang version does not exist and this method is reported as a smell.

Example

Given

class C
  def foo; end
  def foo!; end
  def bar!; end
end

Reek would report bar! as Missing Safe Method smell but not foo!.

Reek reports this smell only in a class context, not in a module context in order to allow perfectly legit code like this:

class Parent
  def foo; end
end

module Dangerous
  def foo!; end
end

class Son < Parent
  include Dangerous
end

class Daughter < Parent
end

In this example, Reek would not report the Missing Safe Method smell for the method foo of the Dangerous module.

DirectoryInitializer#delete_existing_files doesn't depend on instance state (maybe move it to another class?)
Open

  def delete_existing_files(files)
Severity: Minor
Found in lib/directory_initializer.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

DirectoryInitializer#validate_string performs a nil-check
Open

    !(cred.nil? || !cred.is_a?(String) || cred.empty?)
Severity: Minor
Found in lib/directory_initializer.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

DirectoryInitializer#create_non_existing_files doesn't depend on instance state (maybe move it to another class?)
Open

  def create_non_existing_files(files)
Severity: Minor
Found in lib/directory_initializer.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

There are no issues that match your filters.

Category
Status