diff options
author | Jorie Tappa <jorie@jorietappa.com> | 2018-08-01 16:51:24 -0500 |
---|---|---|
committer | Jorie Tappa <jorie@jorietappa.com> | 2018-08-01 16:51:24 -0500 |
commit | 6e4c49d512272fcfe363867bcc82943168ac0361 (patch) | |
tree | 6db34e918186e5963e07202c13f1331e7a18a614 /lib | |
parent | ab27f19f5cc54322ec7fe2c4e970f3a54d40881f (diff) | |
download | puppet-cron_core-6e4c49d512272fcfe363867bcc82943168ac0361.tar.gz puppet-cron_core-6e4c49d512272fcfe363867bcc82943168ac0361.tar.bz2 |
Fix Lint/AssignmentInCondition violations.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/provider/cron/crontab.rb | 16 | ||||
-rw-r--r-- | lib/puppet/type/cron.rb | 13 |
2 files changed, 18 insertions, 11 deletions
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 |