From 6e4c49d512272fcfe363867bcc82943168ac0361 Mon Sep 17 00:00:00 2001 From: Jorie Tappa Date: Wed, 1 Aug 2018 16:51:24 -0500 Subject: Fix Lint/AssignmentInCondition violations. --- lib/puppet/provider/cron/crontab.rb | 16 +++++++++++----- lib/puppet/type/cron.rb | 13 +++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index a664629..e2cb6b6 100644 --- a/lib/puppet/provider/cron/crontab.rb +++ b/lib/puppet/provider/cron/crontab.rb @@ -34,11 +34,16 @@ Puppet::Type.type(:cron).provide(:crontab, parent: Puppet::Provider::ParsedFile, def post_parse(record) time = record.delete(:time) - if match = %r{@(\S+)}.match(time) + match = %r{@(\S+)}.match(time) + if match # is there another way to access the constant? Puppet::Type::Cron::ProviderCrontab::TIME_FIELDS.each { |f| record[f] = :absent } record[:special] = match.captures[0] - elsif match = %r{(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)}.match(time) + return record + end + + match = %r{(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)}.match(time) + if match record[:special] = :absent Puppet::Type::Cron::ProviderCrontab::TIME_FIELDS.zip(match.captures).each do |field, value| record[field] = if value == absent @@ -47,10 +52,11 @@ Puppet::Type.type(:cron).provide(:crontab, parent: Puppet::Provider::ParsedFile, value.split(',') end end - else - raise Puppet::Error, _('Line got parsed as a crontab entry but cannot be handled. Please file a bug with the contents of your crontab') + + return record end - record + + raise Puppet::Error, _('Line got parsed as a crontab entry but cannot be handled. Please file a bug with the contents of your crontab') end def pre_gen(record) diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index fada980..a811f94 100644 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -178,7 +178,8 @@ Puppet::Type.newtype(:cron) do return value unless self.class.boundaries lower, upper = self.class.boundaries retval = nil - if num = numfix(value) + num = numfix(value) + if num retval = limitcheck(num, lower, upper) elsif respond_to?(:alpha) # If it has an alpha method defined, then we check @@ -396,7 +397,8 @@ Puppet::Type.newtype(:cron) do defaultto do if provider.is_a?(@resource.class.provider(:crontab)) - if val = @resource.should(:user) + val = @resource.should(:user) + if val val else struct = Etc.getpwuid(Process.uid) @@ -450,10 +452,9 @@ Puppet::Type.newtype(:cron) do def value(name) name = name.to_sym ret = nil - if obj = @parameters[name] - ret = obj.should - - ret ||= obj.retrieve + obj = @parameters[name] + if obj + ret = obj.should || obj.retrieve if ret == :absent ret = nil -- cgit v1.2.3