orange-cloudfoundry/cf-ops-automation

View on GitHub
lib/tasks/bosh/list_releases.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

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

      def update_releases(a_release, all_releases)
        name = a_release&.dig('name')
        version = a_release&.dig('version')
        is_deployed = version.end_with?('*')
        as_uncommitted_changes = version.end_with?('+')
Severity: Minor
Found in lib/tasks/bosh/list_releases.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 update_releases is too high. [16.55/15]
Open

      def update_releases(a_release, all_releases)
        name = a_release&.dig('name')
        version = a_release&.dig('version')
        is_deployed = version.end_with?('*')
        as_uncommitted_changes = version.end_with?('+')
Severity: Minor
Found in lib/tasks/bosh/list_releases.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

Tasks::Bosh::ListReleases#update_releases has approx 13 statements
Open

      def update_releases(a_release, all_releases)
Severity: Minor
Found in lib/tasks/bosh/list_releases.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.)

Tasks::Bosh::ListReleases#update_releases doesn't depend on instance state (maybe move it to another class?)
Open

      def update_releases(a_release, all_releases)
Severity: Minor
Found in lib/tasks/bosh/list_releases.rb by reek

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

Tasks::Bosh::ListReleases#update_releases performs a nil-check
Open

        all_releases.store(name, versions) unless name.nil?
Severity: Minor
Found in lib/tasks/bosh/list_releases.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)

There are no issues that match your filters.

Category
Status