diff options
| author | Geremia Taglialatela <[email protected]> | 2023-04-07 23:36:48 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-04-07 23:38:58 +0200 |
| commit | 70d3dfc768ecbea6ea52e9481fbfd3068445bbc4 (patch) | |
| tree | b218d38d26a51bf6bb1216a81fc6c7acb491c265 | |
| parent | 3460a7fbb808d43a2a027fb98ef40209498a86fd (diff) | |
| download | caxlsx-70d3dfc768ecbea6ea52e9481fbfd3068445bbc4.tar.gz caxlsx-70d3dfc768ecbea6ea52e9481fbfd3068445bbc4.zip | |
Fix Layout/ElseAlignment
Manually fixed
| -rw-r--r-- | .rubocop_todo.yml | 18 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/merged_cells.rb | 12 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 8 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_date_time_converter.rb | 58 |
4 files changed, 39 insertions, 57 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c56a7f5f..817fdd67 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -42,14 +42,6 @@ Layout/ClosingParenthesisIndentation: Exclude: - 'lib/axlsx/stylesheet/styles.rb' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Layout/ElseAlignment: - Exclude: - - 'lib/axlsx/workbook/worksheet/merged_cells.rb' - - 'lib/axlsx/workbook/worksheet/worksheet.rb' - - 'test/workbook/worksheet/tc_date_time_converter.rb' - # Offense count: 90 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: @@ -83,16 +75,6 @@ Layout/EmptyLinesAroundMethodBody: Layout/EmptyLinesAroundModuleBody: Enabled: false -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'lib/axlsx/workbook/worksheet/merged_cells.rb' - - 'lib/axlsx/workbook/worksheet/worksheet.rb' - - 'test/workbook/worksheet/tc_date_time_converter.rb' - # Offense count: 58 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. diff --git a/lib/axlsx/workbook/worksheet/merged_cells.rb b/lib/axlsx/workbook/worksheet/merged_cells.rb index 67753bd3..cb5bae93 100644 --- a/lib/axlsx/workbook/worksheet/merged_cells.rb +++ b/lib/axlsx/workbook/worksheet/merged_cells.rb @@ -16,12 +16,12 @@ module Axlsx # range like 'A1:C1' def add(cells) self << if cells.is_a?(String) - cells - elsif cells.is_a?(Array) - Axlsx::cell_range(cells, false) - elsif cells.is_a?(Row) - Axlsx::cell_range(cells, false) - end + cells + elsif cells.is_a?(Array) + Axlsx::cell_range(cells, false) + elsif cells.is_a?(Row) + Axlsx::cell_range(cells, false) + end end # serialize the object diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 2ab01862..a32bc5b6 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -507,10 +507,10 @@ module Axlsx def add_page_break(cell) DataTypeValidator.validate :worksheet_page_break, [String, Cell], cell column_index, row_index = if cell.is_a?(String) - Axlsx.name_to_indices(cell) - else - cell.pos - end + Axlsx.name_to_indices(cell) + else + cell.pos + end if column_index > 0 col_breaks.add_break(:id => column_index) end diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb index 19278e95..225c1893 100644 --- a/test/workbook/worksheet/tc_date_time_converter.rb +++ b/test/workbook/worksheet/tc_date_time_converter.rb @@ -63,21 +63,21 @@ class TestDateTimeConverter < Test::Unit::TestCase def test_time_to_serial_1900 Axlsx::Workbook.date1904 = false tests = if @extended_time_range - { # examples taken straight from the spec - "1893-08-05T00:00:01Z" => -2337.999989, - "1899-12-28T18:00:00Z" => -1.25, - "1910-02-03T10:05:54Z" => 3687.4207639, - "1900-01-01T12:00:00Z" => 2.5, # wrongly indicated as 1.5 in the spec! - "9999-12-31T23:59:59Z" => 2958465.9999884 - } - else - { # examples taken inside the possible values - "1970-01-01T00:00:00Z" => 25569.0, # Unix epoch - "1970-01-01T12:00:00Z" => 25569.5, - "2000-01-01T00:00:00Z" => 36526.0, - "2038-01-19T03:14:07Z" => 50424.134803, # max signed timestamp in 32bit - } - end + { # examples taken straight from the spec + "1893-08-05T00:00:01Z" => -2337.999989, + "1899-12-28T18:00:00Z" => -1.25, + "1910-02-03T10:05:54Z" => 3687.4207639, + "1900-01-01T12:00:00Z" => 2.5, # wrongly indicated as 1.5 in the spec! + "9999-12-31T23:59:59Z" => 2958465.9999884 + } + else + { # examples taken inside the possible values + "1970-01-01T00:00:00Z" => 25569.0, # Unix epoch + "1970-01-01T12:00:00Z" => 25569.5, + "2000-01-01T00:00:00Z" => 36526.0, + "2038-01-19T03:14:07Z" => 50424.134803, # max signed timestamp in 32bit + } + end tests.each do |time_string, expected| serial = Axlsx::DateTimeConverter::time_to_serial Time.parse(time_string) assert_in_delta expected, serial, @margin_of_error @@ -89,20 +89,20 @@ class TestDateTimeConverter < Test::Unit::TestCase # ruby 1.8.7 cannot parse dates prior to epoch. see http://ruby-doc.org/core-1.8.7/Time.html tests = if @extended_time_range - { # examples taken straight from the spec - "1893-08-05T00:00:01Z" => -3799.999989, - "1910-02-03T10:05:54Z" => 2225.4207639, - "1904-01-01T12:00:00Z" => 0.5000000, - "9999-12-31T23:59:59Z" => 2957003.9999884 - } - else - { # examples taken inside the possible values - "1970-01-01T00:00:00Z" => 24107.0, # Unix epoch - "1970-01-01T12:00:00Z" => 24107.5, - "2000-01-01T00:00:00Z" => 35064.0, - "2038-01-19T03:14:07Z" => 48962.134803, # max signed timestamp in 32bit - } - end + { # examples taken straight from the spec + "1893-08-05T00:00:01Z" => -3799.999989, + "1910-02-03T10:05:54Z" => 2225.4207639, + "1904-01-01T12:00:00Z" => 0.5000000, + "9999-12-31T23:59:59Z" => 2957003.9999884 + } + else + { # examples taken inside the possible values + "1970-01-01T00:00:00Z" => 24107.0, # Unix epoch + "1970-01-01T12:00:00Z" => 24107.5, + "2000-01-01T00:00:00Z" => 35064.0, + "2038-01-19T03:14:07Z" => 48962.134803, # max signed timestamp in 32bit + } + end tests.each do |time_string, expected| serial = Axlsx::DateTimeConverter::time_to_serial Time.parse(time_string) assert_in_delta expected, serial, @margin_of_error |
