Skip to content

Commit a7c8765

Browse files
authored
Clean up permissions fix code (#1236)
* Clean up permissions fix code - Use modern octal notation (0o755 instead of 0755) - Simplify conditional logic for non-executable files * Fix CI to catch Ruby style violations - Change default rake task from standard:fix to standard - This ensures CI fails when there are style violations instead of silently fixing them - Fixes the issue where style violations were auto-fixed but not caught in CI
1 parent b827e80 commit a7c8765

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ruby/Rakefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ LIB_GITHUB_RELEASES = [
4444

4545
task default: [
4646
:spec,
47-
(:"standard:fix" unless RUBY_VERSION < "2.6")
47+
(:standard unless RUBY_VERSION < "2.6")
4848
].compact
4949

5050
desc "Download lib release from github"
@@ -181,20 +181,18 @@ module Helpers
181181
next unless File.file?(path)
182182

183183
filename = File.basename(path)
184-
current_permissions = File.stat(path).mode & 0777
184+
current_permissions = File.stat(path).mode & 0o777
185185

186186
if EXECUTABLE_FILES.include?(filename)
187187
# Should be executable (755), fix if not
188-
if current_permissions != 0755
188+
if current_permissions != 0o755
189189
puts "Fixing permissions for #{filename}: #{current_permissions.to_s(8)} -> 755"
190-
FileUtils.chmod(0755, path)
190+
FileUtils.chmod(0o755, path)
191191
end
192-
else
192+
elsif current_permissions != 0o644
193193
# Should be non-executable (644), fix if not
194-
if current_permissions != 0644
195-
puts "Fixing permissions for #{filename}: #{current_permissions.to_s(8)} -> 644"
196-
FileUtils.chmod(0644, path)
197-
end
194+
puts "Fixing permissions for #{filename}: #{current_permissions.to_s(8)} -> 644"
195+
FileUtils.chmod(0o644, path)
198196
end
199197
end
200198
end

0 commit comments

Comments
 (0)