Skip to content

Commit acee715

Browse files
committed
(PUP-11993) Style/NumericLiterals
This commit enables the Style/NumericLiterals cop and fixes 19 autocorrectable offenses.
1 parent 9b06446 commit acee715

File tree

13 files changed

+17
-22
lines changed

13 files changed

+17
-22
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,6 @@ Style/MultipleComparison:
629629
Style/MutableConstant:
630630
Enabled: false
631631

632-
# This cop supports safe auto-correction (--auto-correct).
633-
# Configuration parameters: Strict, AllowedNumbers.
634-
Style/NumericLiterals:
635-
MinDigits: 11
636-
637632
# This cop supports unsafe auto-correction (--auto-correct-all).
638633
# Configuration parameters: EnforcedStyle, IgnoredMethods.
639634
# SupportedStyles: predicate, comparison

lib/puppet/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def self.initialize_default_settings!(settings)
501501
end
502502
},
503503
:maximum_uid => {
504-
:default => 4294967290,
504+
:default => 4_294_967_290,
505505
:type => :integer,
506506
:desc => "The maximum allowed UID. Some platforms use negative UIDs
507507
but then ship with tools that do not know how to handle signed ints,

lib/puppet/ffi/windows/constants.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module Constants
109109
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa364571(v=vs.85).aspx
110110
FSCTL_GET_REPARSE_POINT = 0x900a8
111111

112-
MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384
112+
MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16_384
113113

114114
# Priority constants
115115
# https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setpriorityclass

lib/puppet/ffi/windows/structs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class OSVERSIONINFO < FFI::Struct
258258
)
259259
end
260260

261-
MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384
261+
MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16_384
262262

263263
# SYMLINK_REPARSE_DATA_BUFFER
264264
# https://msdn.microsoft.com/en-us/library/cc232006.aspx

lib/puppet/pops/serialization/abstract_reader.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ def register_types
143143
read_payload(data) do |ep|
144144
sec = ep.read
145145
nsec = ep.read
146-
Time::Timestamp.new(sec * 1000000000 + nsec)
146+
Time::Timestamp.new(sec * 1_000_000_000 + nsec)
147147
end
148148
end
149149

150150
register_type(Extension::TIMESPAN) do |data|
151151
read_payload(data) do |ep|
152152
sec = ep.read
153153
nsec = ep.read
154-
Time::Timespan.new(sec * 1000000000 + nsec)
154+
Time::Timespan.new(sec * 1_000_000_000 + nsec)
155155
end
156156
end
157157

lib/puppet/pops/serialization/abstract_writer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ def register_types
178178
end
179179

180180
register_type(Extension::TIME, Time::Timestamp) do |o|
181-
build_payload { |ep| nsecs = o.nsecs; ep.write(nsecs / 1000000000); ep.write(nsecs % 1000000000) }
181+
build_payload { |ep| nsecs = o.nsecs; ep.write(nsecs / 1_000_000_000); ep.write(nsecs % 1_000_000_000) }
182182
end
183183

184184
register_type(Extension::TIMESPAN, Time::Timespan) do |o|
185-
build_payload { |ep| nsecs = o.nsecs; ep.write(nsecs / 1000000000); ep.write(nsecs % 1000000000) }
185+
build_payload { |ep| nsecs = o.nsecs; ep.write(nsecs / 1_000_000_000); ep.write(nsecs % 1_000_000_000) }
186186
end
187187

188188
register_type(Extension::VERSION, SemanticPuppet::Version) do |o|

lib/puppet/pops/time/timestamp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def self.parse(str, format = :default, timezone = nil)
107107
fraction = parsed[:sec_fraction]
108108

109109
# Convert msec rational found in _strptime hash to usec
110-
fraction = fraction * 1000000 unless fraction.nil?
110+
fraction = fraction * 1_000_000 unless fraction.nil?
111111

112112
# Create the Time instance and adjust for timezone
113113
parsed_time = ::Time.utc(parsed[:year], parsed[:mon], parsed[:mday], parsed[:hour], parsed[:min], parsed[:sec], fraction)

lib/puppet/provider/nameservice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def self.autogen_id(field, resource_type)
142142
# loop. Thanks, Ruby, for your awesome abstractions. --daniel 2012-03-23
143143
highest = []
144144
Puppet::Etc.send(database) { |entry| highest << entry.send(method) }
145-
highest = highest.reject { |x| x > 65000 }.max
145+
highest = highest.reject { |x| x > 65_000 }.max
146146

147147
@prevauto = highest || 1000
148148
end

lib/puppet/settings/port_setting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Puppet::Settings::PortSetting < Puppet::Settings::IntegerSetting
44
def munge(value)
55
value = super(value)
66

7-
if value < 0 || value > 65535
7+
if value < 0 || value > 65_535
88
raise Puppet::Settings::ValidationError, _("Value '%{value}' is not a valid port number for parameter: %{name}") % { value: value.inspect, name: @name }
99
end
1010

lib/puppet/type/schedule.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ def match?(previous, now)
232232

233233
ScheduleScales = {
234234
:hourly => 3600,
235-
:daily => 86400,
236-
:weekly => 604800,
237-
:monthly => 2592000
235+
:daily => 86_400,
236+
:weekly => 604_800,
237+
:monthly => 2_592_000
238238
}
239239
ScheduleMethods = {
240240
:hourly => :hour,

0 commit comments

Comments
 (0)