Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all remaining rubocop violations #241

Merged
merged 6 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/puppet/parser/functions/to_hash_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ module Puppet::Parser::Functions

raise(Puppet::ParseError, 'to_hash_settings(): Requires hash to work with') unless hash.is_a?(Hash)

return hash.reduce({}) do |acc, kv|
return hash.each_with_object({}) do |kv, acc|
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually have a spec test for this function, and it still passes! Yay!

acc[id + kv[0]] = { 'key' => kv[0], 'value' => kv[1] }
acc
end
end
end
34 changes: 13 additions & 21 deletions lib/puppet/provider/package/pear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,17 @@ def self.pearlist(hash)
begin
list = execute(command).split("\n")
list = list.map do |set|
if match = %r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) # rubocop:disable Lint/AssignmentInCondition
channel = match[1].downcase
%r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) { |m| channel = m[1].downcase }

if hash[:justme] && set =~ %r{^#{hash[:justme]}}
pearhash = pearsplit(set, channel)
pearhash[:provider] = :pear
pearhash
elsif (pearhash = pearsplit(set, channel))
pearhash[:provider] = :pear
pearhash
end

if hash[:justme]
if set =~ %r{^#{hash[:justme]}}
pearhash = pearsplit(set, channel)
pearhash[:provider] = :pear
pearhash
end
else
if pearhash = pearsplit(set, channel) # rubocop:disable Lint/AssignmentInCondition
pearhash[:provider] = :pear
pearhash
end
end
end.reject { |p| p.nil? }
end.compact

rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, format('Could not list pears: %s', detail)
Expand Down Expand Up @@ -87,12 +81,10 @@ def install(useversion = true)

command << if @resource[:source]
@resource[:source]
elsif ([email protected](:ensure).is_a? Symbol) && useversion
"#{@resource[:name]}-#{@resource.should(:ensure)}"
else
if ([email protected](:ensure).is_a? Symbol) && useversion
"#{@resource[:name]}-#{@resource.should(:ensure)}"
else
@resource[:name]
end
@resource[:name]
end

pearcmd(*command)
Expand Down
30 changes: 11 additions & 19 deletions lib/puppet/provider/package/pecl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ def self.pecllist(hash)

begin
list = execute(command).split("\n").map do |set|
if hash[:justme]
if %r{^#{hash[:justme]}$}i.match(set)
if peclhash = peclsplit(set) # rubocop:disable Lint/AssignmentInCondition
peclhash[:provider] = :peclcmd
peclhash
end
end
else
if peclhash = peclsplit(set) # rubocop:disable Lint/AssignmentInCondition
peclhash[:provider] = :peclcmd
peclhash
end
if hash[:justme] && %r{^#{hash[:justme]}$}i =~ set && (peclhash = peclsplit(set))
peclhash[:provider] = :peclcmd
peclhash
elsif (peclhash = peclsplit(set))
peclhash[:provider] = :peclcmd
peclhash
end
end.reject { |p| p.nil? }
end.compact
rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, format('Could not list pecls: %s', detail)
end
Expand Down Expand Up @@ -79,13 +73,11 @@ def install(useversion = true)

if @resource[:source]
command << @resource[:source]
elsif ([email protected](:ensure).is_a? Symbol) && useversion
command << '-f'
command << "#{peclname}-#{@resource.should(:ensure)}"
else
if ([email protected](:ensure).is_a? Symbol) && useversion
command << '-f'
command << "#{peclname}-#{@resource.should(:ensure)}"
else
command << peclname
end
command << peclname
end

if pipe == @resource[:pipe]
Expand Down