cloudamatic/mu

View on GitHub

Showing 2,704 of 2,705 total issues

Useless assignment to variable - bucket. Did you mean bucketobj?
Open

      bucket = MU::Cloud::Google.storage(credentials: credset).get_bucket(bucketname)
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

Use meaningful heredoc delimiters.
Open

  EOS
Severity: Minor
Found in bin/mu-tunnel-nagios 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

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

    MU::Cloud.resource_types.each_pair { |type, cfg|
Severity: Minor
Found in bin/mu-gen-docs 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

Do not suppress exceptions.
Open

  rescue OpenURI::HTTPError, Timeout::Error, SocketError, Errno::ENETUNREACH
Severity: Minor
Found in bin/mu-configure 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

(...) interpreted as grouped expression.
Open

    puts (desc['required'] ? "REQUIRED".red.on_black : "OPTIONAL".yellow.on_black)+" - "+desc["desc"]
Severity: Minor
Found in bin/mu-configure by rubocop

Checks for space between the name of a called method and a left parenthesis.

Example:

# bad

puts (x + y)

Example:

# good

puts(x + y)

Avoid more than 4 levels of block nesting.
Open

                cfg[key][name][subkey] = subdata['value'] if subdata['value']
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.

Use delete instead of gsub.
Open

    chefuser = user.gsub(/\./, "")
Severity: Minor
Found in bin/mu-configure by rubocop

This cop identifies places where gsub can be replaced by tr or delete.

Example:

# bad
'abc'.gsub('b', 'd')
'abc'.gsub('a', '')
'abc'.gsub(/a/, 'd')
'abc'.gsub!('a', 'd')

# good
'abc'.gsub(/.*/, 'a')
'abc'.gsub(/a+/, 'd')
'abc'.tr('b', 'd')
'a b c'.delete(' ')

Prefer using YAML.safe_load over YAML.load.
Open

    localfile = YAML.load(File.read("#{home}/.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")

Use meaningful heredoc delimiters.
Open

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

end at 58, 2 is not aligned with if at 54, 12.
Open

  end
Severity: Minor
Found in bin/mu-ansible-secret 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)

Do not suppress exceptions.
Open

  rescue OpenURI::HTTPError, Timeout::Error, SocketError, Errno::ENETUNREACH
Severity: Minor
Found in bin/mu-configure 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 SocketError
Severity: Minor
Found in bin/mu-configure 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

Useless assignment to variable - optlist.
Open

      optlist = displayCurrentOpts(tree)
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

              $CHANGES.concat(subdata['changes']) if subdata['changes']
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.

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'

Unused method argument - noop.
Open

def runCommand(deploys = MU::MommaCat.listDeploys, nodes = [], cmd = nil, print_output: $opts[:verbose], noop: false)
Severity: Minor
Found in bin/mu-node-manage by rubocop

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

Avoid more than 4 levels of block nesting.
Open

                puts resp.stderr if resp.stderr
Severity: Minor
Found in bin/mu-node-manage 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.

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

  if File.exists?("/opt/opscode/bin/chef-server-ctl")
Severity: Minor
Found in bin/mu-gcp-setup 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 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 - preferred_ip.
Open

  preferred_ip = MU.mu_public_ip
Severity: Minor
Found in bin/mu-azure-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
Severity
Category
Status
Source
Language