diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-06-05 18:40:47 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-05 18:40:47 +0200 |
| commit | 2965ebd4c719ad34a75e70cb1640e94093c8c763 (patch) | |
| tree | a50309ea3b0db8a2de8d3f6985ba29de3b826f5a /lib/axlsx/util/validators.rb | |
| parent | a2eeaeefca8deb3d26f3f8dc62976fe6bf1dafcf (diff) | |
| parent | b0fb7d1f19afbc933b3aa445f5d95d4b6bef9f6b (diff) | |
| download | caxlsx-2965ebd4c719ad34a75e70cb1640e94093c8c763.tar.gz caxlsx-2965ebd4c719ad34a75e70cb1640e94093c8c763.zip | |
Merge pull request #277 from tagliala/chore/fix-format-string-offenses
Fix format string offenses
Diffstat (limited to 'lib/axlsx/util/validators.rb')
| -rw-r--r-- | lib/axlsx/util/validators.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index 48c12c13..8533145d 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -10,7 +10,7 @@ module Axlsx # @raise [ArgumentError] Raised if the value provided is not in the list of choices. # @return [Boolean] true if validation succeeds. def self.validate(name, choices, v) - raise ArgumentError, (ERR_RESTRICTION % [v.to_s, name, choices.inspect]) unless choices.include?(v) + raise ArgumentError, format(ERR_RESTRICTION, v.to_s, name, choices.inspect) unless choices.include?(v) true end @@ -31,7 +31,7 @@ module Axlsx else min < value && value < max end - raise ArgumentError, (ERR_RANGE % [value.inspect, min.to_s, max.to_s, inclusive]) unless passes + raise ArgumentError, format(ERR_RANGE, value.inspect, min.to_s, max.to_s, inclusive) unless passes end end @@ -41,7 +41,7 @@ module Axlsx # @param [Regexp] regex The regular expression to evaluate # @param [Any] v The value to validate. def self.validate(name, regex, v) - raise ArgumentError, (ERR_REGEX % [v.inspect, regex.to_s]) unless v.respond_to?(:to_s) && regex.match?(v.to_s) + raise ArgumentError, format(ERR_REGEX, v.inspect, regex.to_s) unless v.respond_to?(:to_s) && regex.match?(v.to_s) end end @@ -56,14 +56,14 @@ module Axlsx # @see validate_boolean def self.validate(name, types, v, other = false) if other.is_a?(Proc) && !other.call(v) - raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) + raise ArgumentError, format(ERR_TYPE, v.inspect, name, types.inspect) end v_class = v.is_a?(Class) ? v : v.class Array(types).each do |t| return if v_class <= t end - raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) + raise ArgumentError, format(ERR_TYPE, v.inspect, name, types.inspect) end end @@ -71,7 +71,7 @@ module Axlsx # @para, [Any] v the value to validate # @raise [ArgumentError] raised if the value cannot be converted to an integer def self.validate_integerish(v) - raise ArgumentError, (ERR_INTEGERISH % v.inspect) unless v.respond_to?(:to_i) && v.to_i.is_a?(Integer) + raise ArgumentError, format(ERR_INTEGERISH, v.inspect) unless v.respond_to?(:to_i) && v.to_i.is_a?(Integer) end # Requires that the value is between -54000000 and 54000000 @@ -79,7 +79,7 @@ module Axlsx # @raise [ArgumentError] raised if the value cannot be converted to an integer between the allowed angle values for chart label rotation. # @return [Boolean] true if the data is valid def self.validate_angle(v) - raise ArgumentError, (ERR_ANGLE % v.inspect) unless v.to_i >= -5400000 && v.to_i <= 5400000 + raise ArgumentError, format(ERR_ANGLE, v.inspect) unless v.to_i >= -5400000 && v.to_i <= 5400000 end # Validates an unsigned intger |
