cloudamatic/mu

View on GitHub

Showing 2,704 of 2,705 total issues

end at 100, 8 is not aligned with if at 90, 14.
Open

        end
Severity: Minor
Found in modules/mu/groomers/ansible.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 longrole.match(/\.#{Regexp.quote(role)}$/)
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 each_value instead of values.each.
Open

                deploy.deployment["databases"][dep['name']].values.each { |database|
Severity: Minor
Found in modules/mu/groomers/chef.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 }

File.exists? is deprecated in favor of File.exist?.
Open

            if !File.exists?(batch['source'])
Severity: Minor
Found in modules/mu/config/bucket.rb by rubocop

This cop checks for uses of the deprecated class method usages.

Example:

# bad

File.exists?(some_path)

Example:

# good

File.exist?(some_path)

Unused method argument - args. If it's necessary, use _ or _args as an argument name to indicate that it won't be used. You can also write as find(*) if you want the method to accept any arguments but don't care about them.
Open

        def self.find(*args)

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Redundant use of Object#to_s in interpolation.
Open

            MU.log "#{@server.mu_name}: Knife Bootstrap failed #{e.inspect}, retrying in #{(10*retries).to_s}s (#{retries} of #{max_retries})", MU::WARN, details: e.backtrace
Severity: Minor
Found in modules/mu/groomers/chef.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}"

Dir.exists? is deprecated in favor of Dir.exist?.
Open

              if !File.readable?(function['code'][src]) and !Dir.exists?(function['code'][src])
Severity: Minor
Found in modules/mu/config/function.rb by rubocop

This cop checks for uses of the deprecated class method usages.

Example:

# bad

File.exists?(some_path)

Example:

# good

File.exist?(some_path)

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

          MU.log "Parameter '#{param}' (#{param.class.name}) referenced in config but not provided (#{caller[0]})", MU::DEBUG, details: @@parameters
Severity: Minor
Found in modules/mu/config/tail.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

Redundant use of Object#to_s in interpolation.
Open

                  newref.instance_variable_set("@#{field.to_s}".to_sym, cfg[field])
Severity: Minor
Found in modules/mu/config/ref.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 =~ in places where the MatchData returned by #match will not be used.
Open

              if output.match(/InProgress/)
Severity: Minor
Found in modules/mu/cloud/ssh_sessions.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'

Prefer using YAML.safe_load over YAML.load.
Open

                images.deep_merge!(YAML.load(response))
Severity: Minor
Found in modules/mu/cloud/machine_images.rb by rubocop

This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

Example:

# bad
YAML.load("--- foo")

# good
YAML.safe_load("--- foo")
YAML.dump("foo")

Prefer using YAML.safe_load over YAML.load.
Open

            images.deep_merge!(YAML.load(File.read("#{basepath}/#{file}.yaml")))
Severity: Minor
Found in modules/mu/cloud/machine_images.rb by rubocop

This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

Example:

# bad
YAML.load("--- foo")

# good
YAML.safe_load("--- foo")
YAML.dump("foo")

Useless assignment to variable - e.
Open

            rescue Psych::SyntaxError => e
Severity: Minor
Found in modules/mu/groomers/ansible.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

Do not suppress exceptions.
Open

          rescue Net::HTTPServerException
Severity: Minor
Found in modules/mu/groomers/chef.rb by rubocop

This cop checks for rescue blocks with no body.

Example:

# bad

def some_method
  do_something
rescue
  # do nothing
end

Example:

# bad

begin
  do_something
rescue
  # do nothing
end

Example:

# good

def some_method
  do_something
rescue
  handle_exception
end

Example:

# good

begin
  do_something
rescue
  handle_exception
end

Do not suppress exceptions.
Open

          rescue Net::HTTPServerException
Severity: Minor
Found in modules/mu/groomers/chef.rb by rubocop

This cop checks for rescue blocks with no body.

Example:

# bad

def some_method
  do_something
rescue
  # do nothing
end

Example:

# bad

begin
  do_something
rescue
  # do nothing
end

Example:

# good

def some_method
  do_something
rescue
  handle_exception
end

Example:

# good

begin
  do_something
rescue
  handle_exception
end

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

            elsif entry.match(/^recipe\[(.+?)\]/)
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'

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

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

Unused method argument - ingress.
Open

        def setRules(rules, add_to_self: false, ingress: true, egress: false)

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

end at 110, 14 is not aligned with if at 106, 25.
Open

              end
Severity: Minor
Found in modules/mu/cloud/wrappers.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

              MU.log "Munging #{cloud}-specific #{classname.to_s} schema into BasketofKittens => #{attrs[:cfg_plural]} => #{key}", MU::DEBUG, details: docschema["properties"][attrs[:cfg_plural]]["items"]["properties"][key]
Severity: Minor
Found in modules/mu/config/doc_helpers.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}"
Severity
Category
Status
Source
Language