cloudamatic/mu

View on GitHub

Showing 2,704 of 2,705 total issues

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

        if e.message.match(/User data is limited to (\d+)/)
Severity: Minor
Found in bin/mu-node-manage 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 meaningful heredoc delimiters.
Open

  EOS
Severity: Minor
Found in bin/mu-gcp-setup by rubocop

This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

Example:

# good
<<-SQL
  SELECT * FROM foo
SQL

# bad
<<-END
  SELECT * FROM foo
END

# bad
<<-EOS
  SELECT * FROM foo
EOS

Useless assignment to variable - opts.
Open

  opts = Net::SSH::Config.for(dest_host, ["#{NAGIOS_HOME}/.ssh/config"])
Severity: Minor
Found in bin/mu-tunnel-nagios 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

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

    if File.exists?("#{CHEF_CTL}")
Severity: Minor
Found in bin/mu-configure 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 block argument - subkey. If it's necessary, use _ or _subkey as an argument name to indicate that it won't be used.
Open

          data["subtree"].each_pair { |subkey, subdata|
Severity: Minor
Found in bin/mu-configure 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

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

    tree.each_pair { |key, data|
Severity: Minor
Found in bin/mu-configure 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

Useless assignment to variable - data.
Open

          data = MU::Groomer::Chef.getSecret(vault: "mu_ldap", item: creds)
Severity: Minor
Found in bin/mu-configure 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

Avoid more than 4 levels of block nesting.
Open

              next if data['readonly']
Severity: Minor
Found in bin/mu-configure 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.

Redundant use of Object#to_s in interpolation.
Open

        puts "#{cmd} RETRY #{retries.to_s}".light_red
Severity: Minor
Found in bin/mu-run-tests 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 meaningful heredoc delimiters.
Open

  EOS
Severity: Minor
Found in bin/mu-run-tests by rubocop

This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

Example:

# good
<<-SQL
  SELECT * FROM foo
SQL

# bad
<<-END
  SELECT * FROM foo
END

# bad
<<-EOS
  SELECT * FROM foo
EOS

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

    if l.match(/^\s*#\s*clouds: (.*)/)
Severity: Minor
Found in bin/mu-run-tests 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

    elsif l.match(/^\s*#\s*groomers: (.*)/)
Severity: Minor
Found in bin/mu-run-tests 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

      default_cfg.merge!(YAML.load(File.read("/opt/mu/etc/mu.yaml")))
Severity: Minor
Found in bin/mu-load-config.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")

Do not suppress exceptions.
Open

          rescue Errno::ESRCH
Severity: Minor
Found in bin/mu-node-manage 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

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

            rescue Exception => e
              MU.log e.inspect, MU::ERR, details: e.backtrace
              exit 1
Severity: Minor
Found in bin/mu-node-manage by rubocop

This cop checks for rescue blocks targeting the Exception class.

Example:

# bad

begin
  do_something
rescue Exception
  handle_exception
end

Example:

# good

begin
  do_something
rescue ArgumentError
  handle_exception
end

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

      $children.each_pair { |pid, node|
Severity: Minor
Found in bin/mu-node-manage 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 =~ in places where the MatchData returned by #match will not be used.
Open

      if node.match(/#{Regexp.quote(pattern)}/i)
Severity: Minor
Found in bin/mu-node-manage 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

                puts "#{nodename} - #{output}" if output.match(/[^\s]/)
Severity: Minor
Found in bin/mu-node-manage 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'

Useless assignment to variable - ebs_key.
Open

    ebs_key = nil
Severity: Minor
Found in bin/mu-gcp-setup 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

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

rescue Exception => e
  Syslog.log(Syslog::LOG_NOTICE, "Tunnel failure for #{dest_host}:#{dest_port} from config #{NAGIOS_HOME}/.ssh/config, `#{full_cmd}`: #{e.inspect} **** #{output} **** ENV: #{envhash.to_s}")
  puts e
  to_return = 3
Severity: Minor
Found in bin/mu-tunnel-nagios by rubocop

This cop checks for rescue blocks targeting the Exception class.

Example:

# bad

begin
  do_something
rescue Exception
  handle_exception
end

Example:

# good

begin
  do_something
rescue ArgumentError
  handle_exception
end
Severity
Category
Status
Source
Language