diff options
| author | Geremia Taglialatela <[email protected]> | 2023-04-09 17:00:03 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-04-09 17:00:03 +0200 |
| commit | 1406b47e64188765f220be86001ec1f543e0157d (patch) | |
| tree | cca128ffc09c8b68e711f7eccd19fdf97f9cf807 | |
| parent | c77a48805c17d36c4503df8cf0fe75e7b620e2d4 (diff) | |
| download | caxlsx-1406b47e64188765f220be86001ec1f543e0157d.tar.gz caxlsx-1406b47e64188765f220be86001ec1f543e0157d.zip | |
Fix Layout/ExtraSpacing offenses
Configure with `AllowBeforeTrailingComments: true`
| -rw-r--r-- | .rubocop.yml | 3 | ||||
| -rw-r--r-- | .rubocop_todo.yml | 6 | ||||
| -rw-r--r-- | lib/axlsx.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/d_lbls.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/series.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/drawing/view_3D.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/package.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/stylesheet/cell_style.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/workbook/workbook.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/auto_filter/filters.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/comments.rb | 2 | ||||
| -rw-r--r-- | test/drawing/tc_axis.rb | 2 | ||||
| -rw-r--r-- | test/drawing/tc_bubble_chart.rb | 4 | ||||
| -rw-r--r-- | test/drawing/tc_scatter_chart.rb | 4 | ||||
| -rw-r--r-- | test/drawing/tc_view_3D.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_data_validation.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_date_time_converter.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_pivot_table.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_selection.rb | 2 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_worksheet.rb | 2 |
20 files changed, 25 insertions, 28 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index fe5b876a..28352bd5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,3 +11,6 @@ AllCops: Layout/CommentIndentation: AllowForAlignment: true + +Layout/ExtraSpacing: + AllowBeforeTrailingComments: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fc019a48..d03f2431 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,12 +22,6 @@ Gemspec/RequireMFA: Exclude: - 'axlsx.gemspec' -# Offense count: 58 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Enabled: false - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IndentationWidth. diff --git a/lib/axlsx.rb b/lib/axlsx.rb index df847a18..a12bf08a 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -88,7 +88,7 @@ module Axlsx letters_str = name[/[A-Z]+/] # capitalization?!? - v = letters_str.reverse.chars.reduce({ :base => 1, :i => 0 }) do |val, c| + v = letters_str.reverse.chars.reduce({ :base => 1, :i => 0 }) do |val, c| val[:i] += ((c.bytes.first - 64) * val[:base]) val[:base] *= 26 diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb index 213008e6..3e51d021 100644 --- a/lib/axlsx/drawing/d_lbls.rb +++ b/lib/axlsx/drawing/d_lbls.rb @@ -63,7 +63,7 @@ module Axlsx def d_lbl_pos=(label_position) return unless [Pie3DChart, LineChart].include? @chart_type - Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position + Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position @d_lbl_pos = label_position end diff --git a/lib/axlsx/drawing/series.rb b/lib/axlsx/drawing/series.rb index e5c66b59..86b85f4c 100644 --- a/lib/axlsx/drawing/series.rb +++ b/lib/axlsx/drawing/series.rb @@ -38,7 +38,7 @@ module Axlsx end # @see order - def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end + def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end # @see title def title=(v) @@ -50,7 +50,7 @@ module Axlsx private # assigns the chart for this series - def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end + def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end # Serializes the object # @param [String] str diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb index 86a2ab2f..1f701f32 100644 --- a/lib/axlsx/drawing/view_3D.rb +++ b/lib/axlsx/drawing/view_3D.rb @@ -11,7 +11,7 @@ module Axlsx # @option options [Boolean] r_ang_ax # @option options [Integer] perspective def initialize(options = {}) - @rot_x, @h_percent, @rot_y, @depth_percent, @r_ang_ax, @perspective = nil, nil, nil, nil, nil, nil + @rot_x, @h_percent, @rot_y, @depth_percent, @r_ang_ax, @perspective = nil, nil, nil, nil, nil, nil parse_options options end diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index fcb80cdc..c3805a5c 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -327,7 +327,7 @@ module Axlsx end exts = workbook.images.map { |image| image.extname.downcase } exts.uniq.each do |ext| - ct = if ['jpeg', 'jpg'].include?(ext) + ct = if ['jpeg', 'jpg'].include?(ext) JPEG_CT elsif ext == 'gif' GIF_CT diff --git a/lib/axlsx/stylesheet/cell_style.rb b/lib/axlsx/stylesheet/cell_style.rb index 1e35a1a4..20f88133 100644 --- a/lib/axlsx/stylesheet/cell_style.rb +++ b/lib/axlsx/stylesheet/cell_style.rb @@ -46,7 +46,7 @@ module Axlsx attr_reader :customBuiltin # @see name - def name=(v) Axlsx::validate_string v; @name = v end + def name=(v) Axlsx::validate_string v; @name = v end # @see xfId def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end # @see builtinId diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index 567a0598..134a3e6b 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -344,7 +344,7 @@ module Axlsx pivot_tables.each_with_index do |pivot_table, index| r << Relationship.new(pivot_table.cache_definition, PIVOT_TABLE_CACHE_DEFINITION_R, PIVOT_TABLE_CACHE_DEFINITION_PN % (index + 1)) end - r << Relationship.new(self, STYLES_R, STYLES_PN) + r << Relationship.new(self, STYLES_R, STYLES_PN) if use_shared_strings r << Relationship.new(self, SHARED_STRINGS_R, SHARED_STRINGS_PN) end diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb index e731dab2..554df012 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb @@ -76,7 +76,7 @@ module Axlsx # Serialize the object to xml def to_xml_string(str = '') str << "<filters #{serialized_attributes}>" - filter_items.each { |filter| filter.to_xml_string(str) } + filter_items.each { |filter| filter.to_xml_string(str) } date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) } str << '</filters>' end @@ -144,7 +144,7 @@ module Axlsx # @option [Integer] minute @see minute # @option [Integer] second @see second def initialize(options = {}) - raise ArgumentError, "You must specify a year for date time grouping" unless options[:year] + raise ArgumentError, "You must specify a year for date time grouping" unless options[:year] raise ArgumentError, "You must specify a date_time_grouping when creating a DateGroupItem for auto filter" unless options[:date_time_grouping] parse_options options diff --git a/lib/axlsx/workbook/worksheet/comments.rb b/lib/axlsx/workbook/worksheet/comments.rb index 452b198f..f6f3071b 100644 --- a/lib/axlsx/workbook/worksheet/comments.rb +++ b/lib/axlsx/workbook/worksheet/comments.rb @@ -65,7 +65,7 @@ module Axlsx def to_xml_string(str = "") str << '<?xml version="1.0" encoding="UTF-8"?>' str << ('<comments xmlns="' << XML_NS << '"><authors>') - authors.each do |author| + authors.each do |author| str << ('<author>' << author.to_s << '</author>') end str << '</authors><commentList>' diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index 52a066be..0f7108eb 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -57,7 +57,7 @@ class TestAxis < Test::Unit::TestCase def test_format_code assert_raise(ArgumentError, "requires valid format code") { @axis.format_code = :high } - assert_nothing_raised("accepts valid format code") { @axis.format_code = "00.##" } + assert_nothing_raised("accepts valid format code") { @axis.format_code = "00.##" } end def create_chart_with_formatting(format_string = nil) diff --git a/test/drawing/tc_bubble_chart.rb b/test/drawing/tc_bubble_chart.rb index 7a9af423..02745f92 100644 --- a/test/drawing/tc_bubble_chart.rb +++ b/test/drawing/tc_bubble_chart.rb @@ -5,10 +5,10 @@ class TestBubbleChart < Test::Unit::TestCase @p = Axlsx::Package.new @chart = nil @p.workbook.add_worksheet do |sheet| - sheet.add_row ["First", 1, 5, 7, 9] + sheet.add_row ["First", 1, 5, 7, 9] sheet.add_row ["", 1, 25, 49, 81] sheet.add_row ["", 1, 42, 60, 75] - sheet.add_row ["Second", 5, 2, 14, 9] + sheet.add_row ["Second", 5, 2, 14, 9] sheet.add_row ["", 5, 10, 15, 20] sheet.add_row ["", 5, 28, 92, 13] sheet.add_chart(Axlsx::BubbleChart, :title => "example: Bubble Chart") do |chart| diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index a8d713eb..359f7206 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -5,9 +5,9 @@ class TestScatterChart < Test::Unit::TestCase @p = Axlsx::Package.new @chart = nil @p.workbook.add_worksheet do |sheet| - sheet.add_row ["First", 1, 5, 7, 9] + sheet.add_row ["First", 1, 5, 7, 9] sheet.add_row ["", 1, 25, 49, 81] - sheet.add_row ["Second", 5, 2, 14, 9] + sheet.add_row ["Second", 5, 2, 14, 9] sheet.add_row ["", 5, 10, 15, 20] sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart| chart.start_at 0, 4 diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb index 9aceb542..43116023 100644 --- a/test/drawing/tc_view_3D.rb +++ b/test/drawing/tc_view_3D.rb @@ -2,7 +2,7 @@ require 'tc_helper.rb' class TestView3D < Test::Unit::TestCase def setup - @view = Axlsx::View3D.new + @view = Axlsx::View3D.new end def teardown diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb index f93c91fe..09ce8290 100644 --- a/test/workbook/worksheet/tc_data_validation.rb +++ b/test/workbook/worksheet/tc_data_validation.rb @@ -7,7 +7,7 @@ class TestDataValidation < Test::Unit::TestCase def setup #inverse defaults @boolean_options = { :allowBlank => false, :hideDropDown => true, :showErrorMessage => false, :showInputMessage => true } - @nil_options = { :formula1 => 'foo', :formula2 => 'foo', :errorTitle => 'foo', :operator => :lessThan, :prompt => 'foo', :promptTitle => 'foo', :sqref => 'foo' } + @nil_options = { :formula1 => 'foo', :formula2 => 'foo', :errorTitle => 'foo', :operator => :lessThan, :prompt => 'foo', :promptTitle => 'foo', :sqref => 'foo' } @type_option = { :type => :whole } @error_style_option = { :errorStyle => :warning } diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb index cb139d45..9c813486 100644 --- a/test/workbook/worksheet/tc_date_time_converter.rb +++ b/test/workbook/worksheet/tc_date_time_converter.rb @@ -114,7 +114,7 @@ class TestDateTimeConverter < Test::Unit::TestCase local = Time.parse "2012-01-01 09:00:00 +0900" assert_equal local, utc - assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc) + assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc) Axlsx::Workbook.date1904 = true assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - local.utc_offset.to_f / 86400, Axlsx::DateTimeConverter::time_to_serial(utc) end diff --git a/test/workbook/worksheet/tc_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb index 83f8fce6..a5bb8906 100644 --- a/test/workbook/worksheet/tc_pivot_table.rb +++ b/test/workbook/worksheet/tc_pivot_table.rb @@ -17,7 +17,7 @@ class TestPivotTable < Test::Unit::TestCase @ws = p.workbook.add_worksheet @ws << ["Year", "Month", "Region", "Type", "Sales"] - @ws << [2012, "Nov", "East", "Soda", "12345"] + @ws << [2012, "Nov", "East", "Soda", "12345"] end def test_initialization diff --git a/test/workbook/worksheet/tc_selection.rb b/test/workbook/worksheet/tc_selection.rb index 5f65adcd..d600aa67 100644 --- a/test/workbook/worksheet/tc_selection.rb +++ b/test/workbook/worksheet/tc_selection.rb @@ -2,7 +2,7 @@ require 'tc_helper.rb' class TestSelection < Test::Unit::TestCase def setup - @options = { :active_cell => 'A2', :active_cell_id => 1, :pane => :top_left, :sqref => 'A2' } + @options = { :active_cell => 'A2', :active_cell_id => 1, :pane => :top_left, :sqref => 'A2' } @selection = Axlsx::Selection.new(@options) end diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index 6c8e0781..f6c65fe4 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -690,7 +690,7 @@ class TestWorksheet < Test::Unit::TestCase sheet.add_row ['', 'Butter', 'Dairy', 4.99] sheet.add_row ['', 'Bread', 'Baked Goods', 3.45] sheet.add_row ['', 'Broccoli', 'Produce', 2.99] - sheet.add_row ['', 'Pizza', 'Frozen Foods', 4.99] + sheet.add_row ['', 'Pizza', 'Frozen Foods', 4.99] sheet.column_widths 5, 20, 20, 20 sheet.add_style 'B2:D2', b: true |
