crowbar/crowbar-hadoop

View on GitHub

Showing 509 of 509 total issues

Use array literal [] instead of Array.new. (https://github.com/bbatsov/ruby-style-guide#literal-array-hash)
Open

servers = Array.new

This cop checks for the use of a method, the result of which would be a literal, like an empty array, hash or string.

Example:

# bad
a = Array.new
h = Hash.new
s = String.new

# good
a = []
h = {}
s = ''

Use 0o for octal literals. (https://github.com/bbatsov/ruby-style-guide#numeric-literal-prefixes)
Open

  mode 0644

This cop checks for octal, hex, binary and decimal literals using uppercase prefixes and corrects them to lowercase prefix or no prefix (in case of decimals). eg. for octal use 0o instead of 0 or 0O.

Can be configured to use 0 only for octal literals using EnforcedOctalStyle => zero_only

Use 0o for octal literals. (https://github.com/bbatsov/ruby-style-guide#numeric-literal-prefixes)
Open

  mode 0644

This cop checks for octal, hex, binary and decimal literals using uppercase prefixes and corrects them to lowercase prefix or no prefix (in case of decimals). eg. for octal use 0o instead of 0 or 0O.

Can be configured to use 0 only for octal literals using EnforcedOctalStyle => zero_only

Line is too long. [108/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

recipe "hadoop::secondarynamenode", "Installs the secondary name node package and prepares the file system."
Severity: Minor
Found in chef/cookbooks/hadoop/metadata.rb by rubocop

The name of this source file (mapred-site.rb) should use snake_case. (https://github.com/bbatsov/ruby-style-guide#snake-case-files)
Open

#

This cop makes sure that Ruby source files have snake_case names. Ruby scripts (i.e. source files with a shebang in the first line) are ignored.

Example:

# bad
lib/layoutManager.rb

anything/usingCamelCase

# good
lib/layout_manager.rb

anything/using_snake_case.rake

Space missing after comma. (https://github.com/bbatsov/ruby-style-guide#spaces-operators)
Open

    ipaddr = BarclampLibrary::Barclamp::Inventory.get_network_by_type(n,"admin").address

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
Open

thp_array = cur_buff.scan /^[\t ]*echo\s*(.+?)\s*>\s*\/sys\/kernel\/mm\/redhat_transparent_hugepage\/defrag[\t ]*$/m

This cop checks for ambiguous regexp literals in the first argument of a method invocation without parentheses.

Example:

# bad

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

Example:

# good

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. (https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier)
Open

if File.exists?(rc_local_path)

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

The name of this source file (hadoop-setup.rb) should use snake_case. (https://github.com/bbatsov/ruby-style-guide#snake-case-files)
Open

#

This cop makes sure that Ruby source files have snake_case names. Ruby scripts (i.e. source files with a shebang in the first line) are ignored.

Example:

# bad
lib/layoutManager.rb

anything/usingCamelCase

# good
lib/layout_manager.rb

anything/using_snake_case.rake

Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
Open

  unless v.nil? or v.empty?

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Avoid using rescue in its modifier form. (https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers)
Open

    key = n[:ssh_key] rescue nil

This cop checks for uses of rescue in its modifier form.

Example:

# bad
some_method rescue handle_error

# good
begin
  some_method
rescue
  handle_error
end

Carriage return character detected. (https://github.com/bbatsov/ruby-style-guide#crlf)
Open

#
# Cookbook Name: hive

Line is too long. [108/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

search(:node, "roles:zookeeper-server AND zookeeper_cluster_name:#{node[:zookeeper][:cluster_name]}") do |n|

Use self-assignment shorthand +=. (https://github.com/bbatsov/ruby-style-guide#self-assignment)
Open

  myid = myid + 1 if !myid.nil?

This cop enforces the use the shorthand for self-assignment.

Example:

# bad
x = x + 1

# good
x += 1

Use next to skip iteration. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals)
Open

    if !is_ok

Use next to skip iteration instead of a condition at the end.

Example: EnforcedStyle: skipmodifierifs (default)

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

# good
[1, 2].each do |o|
  puts o unless o == 1
end

Example: EnforcedStyle: always

# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like
# this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`

# bad
[1, 2].each do |o|
  puts o unless o == 1
end

# bad
[1, 2].each do |a|
  if a == 1
    puts a
  end
end

# good
[1, 2].each do |a|
  next unless a == 1
  puts a
end

Surrounding space missing for operator =. (https://github.com/bbatsov/ruby-style-guide#spaces-operators)
Open

  xfs_packages=%w{

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
Open

if (cur_thpval == "never" and cur_buff != "always [never]") or (cur_thpval == "always" and cur_buff != "[always] never")

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Use && instead of and. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
Open

  if n[:fqdn] and not n[:fqdn].empty?

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Line is too long. [106/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)
Open

  new_lines = "#{shared_edits_directory} #{admin_subnet}/#{admin_netmask}(#{shared_edits_export_options})"

Use ! instead of not. (https://github.com/bbatsov/ruby-style-guide#bang-not-not)
Open

if not File.exists?(shared_edits_directory)

This cop checks for uses of the keyword not instead of !.

Example:

# bad - parentheses are required because of op precedence
x = (not something)

# good
x = !something
Severity
Category
Status
Source
Language