recipes/plugins.rb
Block has too many lines. [34/25] Open
Open
node['jenkins-server']['plugins'].each do |plugin, options|
if options
jenkins_plugin plugin do
version options['version']
end
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Final newline missing. Open
Open
end
- Exclude checks
Use next
to skip iteration. Open
Open
if options
- Read upRead up
- 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
Line is too long. [114/80] Open
Open
Chef::Log.debug "No template found for source \"#{template_source}\" in cookbook \"#{template_cookbook}\""
- Exclude checks
Line is too long. [101/80] Open
Open
if !options['configure'].nil? && (options['configure'] == true || options['configure'] == 'recipe')
- Exclude checks
Line is too long. [109/80] Open
Open
cookbook = options.key?('cookbook') && !options['cookbook'].nil? ? options['cookbook'] : 'jenkins-server'
- Exclude checks
Use next
to skip iteration. Open
Open
if !options['configure'].nil? && (options['configure'] == true || options['configure'] == 'recipe')
- Read upRead up
- 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
Line is too long. [103/80] Open
Open
recipe = options.key?('recipe') && !options['recipe'].nil? ? options['recipe'] : "plugin_#{plugin}"
- Exclude checks
Favor modifier unless
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
Open
unless Chef::Config[:solo]
- Read upRead up
- 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?