Showing 509 of 509 total issues
Use 2 spaces for indentation in a heredoc by using some library(e.g. ActiveSupport's String#strip_heredoc
). (https://github.com/bbatsov/ruby-style-guide#squiggly-heredocs) Open
hadoop fs -mkdir /mapred
hadoop fs -mkdir /mapred/system
hadoop fs -chown #{mapred_owner}:#{hadoop_group} /mapred
hadoop fs -chown #{mapred_owner}:#{hadoop_group} /mapred/system
hadoop fs -chmod 0775 /mapred
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cops checks the indentation of the here document bodies. The bodies
are indented one step.
In Ruby 2.3 or newer, squiggly heredocs (<<~
) should be used. If you
use the older rubies, you should introduce some library to your project
(e.g. ActiveSupport, Powerpack or Unindent).
Note: When Metrics/LineLength
's AllowHeredoc
is false(not default),
this cop does not add any offenses for long here documents to
avoid Metrics/LineLength
's offenses.
Example:
# bad
<<-RUBY
something
RUBY
# good
# When EnforcedStyle is squiggly, bad code is auto-corrected to the
# following code.
<<~RUBY
something
RUBY
# good
# When EnforcedStyle is active_support, bad code is auto-corrected to
# the following code.
<<-RUBY.strip_heredoc
something
RUBY
Line is too long. [118/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
base["deployment"]["hadoop"]["elements"]["hadoop-secondarynamenode"] = secondary if secondary && !secondary.empty?
- Create a ticketCreate a ticket
- Exclude checks
Space missing to the left of {. Open
IO.popen("blkid -c /dev/null -s UUID -o value #{disk}"){ |f|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that block braces have or don't have a space before the opening brace depending on configuration.
Example:
# bad
foo.map{ |a|
a.bar.to_s
}
# good
foo.map { |a|
a.bar.to_s
}
Convert if
nested inside else
to elsif
. Open
Chef::Log.info("HADOOP : MASTER NAME NODE IP #{master_node_ip}") if debug
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
If the else
branch of a conditional consists solely of an if
node,
it can be combined with the else
to become an elsif
.
This helps to keep the nesting level from getting too deep.
Example:
# bad
if condition_a
action_a
else
if condition_b
action_b
else
action_c
end
end
# good
if condition_a
action_a
elsif condition_b
action_b
else
action_c
end
Pass &:nil?
as an argument to delete_if
instead of a block. Open
nodes.delete_if { |n| n.nil? }
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Use symbols as procs when possible.
Example:
# bad
something.map { |s| s.upcase }
# good
something.map(&:upcase)
Line is too long. [114/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
default[:hadoop][:core][:hadoop_security_group_mapping] = "org.apache.hadoop.security.ShellBasedUnixGroupsMapping"
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [109/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
Chef::Log.warn("HADOOP: #{disk[:name]} (#{disk[:uuid]}) was not created by configure-disks, ignoring.")
- Create a ticketCreate a ticket
- Exclude checks
Use next
to skip iteration. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals) Open
unless v.nil?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Pass &:nil?
as an argument to delete_if
instead of a block. Open
nodes.delete_if { |n| n.nil? }
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Use symbols as procs when possible.
Example:
# bad
something.map { |s| s.upcase }
# good
something.map(&:upcase)
Avoid using rescue
in its modifier form. (https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers) Open
keys[nslave.name] = nslave["crowbar"]["ssh"]["root_pub_key"] rescue nil
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Line is too long. [111/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
adminnodes = nodeswithroles.find_all { |n| n.roles.include?("hadoop_infrastructure-cb-adminnode" ) }
- Create a ticketCreate a ticket
- Exclude checks
Favor unless
over if
for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives) Open
if not datanodes.empty?
base["deployment"]["hadoop_infrastructure"]["elements"]["hadoop_infrastructure-datanode"] = datanodes
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Use !empty?
instead of length > 0
. Open
if master_name_nodes.length > 0
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.
Example:
# bad
[1, 2, 3].length == 0
0 == "foobar".length
array.length < 1
{a: 1, b: 2}.length != 0
string.length > 0
hash.size > 0
# good
[1, 2, 3].empty?
"foobar".empty?
array.empty?
!{a: 1, b: 2}.empty?
!string.empty?
!hash.empty?
Favor unless
over if
for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives) Open
if not hafilernodes.empty?
base["deployment"]["hadoop_infrastructure"]["elements"]["hadoop_infrastructure-ha-filernode"] = hafilernodes
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Space inside parentheses detected. (https://github.com/bbatsov/ruby-style-guide#spaces-braces) Open
servernodes = nodeswithroles.find_all { |n| n.roles.include?("hadoop_infrastructure-server" ) }
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Use !
instead of not
. (https://github.com/bbatsov/ruby-style-guide#bang-not-not) Open
if not adminnodes.empty?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Use ||
instead of or
. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or) Open
next if tnodes.nil? or tnodes.empty?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Favor unless
over if
for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives) Open
if not servernodes.empty?
base["deployment"]["hadoop_infrastructure"]["elements"]["hadoop_infrastructure-server"] = servernodes
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end
Space inside empty hash literal braces detected. (https://github.com/bbatsov/ruby-style-guide#spaces-operators) Open
base["deployment"]["sqoop"]["elements"] = { }
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks that braces used for hash literals have or don't have surrounding space depending on configuration.
Example: EnforcedStyle: space
# The `space` style enforces that hash literals have
# surrounding space.
# bad
h = {a: 1, b: 2}
# good
h = { a: 1, b: 2 }
Example: EnforcedStyle: no_space
# The `no_space` style enforces that hash literals have
# no surrounding space.
# bad
h = { a: 1, b: 2 }
# good
h = {a: 1, b: 2}
Example: EnforcedStyle: compact
# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.
# bad
h = { a: { b: 2 } }
# good
h = { a: { b: 2 }}
Favor unless
over if
for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives) Open
if not hajournalingnodes.empty?
base["deployment"]["hadoop_infrastructure"]["elements"]["hadoop_infrastructure-ha-journalingnode"] = hajournalingnodes
end
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:
- both
- prefix
- postfix
Example: EnforcedStyle: both (default)
# enforces `unless` for `prefix` and `postfix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# bad
bar if !foo
# good
bar unless foo
Example: EnforcedStyle: prefix
# enforces `unless` for just `prefix` conditionals
# bad
if !foo
bar
end
# good
unless foo
bar
end
# good
bar if !foo
Example: EnforcedStyle: postfix
# enforces `unless` for just `postfix` conditionals
# bad
bar if !foo
# good
bar unless foo
# good
if !foo
bar
end