pietervogelaar/chef-cookbook-jenkins-server

View on GitHub
recipes/plugins.rb

Summary

Maintainability
A
0 mins
Test Coverage

Block has too many lines. [34/25]
Open

node['jenkins-server']['plugins'].each do |plugin, options|
  if options
    jenkins_plugin plugin do
      version options['version']
    end
Severity: Minor
Found in recipes/plugins.rb by rubocop

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

end
Severity: Minor
Found in recipes/plugins.rb by rubocop

Use next to skip iteration.
Open

  if options
Severity: Minor
Found in recipes/plugins.rb by rubocop

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

        Chef::Log.debug "No template found for source \"#{template_source}\" in cookbook \"#{template_cookbook}\""
Severity: Minor
Found in recipes/plugins.rb by rubocop

Line is too long. [101/80]
Open

  if !options['configure'].nil? && (options['configure'] == true || options['configure'] == 'recipe')
Severity: Minor
Found in recipes/plugins.rb by rubocop

Line is too long. [109/80]
Open

    cookbook = options.key?('cookbook') && !options['cookbook'].nil? ? options['cookbook'] : 'jenkins-server'
Severity: Minor
Found in recipes/plugins.rb by rubocop

Use next to skip iteration.
Open

  if !options['configure'].nil? && (options['configure'] == true || options['configure'] == 'recipe')
Severity: Minor
Found in recipes/plugins.rb by rubocop

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

    recipe = options.key?('recipe') && !options['recipe'].nil? ? options['recipe'] : "plugin_#{plugin}"
Severity: Minor
Found in recipes/plugins.rb by rubocop

Favor modifier unless usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

  unless Chef::Config[:solo]
Severity: Minor
Found in recipes/plugins.rb by rubocop

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?

There are no issues that match your filters.

Category
Status