diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-05-22 10:33:45 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-22 10:33:45 +0200 |
| commit | 0f812ee216076a4c713f6cadb0751bac45f6b9da (patch) | |
| tree | 95549c3a1899db8791268a71d4a33f5b9ce7847f /lib/axlsx | |
| parent | 56ff466673b8aff9a6508e29ebfaf4ee21f5fae9 (diff) | |
| parent | 611b57cdd44f3f5e91394c699ad98b7c05330a2e (diff) | |
| download | caxlsx-0f812ee216076a4c713f6cadb0751bac45f6b9da.tar.gz caxlsx-0f812ee216076a4c713f6cadb0751bac45f6b9da.zip | |
Merge pull request #242 from tagliala/chore/fix-minor-safe-offenses
Remove minor safe offenses
Diffstat (limited to 'lib/axlsx')
| -rw-r--r-- | lib/axlsx/drawing/area_series.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/line_series.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/package.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/color.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/styles.rb | 10 | ||||
| -rw-r--r-- | lib/axlsx/util/validators.rb | 5 | ||||
| -rw-r--r-- | lib/axlsx/util/zip_command.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/border_creator.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 2 |
9 files changed, 16 insertions, 17 deletions
diff --git a/lib/axlsx/drawing/area_series.rb b/lib/axlsx/drawing/area_series.rb index 5cebd7da..cf4aaf13 100644 --- a/lib/axlsx/drawing/area_series.rb +++ b/lib/axlsx/drawing/area_series.rb @@ -37,7 +37,7 @@ module Axlsx # @param [Chart] chart def initialize(chart, options = {}) @show_marker = false - @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default + @marker_symbol = options[:marker_symbol] || :default @smooth = false @labels, @data = nil, nil super(chart, options) diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb index bbd3957e..fbed4000 100644 --- a/lib/axlsx/drawing/line_series.rb +++ b/lib/axlsx/drawing/line_series.rb @@ -37,7 +37,7 @@ module Axlsx # @param [Chart] chart def initialize(chart, options = {}) @show_marker = false - @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default + @marker_symbol = options[:marker_symbol] || :default @smooth = false @labels, @data = nil, nil super(chart, options) diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index 9eab87a6..e8276d7c 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -145,7 +145,7 @@ module Axlsx # Encrypt the package into a CFB using the password provided # This is not ready yet def encrypt(file_name, password) - return false + false # moc = MsOffCrypto.new(file_name, password) # moc.save end @@ -386,7 +386,7 @@ module Axlsx options.merge!(secondary_options || {}) invalid_keys = options.keys - [:confirm_valid, :zip_command] if invalid_keys.any? - raise ArgumentError.new("Invalid keyword arguments: #{invalid_keys}") + raise ArgumentError, "Invalid keyword arguments: #{invalid_keys}" end [options.fetch(:confirm_valid, false), options.fetch(:zip_command, nil)] diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index 87308bb1..24fe3bc3 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -53,7 +53,7 @@ module Axlsx def rgb=(v) Axlsx::validate_string(v) v = v.upcase - v = v * 3 if v.size == 2 + v *= 3 if v.size == 2 v = v.rjust(8, 'FF') raise ArgumentError, "Invalid color rgb value: #{v}." unless /[0-9A-F]{8}/.match?(v) diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb index f67c711a..625f6a02 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -278,11 +278,9 @@ module Axlsx # Add styles to style_index cache for re-use style_index[xf_index] = raw_style - return xf_index + xf_index else - dxf_index = (dxfs << style) - - return dxf_index + dxfs << style end end @@ -457,9 +455,9 @@ module Axlsx end if options[:type] == :dxf - return border + border else - return borders << border + borders << border end end diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index e9cf13b6..72e3f2d8 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -55,9 +55,10 @@ module Axlsx # @return [Boolean] true if validation succeeds. # @see validate_boolean def self.validate(name, types, v, other = false) - if other.is_a?(Proc) - raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) unless other.call(v) + if other.is_a?(Proc) && !other.call(v) + raise ArgumentError, (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 diff --git a/lib/axlsx/util/zip_command.rb b/lib/axlsx/util/zip_command.rb index e43ba03d..bc098a92 100644 --- a/lib/axlsx/util/zip_command.rb +++ b/lib/axlsx/util/zip_command.rb @@ -64,7 +64,7 @@ module Axlsx command = "cd #{escaped_dir} && #{@zip_command} #{output} #{inputs}" stdout_and_stderr, status = Open3.capture2e(command) if !status.success? - raise(ZipError.new(stdout_and_stderr)) + raise ZipError, stdout_and_stderr end end end diff --git a/lib/axlsx/workbook/worksheet/border_creator.rb b/lib/axlsx/workbook/worksheet/border_creator.rb index 6321916f..9abaded5 100644 --- a/lib/axlsx/workbook/worksheet/border_creator.rb +++ b/lib/axlsx/workbook/worksheet/border_creator.rb @@ -13,12 +13,12 @@ module Axlsx if @edges == :all @edges = Axlsx::Border::EDGES elsif [email protected]_a?(Array) - raise ArgumentError.new("Invalid edges provided, #{@edges}") + raise ArgumentError, "Invalid edges provided, #{@edges}" else @edges = @edges.map { |x| x&.to_sym }.uniq if !(@edges - Axlsx::Border::EDGES).empty? - raise ArgumentError.new("Invalid edges provided, #{edges}") + raise ArgumentError, "Invalid edges provided, #{edges}" end end end diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index f4dd71a1..8c6e53b4 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -693,7 +693,7 @@ module Axlsx r = rows[row_index] if r - return r[col_index] + r[col_index] end end |
