Showing 509 of 509 total issues
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem codeclimate-test-reporter
should appear before coveralls
. Open
gem "codeclimate-test-reporter", require: false
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Use __dir__
to get an absolute path to the current file's directory. Open
require File.join(File.expand_path(File.dirname(__FILE__)), "barclamp_lib")
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for places where the #__dir__
method can replace more
complex constructs to retrieve a canonicalized absolute path to the
current file.
Example:
# bad
path = File.expand_path(File.dirname(__FILE__))
# bad
path = File.dirname(File.realpath(__FILE__))
# good
path = __dir__
Line is too long. [163/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
export << I18n.t(".barclamp.hadoop_infrastructure.nodes.datanodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
- Create a ticketCreate a ticket
- Exclude checks
1 trailing blank lines detected. (https://github.com/bbatsov/ruby-style-guide#newline-eof) Open
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [104/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
system("for f in `find -name \*.rb`; do echo -n \"Syntaxcheck $f: \"; ruby -c $f || exit $? ; done")
- Create a ticketCreate a ticket
- Exclude checks
Use __dir__
to get an absolute path to the current file's directory. Open
require File.join(File.expand_path(File.dirname(__FILE__)), "barclamp_lib")
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for places where the #__dir__
method can replace more
complex constructs to retrieve a canonicalized absolute path to the
current file.
Example:
# bad
path = File.expand_path(File.dirname(__FILE__))
# bad
path = File.dirname(File.realpath(__FILE__))
# good
path = __dir__
Carriage return character detected. (https://github.com/bbatsov/ruby-style-guide#crlf) Open
#
# Cookbook Name: sqoop
- Create a ticketCreate a ticket
- Exclude checks
1 trailing blank lines detected. (https://github.com/bbatsov/ruby-style-guide#newline-eof) Open
- Create a ticketCreate a ticket
- Exclude checks
Use __dir__
to get an absolute path to the current file's directory. Open
require File.join(File.expand_path(File.dirname(__FILE__)), "barclamp_lib")
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for places where the #__dir__
method can replace more
complex constructs to retrieve a canonicalized absolute path to the
current file.
Example:
# bad
path = File.expand_path(File.dirname(__FILE__))
# bad
path = File.dirname(File.realpath(__FILE__))
# good
path = __dir__
Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem sprockets
should appear before sprockets-standalone
. Open
gem "sprockets", "~> 2.11.0"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Gems should be alphabetically sorted within groups.
Example:
# bad
gem 'rubocop'
gem 'rspec'
# good
gem 'rspec'
gem 'rubocop'
# good
gem 'rubocop'
gem 'rspec'
# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'
Use next
to skip iteration. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals) Open
if !x[:fqdn].nil? && !x[:fqdn].empty?
- 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
Use !empty?
instead of length > 0
. Open
if !slave_fqdns.nil? && slave_fqdns.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?
Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation) Open
headers["Content-Disposition"] = "attachment; filename=\"#{I18n.t('nodes.dell.nodes.filename', default: 'hadoop_infrastructure_inventory.txt')}\""
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Line is too long. [166/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
export << I18n.t(".barclamp.hadoop_infrastructure.nodes.hafilernodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
- Create a ticketCreate a ticket
- Exclude checks
Surrounding space missing for operator +
. (https://github.com/bbatsov/ruby-style-guide#spaces-operators) Open
node_cnt = node_cnt +1
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Line is too long. [164/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
export << I18n.t(".barclamp.hadoop_infrastructure.nodes.adminnodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
- Create a ticketCreate a ticket
- Exclude checks
Do not suppress exceptions. (https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions) Open
rescue
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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
Line is too long. [103/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
edge_nodes = nodes.find_all { |n| n.role? "hadoop-edgenode" or n.role? "clouderamanager-edgenode" }
- Create a ticketCreate a ticket
- Exclude checks
Use ||
instead of or
. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or) Open
edge_nodes = nodes.find_all { |n| n.role? "hadoop-edgenode" or n.role? "clouderamanager-edgenode" }
- 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
Line is too long. [165/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength) Open
export << I18n.t(".barclamp.hadoop_infrastructure.nodes.servernodes") + ", #{node.ip}, #{node.name}, #{node.cpu}, #{node.memory}, #{node.number_of_drives}"
- Create a ticketCreate a ticket
- Exclude checks