cloudamatic/mu

View on GitHub

Showing 2,704 of 2,705 total issues

Avoid more than 4 levels of block nesting.
Open

              if fail_hard
                raise MuError, "No base image for platform #{platform} in cloud #{cloud} region #{region} found"
              else
                MU.log "No base image for platform #{platform} in cloud #{cloud} region #{region} found", MU::WARN if !quiet
                return nil
Severity: Minor
Found in modules/mu/cloud/machine_images.rb by rubocop

This cop checks for excessive nesting of conditional and looping constructs.

You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

The maximum level of nesting allowed is configurable.

Use =~ in places where the MatchData returned by #match will not be used.
Open

            repo.match(/\/([^\/]+?)(\.git)?$/)
Severity: Minor
Found in modules/mu/groomers/ansible.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

Use =~ in places where the MatchData returned by #match will not be used.
Open

              if path.match(/\/gems\/chef\-\d+\.\d+\.\d+\/lib$/)
Severity: Minor
Found in modules/mu/groomers/chef.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

Use =~ in places where the MatchData returned by #match will not be used.
Open

            if entry.match(/^role\[(.+?)\]/)
Severity: Minor
Found in modules/mu/groomers/chef.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

Use each_key instead of keys.each.
Open

          cfg["properties"].keys.each { |key|
Severity: Minor
Found in modules/mu/config/doc_helpers.rb by rubocop

This cop checks for uses of each_key and each_value Hash methods.

Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Rename is_mu_type? to mu_type?.
Open

      def is_mu_type?
Severity: Minor
Found in modules/mu/config/ref.rb by rubocop

This cop makes sure that predicates are named properly.

Example:

# bad
def is_even?(value)
end

# good
def even?(value)
end

# bad
def has_value?
end

# good
def value?
end

unexpected token tCOMMA (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

            },
Severity: Minor
Found in modules/mu/config/database.rb by rubocop

Avoid more than 4 levels of block nesting.
Open

                  if my_cidr.rel(cidr_obj) != nil
                    can_peer = false
                  end
Severity: Minor
Found in modules/mu/config/vpc.rb by rubocop

This cop checks for excessive nesting of conditional and looping constructs.

You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

The maximum level of nesting allowed is configurable.

end at 207, 8 is not aligned with if at 200, 15.
Open

        end
Severity: Minor
Found in modules/mu/master/ssl.rb by rubocop

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

Use =~ in places where the MatchData returned by #match will not be used.
Open

        if "-".match(disallowed_chars)
Severity: Minor
Found in modules/mu/mommacat/naming.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

Redundant use of Object#to_s in interpolation.
Open

      backup = "#{deploy_dir}/basket_of_kittens.json.#{Time.now.to_i.to_s}"
Severity: Minor
Found in modules/mu/mommacat/storage.rb by rubocop

This cop checks for string conversion in string interpolation, which is redundant.

Example:

# bad

"result is #{something.to_s}"

Example:

# good

"result is #{something}"

Useless assignment to variable - deletia.
Open

        deletia = {}
Severity: Minor
Found in modules/mu/mommacat/storage.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Useless assignment to variable - grouping_options.
Open

grouping_options = {
Severity: Minor
Found in bin/mu-adopt by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

end at 776, 14 is not aligned with if at 756, 24.
Open

              end
Severity: Minor
Found in modules/mu/config/vpc.rb by rubocop

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

Redundant use of Object#to_s in interpolation.
Open

                raise MuLDAPError, "Failed to create user #{user} (#{getLDAPErr}) from add(:dn => #{user_dn}, :attributes => #{attr.to_s})"
Severity: Minor
Found in modules/mu/master/ldap.rb by rubocop

This cop checks for string conversion in string interpolation, which is redundant.

Example:

# bad

"result is #{something.to_s}"

Example:

# good

"result is #{something}"

Use casecmp instead of downcase ==.
Open

                if member.downcase == user or (!dn.nil? and member.downcase == dn.downcase)
Severity: Minor
Found in modules/mu/master/ldap.rb by rubocop

This cop identifies places where a case-insensitive string comparison can better be implemented using casecmp.

Example:

# bad
str.downcase == 'abc'
str.upcase.eql? 'ABC'
'abc' == str.downcase
'ABC'.eql? str.upcase
str.downcase == str.downcase

# good
str.casecmp('ABC').zero?
'abc'.casecmp(str).zero?

end at 307, 8 is not aligned with if at 304, 7.
Open

        end
Severity: Minor
Found in modules/mu/mommacat/daemon.rb by rubocop

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

Unused block argument - res_type. If it's necessary, use _ or _res_type as an argument name to indicate that it won't be used.
Open

      MU::Cloud.resource_types.each_pair { |res_type, attrs|
Severity: Minor
Found in modules/mu/mommacat/storage.rb by rubocop

This cop checks for unused block arguments.

Example:

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Example:

#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Use caller(2..2).first instead of caller[1].
Open

      raise MuError, "deploy_dir must get a deploy_id if called as class method (from #{caller[0]}; #{caller[1]})" if deploy_id.nil?
Severity: Minor
Found in modules/mu/mommacat/storage.rb by rubocop

This cop identifies places where caller[n] can be replaced by caller(n..n).first.

Example:

# bad
caller[1]
caller.first
caller_locations[1]
caller_locations.first

# good
caller(2..2).first
caller(1..1).first
caller_locations(2..2).first
caller_locations(1..1).first

Avoid more than 4 levels of block nesting.
Open

        if !instance.vpc_id.nil?
          MU::Cloud::AWS::Server.associateElasticIp(my_instance_id, ip: public_ip)
        else
          MU::Cloud::AWS::Server.associateElasticIp(my_instance_id, classic: true, ip: public_ip)
        end
Severity: Minor
Found in bin/mu-aws-setup by rubocop

This cop checks for excessive nesting of conditional and looping constructs.

You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

The maximum level of nesting allowed is configurable.

Severity
Category
Status
Source
Language