cloudamatic/mu

View on GitHub

Showing 2,704 of 2,705 total issues

Use each_value instead of values.each.
Open

          images.values.each { |regions|
Severity: Minor
Found in modules/mu/cloud/machine_images.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 }

end at 481, 8 is not aligned with if at 477, 15.
Open

        end
Severity: Minor
Found in modules/mu/config/doc_helpers.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 caller(2..2).first instead of caller[1].
Open

        parent_obj ||= caller[1].gsub(/.*?\/([^\.\/]+)\.rb:.*/, '\1')
Severity: Minor
Found in modules/mu/config/ref.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

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 cleanup(*) if you want the method to accept any arguments but don't care about them.
Open

        def self.cleanup(*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

When defining the == operator, name its argument other.
Open

      def ==(o)
Severity: Minor
Found in modules/mu/config/tail.rb by rubocop

This cop makes sure that certain binary operator methods have their sole parameter named other.

Example:

# bad
def +(amount); end

# good
def +(other); end

Redundant use of Object#to_s in interpolation.
Open

            self.instance_variable_set("@#{field.to_s}".to_sym, cfg[field.to_sym])
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}"

Unused method argument - egress.
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

Do not shadow rescued Exceptions.
Open

      rescue LoadError, Gem::MissingSpecError => e
Severity: Minor
Found in modules/mu/cloud/providers.rb by rubocop

This cop checks for a rescued exception that get shadowed by a less specific exception being rescued before a more specific exception is rescued.

Example:

# bad

begin
  something
rescue Exception
  handle_exception
rescue StandardError
  handle_standard_error
end

# good

begin
  something
rescue StandardError
  handle_standard_error
rescue Exception
  handle_exception
end

# good, however depending on runtime environment.
#
# This is a special case for system call errors.
# System dependent error code depends on runtime environment.
# For example, whether `Errno::EAGAIN` and `Errno::EWOULDBLOCK` are
# the same error code or different error code depends on environment.
# This good case is for `Errno::EAGAIN` and `Errno::EWOULDBLOCK` with
# the same error code.
begin
  something
rescue Errno::EAGAIN, Errno::EWOULDBLOCK
  handle_standard_error
end

Do not suppress exceptions.
Open

        rescue Errno::ENOTDIR
Severity: Minor
Found in modules/mu/groomers/ansible.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

Redundant use of Object#to_s in interpolation.
Open

            MU.log "Failed Ansible run, will retry (#{retries.to_s}/#{max_retries.to_s})", MU::NOTICE, details: cmd
Severity: Minor
Found in modules/mu/groomers/ansible.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}"

Redundant use of Object#to_s in interpolation.
Open

            MU.log "Failed Ansible run, will retry (#{retries.to_s}/#{max_retries.to_s})", MU::NOTICE, details: cmd
Severity: Minor
Found in modules/mu/groomers/ansible.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}"

Prefer using YAML.safe_load over YAML.load.
Open

              data = YAML.load(a)
Severity: Minor
Found in modules/mu/groomers/ansible.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")

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

                if data.match(/#{error_signal}/)
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'

Redundant use of Object#to_s in interpolation.
Open

              ext_value = ref.instance_variable_get("@#{field.to_s}".to_sym)
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}"

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

Do not suppress exceptions.
Open

        rescue NameError
Severity: Minor
Found in modules/mu/cloud/providers.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

When defining the + operator, name its argument other.
Open

      def +(o)
Severity: Minor
Found in modules/mu/config/tail.rb by rubocop

This cop makes sure that certain binary operator methods have their sole parameter named other.

Example:

# bad
def +(amount); end

# good
def +(other); end

end at 749, 8 is not aligned with if at 737, 18.
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)

Use each_key instead of keys.each.
Open

    @@resource_types.keys.each { |name|
Severity: Minor
Found in modules/mu/cloud/wrappers.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 }

Prefer using YAML.safe_load over YAML.load.
Open

          images.deep_merge!(YAML.load(File.read("#{MU.etcDir}/#{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")
Severity
Category
Status
Source
Language