Showing 509 of 509 total issues
Line is too long. [123/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
description "Platform for analyzing large data sets that consists of a high-level language for expressing data algorithms."
- Create a ticketCreate a ticket
- Exclude checks
The name of this source file (fair-scheduler.rb
) should use snake_case. (https://github.com/bbatsov/ruby-style-guide#snake-case-files) Open
#
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
The name of this source file (node-setup.rb
) should use snake_case. (https://github.com/bbatsov/ruby-style-guide#snake-case-files) Open
#
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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 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
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
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
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 ha_filer_active
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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?
%w
-literals should be delimited by [
and ]
. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces) Open
lock_list=%w{
/etc/passwd.lock
/etc/shadow.lock
/etc/group.lock
/etc/gshadow.lock
- 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)
Line is too long. [106/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
default[:hadoop][:mapred][:mapred_output_compression_codec] = "org.apache.hadoop.io.compress.DefaultCodec"
- Create a ticketCreate a ticket
- Exclude checks
Use !
instead of not
. (https://github.com/bbatsov/ruby-style-guide#bang-not-not) Open
if not File.exists?(target_dev)
- 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
Line is too long. [128/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
new_buff = cur_buff.gsub(/^[\t ]*echo\s*(.+?)\s*>\s*\/sys\/kernel\/mm\/redhat_transparent_hugepage\/defrag[\t ]*$/, rep_str)
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [106/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
node_rec = { fqdn: n[:fqdn], ipaddr: ipaddr, name: n.name, ssh_key: ssh_key, hdfs_mounts: hdfs_mounts}
- Create a ticketCreate a ticket
- Exclude checks
Use !
instead of not
. (https://github.com/bbatsov/ruby-style-guide#bang-not-not) 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 keyword not
instead of !
.
Example:
# bad - parentheses are required because of op precedence
x = (not something)
# good
x = !something
File.exists?
is deprecated in favor of File.exist?
. Open
if File.exists?(lock_file)
- 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)
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
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 stat and stat.exited? and stat.exitstatus == 0
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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?
Use &&
instead of and
. (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")
- 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 []
for an array of words. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylewordarray) Open
lock_list=%w{
/etc/passwd.lock
/etc/shadow.lock
/etc/group.lock
/etc/gshadow.lock
- 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 &&
instead of and
. (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")
- 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 %r
around regular expression. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#styleregexpliteral) Open
thp_array = cur_buff.scan /^[\t ]*echo\s*(.+?)\s*>\s*\/sys\/kernel\/mm\/redhat_transparent_hugepage\/defrag[\t ]*$/m
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop enforces using // or %r around regular expressions.
Example: EnforcedStyle: slashes (default)
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = %r{
foo
(bar)
(baz)
}x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = /
foo
(bar)
(baz)
/x
Example: EnforcedStyle: percent_r
# bad
snake_case = /^[\dA-Z_]+$/
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = %r{^[\dA-Z_]+$}
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: EnforcedStyle: mixed
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: AllowInnerSlashes: false (default)
# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.
# bad
x =~ /home\//
# good
x =~ %r{home/}
Example: AllowInnerSlashes: true
# good
x =~ /home\//