Skip to content

Commit 3f8f255

Browse files
jsirexgeemus
authored andcommitted
Use SecureRandom.uuid since ruby 2.x
1 parent c4c1f84 commit 3f8f255

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,6 @@ Style/FileWrite:
488488
- 'lib/fog/core/cache.rb'
489489
- 'spec/core/cache_spec.rb'
490490

491-
# Offense count: 1
492-
# This cop supports safe autocorrection (--autocorrect).
493-
# Configuration parameters: EnforcedStyle.
494-
# SupportedStyles: format, sprintf, percent
495-
Style/FormatString:
496-
Exclude:
497-
- 'lib/fog/core/uuid.rb'
498-
499491
# Offense count: 6
500492
# This cop supports safe autocorrection (--autocorrect).
501493
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.

lib/fog/core/uuid.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ module Fog
44
class UUID
55
class << self
66
def uuid
7-
if supported?
8-
SecureRandom.uuid
9-
else
10-
ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
11-
ary[2] = (ary[2] & 0x0fff) | 0x4000
12-
ary[3] = (ary[3] & 0x3fff) | 0x8000
13-
"%08x-%04x-%04x-%04x-%04x%08x" % ary
14-
end
7+
SecureRandom.uuid
158
end
169

10+
# :nodoc: This method is used by other plugins, so preserve it for the compatibility
1711
def supported?
1812
SecureRandom.respond_to?(:uuid)
1913
end

0 commit comments

Comments
 (0)