From 8f578ffc0b6d4b69ff8ca75a66b82646d79afa0e Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Tue, 12 Dec 2017 21:58:31 +0000 Subject: [PATCH] Rubocop: Fix Style/GuardClause --- lib/puppet/provider/posix_acl/posixacl.rb | 16 ++++++++-------- lib/puppet/type/posix_acl.rb | 14 ++++---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/puppet/provider/posix_acl/posixacl.rb b/lib/puppet/provider/posix_acl/posixacl.rb index 0ce781f..a534db5 100644 --- a/lib/puppet/provider/posix_acl/posixacl.rb +++ b/lib/puppet/provider/posix_acl/posixacl.rb @@ -12,14 +12,14 @@ def exists? end def unset_perm(perm, path) - # Don't try to unset mode bits, it don't make sense! - unless perm =~ %r{^(((u(ser)?)|(g(roup)?)|(m(ask)?)|(o(ther)?)):):} - perm = perm.split(':')[0..-2].join(':') - if check_recursive - setfacl('-R', '-n', '-x', perm, path) - else - setfacl('-n', '-x', perm, path) - end + # Don't try to unset mode bits, it doesn't make sense! + return if perm =~ %r{^(((u(ser)?)|(g(roup)?)|(m(ask)?)|(o(ther)?)):):} + + perm = perm.split(':')[0..-2].join(':') + if check_recursive + setfacl('-R', '-n', '-x', perm, path) + else + setfacl('-n', '-x', perm, path) end end diff --git a/lib/puppet/type/posix_acl.rb b/lib/puppet/type/posix_acl.rb index 1b42396..a75fe9f 100644 --- a/lib/puppet/type/posix_acl.rb +++ b/lib/puppet/type/posix_acl.rb @@ -185,18 +185,12 @@ def insync?(is) munge do |acl| r = '' a = acl.split ':', -1 # -1 keeps trailing empty fields. - if a.length < 3 - raise ArgumentError, "Too few fields. At least 3 required, got #{a.length}." - elsif a.length > 4 - raise ArgumentError, "Too many fields. At most 4 allowed, got #{a.length}." - end + raise ArgumentError, "Too few fields. At least 3 required, got #{a.length}." if a.length < 3 + raise ArgumentError, "Too many fields. At most 4 allowed, got #{a.length}." if a.length > 4 if a.length == 4 d = a.shift - if d == 'd' || d == 'default' - r << 'default:' - else - raise ArgumentError, %(First field of 4 must be "d" or "default", got "#{d}".) - end + raise ArgumentError, %(First field of 4 must be "d" or "default", got "#{d}".) unless %w[d default].include?(d) + r << 'default:' end t = a.shift # Copy the type. r << case t