orange-cloudfoundry/cf-ops-automation

View on GitHub
upgrade/v5.0.0/01-upgrade-config.rb

Summary

Maintainability
A
0 mins
Test Coverage

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

def cleanup_old_pipelines(ci_deployment_overview_files)
  migrated_counter = 0
  ci_deployment_overview_files&.each do |ci_deployment_filename|
    ci_deployment = YAML.load_file(ci_deployment_filename)
    unless ci_deployment
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.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.

cleanup_old_pipelines has approx 12 statements
Open

def cleanup_old_pipelines(ci_deployment_overview_files)
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.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.)

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

def pipeline_to_delete?(name)
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.rb by reek

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

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

def cleanup_generated_pipeline_dir(files_to_delete)
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.rb by reek

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

Use name.end_with?('-s3-stemcell-upload-generated', '-s3-br-upload-generated') instead of name.end_with?('-s3-stemcell-upload-generated') || name.end_with?('-s3-br-upload-generated').
Open

  name.end_with?('-s3-stemcell-upload-generated') || name.end_with?('-s3-br-upload-generated') || name.end_with?('-sync-helper-generated')
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.rb by rubocop

This cop checks for double #start_with? or #end_with? calls separated by ||. In some cases such calls can be replaced with an single #start_with?/#end_with? call.

Example:

# bad
str.start_with?("a") || str.start_with?(Some::CONST)
str.start_with?("a", "b") || str.start_with?("c")
str.end_with?(var1) || str.end_with?(var2)

# good
str.start_with?("a", Some::CONST)
str.start_with?("a", "b", "c")
str.end_with?(var1, var2)

Extra blank line detected.
Open


puts "Scanning for credentials in #{config_path}"
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Space missing after comma.
Open

  pipeline_name = File.basename(filename,'.yml')
Severity: Minor
Found in upgrade/v5.0.0/01-upgrade-config.rb by rubocop

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

There are no issues that match your filters.

Category
Status