Showing 509 of 509 total issues
Space missing after comma. (https://github.com/bbatsov/ruby-style-guide#spaces-operators) Open
keys.each do |k,v|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Use meaningful heredoc delimiters. (https://github.com/bbatsov/ruby-style-guide#heredoc-delimiters) Open
EOH
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Avoid using rescue
in its modifier form. (https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers) Open
key = n[:ssh_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
Avoid using rescue
in its modifier form. (https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers) Open
key = n[:ssh_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
Use []
for an array of words. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylewordarray) Open
hive_packages=%w{
hive
hive-metastore
hive-server2
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop can check for array literals made up of word-like strings, that are not using the %w() syntax.
Alternatively, it can check for uses of the %w() syntax, in projects which do not want to include that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize
of 3
will not enforce a style on an
array of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%w[foo bar baz]
# bad
['foo', 'bar', 'baz']
Example: EnforcedStyle: brackets
# good
['foo', 'bar', 'baz']
# bad
%w[foo bar baz]
Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is. Open
ipaddress: ipaddress,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.
By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.
Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.
This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:
Example: EnforcedStyle: specialinsideparentheses (default)
# The `special_inside_parentheses` style enforces that the first key
# in a hash literal where the opening brace and the first key are on
# separate lines is indented one step (two spaces) more than the
# position inside the opening parentheses.
# bad
hash = {
key: :value
}
and_in_a_method_call({
no: :difference
})
# good
special_inside_parentheses
hash = {
key: :value
}
but_in_a_method_call({
its_like: :this
})
Example: EnforcedStyle: consistent
# The `consistent` style enforces that the first key in a hash
# literal where the opening brace and the first key are on
# seprate lines is indented the same as a hash literal which is not
# defined inside a method call.
# bad
hash = {
key: :value
}
but_in_a_method_call({
its_like: :this
})
# good
hash = {
key: :value
}
and_in_a_method_call({
no: :difference
})
Example: EnforcedStyle: align_braces
# The `align_brackets` style enforces that the opening and closing
# braces are indented to the same position.
# bad
and_now_for_something = {
completely: :different
}
# good
and_now_for_something = {
completely: :different
}
Space missing after comma. (https://github.com/bbatsov/ruby-style-guide#spaces-operators) Open
ipaddress = BarclampLibrary::Barclamp::Inventory.get_network_by_type(n,"admin").address
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Use 0o for octal literals. (https://github.com/bbatsov/ruby-style-guide#numeric-literal-prefixes) Open
mode 0644
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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. [107/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
default[:hadoop][:mapred][:mapreduce_jobtracker_staging_root_dir] = "/mnt/hdfs/hdfs01/data1/mapred/staging"
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [113/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
default[:hadoop][:core][:hadoop_rpc_socket_factory_class_default] = "org.apache.hadoop.net.StandardSocketFactory"
- Create a ticketCreate a ticket
- Exclude checks
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
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Use !
instead of not
. (https://github.com/bbatsov/ruby-style-guide#bang-not-not) Open
if n[:fqdn] and not n[:fqdn].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 not
. (https://github.com/bbatsov/ruby-style-guide#bang-not-not) Open
if n[:fqdn] and not n[:fqdn].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
Favor unless
over if
for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives) Open
if not File.exists?(target_dev)
Chef::Log.warn("HI - device: #{target_dev} doesn't seem to exist. ignoring")
next
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
Avoid using rescue
in its modifier form. (https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers) Open
ssh_key = n[: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
File.exists?
is deprecated in favor of File.exist?
. Open
if not File.exists?(shared_edits_directory)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for uses of the deprecated class method usages.
Example:
# bad
File.exists?(some_path)
Example:
# good
File.exist?(some_path)
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
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
%w
-literals should be delimited by [
and ]
. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces) Open
nfs_packages=%w{
nfs-utils
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop enforces the consistent usage of %
-literal delimiters.
Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.
Example:
# Style/PercentLiteralDelimiters:
# PreferredDelimiters:
# default: '[]'
# '%i': '()'
# good
%w[alpha beta] + %i(gamma delta)
# bad
%W(alpha #{beta})
# bad
%I(alpha beta)
Use &&
instead of and
. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or) Open
if n[:fqdn] and not n[:fqdn].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
Use !
instead of not
. (https://github.com/bbatsov/ruby-style-guide#bang-not-not) Open
if not new_buff.nil?
- 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