diff options
| -rw-r--r-- | .rubocop_todo.yml | 12 | ||||
| -rw-r--r-- | lib/axlsx/drawing/chart.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/scaling.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/gradient_fill.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/gradient_stop.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/util/validators.rb | 8 |
7 files changed, 9 insertions, 21 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3a8e5ae..a855f812 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -208,18 +208,6 @@ Style/IfUnlessModifier: Enabled: false # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Exclude: - - 'lib/axlsx/drawing/chart.rb' - - 'lib/axlsx/drawing/scaling.rb' - - 'lib/axlsx/stylesheet/gradient_fill.rb' - - 'lib/axlsx/stylesheet/gradient_stop.rb' - - 'lib/axlsx/stylesheet/styles.rb' - - 'lib/axlsx/util/validators.rb' - -# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMethodComparison. Style/MultipleComparison: Exclude: diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 1e0b3fb6..c84e5cba 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -160,7 +160,7 @@ module Axlsx # The style for the chart. # see ECMA Part 1 ยง21.2.2.196 # @param [Integer] v must be between 1 and 48 - def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |arg| arg >= 1 && arg <= 48 }; @style = v; end + def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, ->(arg) { arg >= 1 && arg <= 48 }; @style = v; end # @see legend_position def legend_position=(v) RestrictionValidator.validate "Chart.legend_position", [:b, :l, :r, :t, :tr], v; @legend_position = v; end diff --git a/lib/axlsx/drawing/scaling.rb b/lib/axlsx/drawing/scaling.rb index 4d5a9d2a..c9101ead 100644 --- a/lib/axlsx/drawing/scaling.rb +++ b/lib/axlsx/drawing/scaling.rb @@ -35,7 +35,7 @@ module Axlsx attr_reader :min # @see logBase - def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000 }; @logBase = v; end + def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, ->(arg) { arg >= 2 && arg <= 1000 }; @logBase = v; end # @see orientation def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end # @see max diff --git a/lib/axlsx/stylesheet/gradient_fill.rb b/lib/axlsx/stylesheet/gradient_fill.rb index ff6903a5..508c91a2 100644 --- a/lib/axlsx/stylesheet/gradient_fill.rb +++ b/lib/axlsx/stylesheet/gradient_fill.rb @@ -86,7 +86,7 @@ module Axlsx # validates that the value provided is between 0.0 and 1.0 def validate_format_percentage(name, value) - DataTypeValidator.validate name, Float, value, lambda { |arg| arg >= 0.0 && arg <= 1.0 } + DataTypeValidator.validate name, Float, value, ->(arg) { arg >= 0.0 && arg <= 1.0 } end # Serializes the object diff --git a/lib/axlsx/stylesheet/gradient_stop.rb b/lib/axlsx/stylesheet/gradient_stop.rb index dd0ea00f..b0d66683 100644 --- a/lib/axlsx/stylesheet/gradient_stop.rb +++ b/lib/axlsx/stylesheet/gradient_stop.rb @@ -24,7 +24,7 @@ module Axlsx # @see color def color=(v) DataTypeValidator.validate "GradientStop.color", Color, v; @color = v end # @see position - def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v, lambda { |arg| arg >= 0 && arg <= 1 }; @position = v end + def position=(v) DataTypeValidator.validate "GradientStop.position", Float, v, ->(arg) { arg >= 0 && arg <= 1 }; @position = v end # Serializes the object # @param [String] str diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index bdda36c7..d9c5683a 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -380,7 +380,7 @@ module Axlsx end end - validate_border_hash = ->(val) { + validate_border_hash = lambda { |val| unless val.key?(:style) && val.key?(:color) raise ArgumentError, format(ERR_INVALID_BORDER_OPTIONS, options[:border]) end diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index 8533145d..fd17360e 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -83,7 +83,7 @@ module Axlsx end # Validates an unsigned intger - UINT_VALIDATOR = lambda { |arg| arg.respond_to?(:>=) && arg >= 0 } + UINT_VALIDATOR = ->(arg) { arg.respond_to?(:>=) && arg >= 0 } # Requires that the value is a Integer and is greater or equal to 0 # @param [Any] v The value validated @@ -109,7 +109,7 @@ module Axlsx VALID_BOOLEAN_CLASSES = [TrueClass, FalseClass, Integer, String, Symbol].freeze VALID_BOOLEAN_VALUES = [true, false, 1, 0, '1', '0', 'true', 'false', :true, :false].freeze - BOOLEAN_VALIDATOR = lambda { |arg| VALID_BOOLEAN_VALUES.include?(arg) } + BOOLEAN_VALIDATOR = ->(arg) { VALID_BOOLEAN_VALUES.include?(arg) } # Requires that the value is a form that can be evaluated as a boolean in an xml document. # The value must be an instance of String, Integer, Symbol, TrueClass or FalseClass and @@ -137,14 +137,14 @@ module Axlsx RegexValidator.validate "number_with_unit", /\A[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)\Z/, v end - SCALE_10_400_VALIDATOR = lambda { |arg| arg >= 10 && arg <= 400 } + SCALE_10_400_VALIDATOR = ->(arg) { arg >= 10 && arg <= 400 } # Requires that the value is an integer ranging from 10 to 400. def self.validate_scale_10_400(v) DataTypeValidator.validate "page_scale", Integer, v, SCALE_10_400_VALIDATOR end - SCALE_0_10_400_VALIDATOR = lambda { |arg| arg == 0 || (arg >= 10 && arg <= 400) } + SCALE_0_10_400_VALIDATOR = ->(arg) { arg == 0 || (arg >= 10 && arg <= 400) } # Requires that the value is an integer ranging from 10 to 400 or 0. def self.validate_scale_0_10_400(v) |
