Skip to content

Commit

Permalink
Merge pull request #41 from alexjfisher/rubocop_gaurd_clauses
Browse files Browse the repository at this point in the history
Rubocop: Fix Style/GuardClause
  • Loading branch information
dobbymoodge authored Dec 12, 2017
2 parents e172efd + 8f578ff commit 9b1f22f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
16 changes: 8 additions & 8 deletions lib/puppet/provider/posix_acl/posixacl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 4 additions & 10 deletions lib/puppet/type/posix_acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,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
Expand Down

0 comments on commit 9b1f22f

Please sign in to comment.