summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-04-13 13:09:14 +0200
committerGeremia Taglialatela <[email protected]>2023-05-03 16:05:17 +0200
commite81036b76e734ab03fac31faafb9732f6b3b2928 (patch)
tree4a5944faddeac7aa574a26955d41f4901fccc038
parent194e852d4f61d7c1acf4cd79df86bee43d84028a (diff)
downloadcaxlsx-e81036b76e734ab03fac31faafb9732f6b3b2928.tar.gz
caxlsx-e81036b76e734ab03fac31faafb9732f6b3b2928.zip
Fix offenses to non-production code
- Lint/AmbiguousBlockAssociation - Lint/AmbiguousOperatorPrecedence - Lint/EmptyBlock - Lint/RedundantSplatExpansion - Lint/RedundantStringCoercion - Lint/SymbolConversion - Lint/UnusedBlockArgument - Style/BlockDelimiters - Style/CommentAnnotation - Style/EachForSimpleLoop - Style/EmptyMethod - Style/ExpandPathArguments - Style/FileWrite - Style/GlobalStdStream (UNSAFE) - Style/HashEachMethods (UNSAFE) - Style/NestedParenthesizedCalls - Style/NilComparison - Style/NumericLiteralPrefix (manually fixed) - Style/ParallelAssignment - Style/PreferredHashMethods (UNSAFE) - Style/RedundantInterpolation (UNSAFE) - Style/RedundantParentheses (UNSAFE) - Style/RegexpLiteral - Style/RescueStandardError - Style/SpecialGlobalVars (UNSAFE) - Style/SymbolProc (UNSAFE) - Style/ZeroLengthPredicate (UNSAFE)
-rw-r--r--.rubocop.yml3
-rw-r--r--.rubocop_todo.yml169
-rwxr-xr-x[-rw-r--r--]test/benchmark.rb25
-rw-r--r--test/content_type/tc_content_type.rb4
-rw-r--r--test/doc_props/tc_app.rb48
-rw-r--r--test/doc_props/tc_core.rb4
-rw-r--r--test/drawing/tc_area_chart.rb3
-rw-r--r--test/drawing/tc_axis.rb6
-rw-r--r--test/drawing/tc_bar_3D_chart.rb3
-rw-r--r--test/drawing/tc_bar_chart.rb3
-rw-r--r--test/drawing/tc_bar_series.rb2
-rw-r--r--test/drawing/tc_bubble_chart.rb3
-rw-r--r--test/drawing/tc_cat_axis.rb3
-rw-r--r--test/drawing/tc_chart.rb3
-rw-r--r--test/drawing/tc_d_lbls.rb2
-rw-r--r--test/drawing/tc_graphic_frame.rb3
-rw-r--r--test/drawing/tc_hyperlink.rb3
-rw-r--r--test/drawing/tc_line_3d_chart.rb3
-rw-r--r--test/drawing/tc_line_chart.rb3
-rw-r--r--test/drawing/tc_marker.rb3
-rw-r--r--test/drawing/tc_num_data.rb3
-rw-r--r--test/drawing/tc_one_cell_anchor.rb3
-rw-r--r--test/drawing/tc_picture_locking.rb3
-rw-r--r--test/drawing/tc_pie_3D_chart.rb3
-rw-r--r--test/drawing/tc_pie_series.rb2
-rw-r--r--test/drawing/tc_scaling.rb3
-rw-r--r--test/drawing/tc_scatter_chart.rb3
-rw-r--r--test/drawing/tc_ser_axis.rb3
-rw-r--r--test/drawing/tc_series_title.rb7
-rw-r--r--test/drawing/tc_title.rb7
-rw-r--r--test/drawing/tc_val_axis.rb3
-rw-r--r--test/drawing/tc_view_3D.rb3
-rw-r--r--test/drawing/tc_vml_drawing.rb2
-rw-r--r--test/drawing/tc_vml_shape.rb2
-rwxr-xr-x[-rw-r--r--]test/profile.rb4
-rw-r--r--test/rels/tc_relationships.rb5
-rw-r--r--test/stylesheet/tc_border.rb3
-rw-r--r--test/stylesheet/tc_border_pr.rb3
-rw-r--r--test/stylesheet/tc_cell_protection.rb3
-rw-r--r--test/stylesheet/tc_cell_style.rb3
-rw-r--r--test/stylesheet/tc_color.rb3
-rw-r--r--test/stylesheet/tc_dxf.rb3
-rw-r--r--test/stylesheet/tc_fill.rb3
-rw-r--r--test/stylesheet/tc_font.rb3
-rw-r--r--test/stylesheet/tc_gradient_fill.rb3
-rw-r--r--test/stylesheet/tc_gradient_stop.rb3
-rw-r--r--test/stylesheet/tc_num_fmt.rb3
-rw-r--r--test/stylesheet/tc_pattern_fill.rb3
-rw-r--r--test/stylesheet/tc_styles.rb25
-rw-r--r--test/stylesheet/tc_table_style.rb3
-rw-r--r--test/stylesheet/tc_table_style_element.rb5
-rw-r--r--test/stylesheet/tc_table_styles.rb3
-rw-r--r--test/stylesheet/tc_xf.rb3
-rw-r--r--test/tc_axlsx.rb16
-rw-r--r--test/tc_package.rb44
-rw-r--r--test/util/tc_mime_type_utils.rb3
-rw-r--r--test/util/tc_simple_typed_list.rb5
-rw-r--r--test/util/tc_validators.rb8
-rw-r--r--test/workbook/tc_shared_strings_table.rb4
-rw-r--r--test/workbook/tc_workbook.rb3
-rw-r--r--test/workbook/worksheet/tc_cell.rb8
-rw-r--r--test/workbook/worksheet/tc_col.rb2
-rw-r--r--test/workbook/worksheet/tc_comment.rb2
-rw-r--r--test/workbook/worksheet/tc_comments.rb4
-rw-r--r--test/workbook/worksheet/tc_data_validation.rb4
-rw-r--r--test/workbook/worksheet/tc_date_time_converter.rb6
-rw-r--r--test/workbook/worksheet/tc_page_setup.rb6
-rw-r--r--test/workbook/worksheet/tc_rich_text.rb4
-rw-r--r--test/workbook/worksheet/tc_sheet_protection.rb2
-rw-r--r--test/workbook/worksheet/tc_sheet_view.rb4
-rw-r--r--test/workbook/worksheet/tc_table_style_info.rb2
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb36
72 files changed, 272 insertions, 318 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 32a50a30..510c1b4b 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -19,5 +19,8 @@ Layout/CommentIndentation:
Layout/ExtraSpacing:
AllowBeforeTrailingComments: true
+Lint:
+ Enabled: true
+
Style:
Enabled: true
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 67848b74..f17b6eda 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -29,6 +29,87 @@ Layout/HeredocIndentation:
- 'lib/axlsx/drawing/vml_shape.rb'
# This cop supports safe autocorrection (--autocorrect).
+Lint/AmbiguousOperatorPrecedence:
+ Exclude:
+ - 'lib/axlsx/drawing/area_series.rb'
+ - 'lib/axlsx/drawing/line_series.rb'
+ - 'lib/axlsx/drawing/pie_series.rb'
+ - 'lib/axlsx/workbook/worksheet/dimension.rb'
+ - 'lib/axlsx/workbook/worksheet/sheet_protection.rb'
+ - 'lib/axlsx/workbook/worksheet/worksheet.rb'
+
+# This cop supports unsafe autocorrection (--autocorrect-all).
+# Configuration parameters: AllowSafeAssignment.
+Lint/AssignmentInCondition:
+ Exclude:
+ - 'lib/axlsx/drawing/area_chart.rb'
+ - 'lib/axlsx/drawing/line_chart.rb'
+ - 'lib/axlsx/workbook/shared_strings_table.rb'
+
+# This cop supports unsafe autocorrection (--autocorrect-all).
+Lint/BooleanSymbol:
+ Exclude:
+ - 'lib/axlsx/stylesheet/font.rb'
+ - 'lib/axlsx/util/validators.rb'
+ - 'lib/axlsx/workbook/worksheet/cell.rb'
+ - 'lib/axlsx/workbook/worksheet/rich_text_run.rb'
+ - 'test/util/tc_validators.rb'
+ - 'test/workbook/tc_workbook.rb'
+
+# This cop supports unsafe autocorrection (--autocorrect-all).
+Lint/DisjunctiveAssignmentInConstructor:
+ Exclude:
+ - 'lib/axlsx/drawing/num_data_source.rb'
+
+# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
+Lint/DuplicateBranch:
+ Exclude:
+ - 'lib/axlsx/workbook/worksheet/cell.rb'
+ - 'lib/axlsx/workbook/worksheet/merged_cells.rb'
+
+Lint/NonLocalExitFromIterator:
+ Exclude:
+ - 'lib/axlsx/util/validators.rb'
+
+# This cop supports safe autocorrection (--autocorrect).
+Lint/RedundantStringCoercion:
+ Exclude:
+ - 'lib/axlsx/workbook/worksheet/auto_filter/filters.rb'
+ - 'lib/axlsx/workbook/worksheet/cell.rb'
+ - 'lib/axlsx/workbook/worksheet/rich_text_run.rb'
+
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
+Lint/UnusedBlockArgument:
+ Exclude:
+ - 'lib/axlsx.rb'
+ - 'lib/axlsx/drawing/axes.rb'
+ - 'lib/axlsx/workbook/worksheet/pivot_table.rb'
+ - 'lib/axlsx/workbook/worksheet/sheet_view.rb'
+
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
+Lint/UnusedMethodArgument:
+ Exclude:
+ - 'lib/axlsx/package.rb'
+ - 'lib/axlsx/util/serialized_attributes.rb'
+ - 'lib/axlsx/util/validators.rb'
+
+Lint/UselessAssignment:
+ Exclude:
+ - 'lib/axlsx/workbook/worksheet/header_footer.rb'
+ - 'lib/axlsx/workbook/worksheet/sheet_protection.rb'
+
+# Configuration parameters: CheckForMethodsWithNoSideEffects.
+Lint/Void:
+ Exclude:
+ - 'lib/axlsx/drawing/title.rb'
+ - 'lib/axlsx/util/simple_typed_list.rb'
+ - 'lib/axlsx/util/storage.rb'
+ - 'lib/axlsx/workbook/worksheet/data_bar.rb'
+ - 'lib/axlsx/workbook/worksheet/pivot_table.rb'
+
+# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: separated, grouped
Style/AccessorGrouping:
@@ -48,16 +129,6 @@ Style/AndOr:
Exclude:
- 'lib/axlsx/workbook/worksheet/data_validation.rb'
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
-# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
-# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
-# FunctionalMethods: let, let!, subject, watch
-# AllowedMethods: lambda, proc, it
-Style/BlockDelimiters:
- Exclude:
- - 'test/benchmark.rb'
-
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: MinBranchesCount.
Style/CaseLikeIf:
@@ -98,10 +169,6 @@ Style/CommentAnnotation:
- 'lib/axlsx/drawing/axis.rb'
- 'lib/axlsx/drawing/chart.rb'
- 'lib/axlsx/drawing/view_3D.rb'
- - 'test/drawing/tc_pie_series.rb'
- - 'test/workbook/worksheet/tc_cell.rb'
- - 'test/workbook/worksheet/tc_col.rb'
- - 'test/workbook/worksheet/tc_comments.rb'
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/ConcatArrayLiterals:
@@ -145,17 +212,6 @@ Style/Documentation:
- 'lib/axlsx/workbook/worksheet/sheet_format_pr.rb'
# This cop supports safe autocorrection (--autocorrect).
-Style/EachForSimpleLoop:
- Exclude:
- - 'test/workbook/worksheet/tc_rich_text.rb'
-
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: compact, expanded
-Style/EmptyMethod:
- Enabled: false
-
-# This cop supports safe autocorrection (--autocorrect).
Style/EvalWithLocation:
Exclude:
- 'lib/axlsx/util/simple_typed_list.rb'
@@ -164,13 +220,11 @@ Style/EvalWithLocation:
Style/ExpandPathArguments:
Exclude:
- 'axlsx.gemspec'
- - 'test/tc_package.rb'
# This cop supports safe autocorrection (--autocorrect).
Style/FileWrite:
Exclude:
- 'lib/axlsx/util/zip_command.rb'
- - 'test/benchmark.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
@@ -197,11 +251,6 @@ Style/FormatStringToken:
Style/FrozenStringLiteralComment:
Enabled: false
-# This cop supports unsafe autocorrection (--autocorrect-all).
-Style/GlobalStdStream:
- Exclude:
- - 'test/profile.rb'
-
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
@@ -231,8 +280,6 @@ Style/HashConversion:
Style/HashEachMethods:
Exclude:
- 'lib/axlsx/workbook/worksheet/rich_text_run.rb'
- - 'test/workbook/worksheet/tc_table_style_info.rb'
- - 'test/workbook/worksheet/tc_worksheet.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
@@ -280,10 +327,6 @@ Style/MethodCallWithoutArgsParentheses:
Exclude:
- 'lib/axlsx/package.rb'
- 'test/benchmark.rb'
- - 'test/drawing/tc_vml_drawing.rb'
- - 'test/drawing/tc_vml_shape.rb'
- - 'test/workbook/worksheet/tc_comments.rb'
- - 'test/workbook/worksheet/tc_rich_text.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
@@ -340,14 +383,6 @@ Style/NegatedIf:
- 'lib/axlsx/workbook/worksheet/worksheet.rb'
# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: AllowedMethods.
-# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with
-Style/NestedParenthesizedCalls:
- Exclude:
- - 'test/stylesheet/tc_styles.rb'
- - 'test/workbook/worksheet/tc_worksheet.rb'
-
-# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MinBodyLength.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
@@ -364,10 +399,6 @@ Style/NilComparison:
- 'lib/axlsx/drawing/view_3D.rb'
- 'lib/axlsx/workbook/worksheet/sheet_protection.rb'
- 'lib/axlsx/workbook/worksheet/worksheet.rb'
- - 'test/drawing/tc_series_title.rb'
- - 'test/drawing/tc_title.rb'
- - 'test/workbook/worksheet/tc_page_setup.rb'
- - 'test/workbook/worksheet/tc_worksheet.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: IncludeSemanticChanges.
@@ -379,13 +410,6 @@ Style/NonNilCheck:
- 'lib/axlsx/workbook/worksheet/page_setup.rb'
# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedOctalStyle.
-# SupportedOctalStyles: zero_with_o, zero_only
-Style/NumericLiteralPrefix:
- Exclude:
- - 'test/doc_props/tc_core.rb'
-
-# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns.
Style/NumericLiterals:
MinDigits: 11
@@ -407,9 +431,6 @@ Style/NumericPredicate:
- 'test/drawing/tc_marker.rb'
- 'test/drawing/tc_one_cell_anchor.rb'
- 'test/drawing/tc_two_cell_anchor.rb'
- - 'test/rels/tc_relationships.rb'
- - 'test/stylesheet/tc_styles.rb'
- - 'test/tc_package.rb'
- 'test/util/tc_simple_typed_list.rb'
# This cop supports safe autocorrection (--autocorrect).
@@ -443,7 +464,6 @@ Style/ParallelAssignment:
- 'lib/axlsx/drawing/view_3D.rb'
- 'lib/axlsx/package.rb'
- 'lib/axlsx/workbook/worksheet/row.rb'
- - 'test/rels/tc_relationships.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
@@ -485,7 +505,6 @@ Style/PerlBackrefs:
Style/PreferredHashMethods:
Exclude:
- 'lib/axlsx.rb'
- - 'test/workbook/tc_shared_strings_table.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
@@ -531,7 +550,6 @@ Style/RedundantInterpolation:
- 'lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb'
- 'lib/axlsx/workbook/worksheet/table.rb'
- 'lib/axlsx/workbook/worksheet/worksheet.rb'
- - 'test/content_type/tc_content_type.rb'
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantParentheses:
@@ -545,7 +563,6 @@ Style/RedundantParentheses:
- 'lib/axlsx/package.rb'
- 'lib/axlsx/workbook/worksheet/pivot_table.rb'
- 'lib/axlsx/workbook/worksheet/worksheet.rb'
- - 'test/stylesheet/tc_styles.rb'
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
@@ -573,7 +590,6 @@ Style/RedundantSelf:
Style/RegexpLiteral:
Exclude:
- 'lib/axlsx/workbook/worksheet/cell.rb'
- - 'test/tc_package.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
@@ -581,7 +597,6 @@ Style/RegexpLiteral:
Style/RescueStandardError:
Exclude:
- 'lib/axlsx.rb'
- - 'test/workbook/worksheet/tc_date_time_converter.rb'
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
@@ -621,14 +636,6 @@ Style/SoleNestedConditional:
- 'lib/axlsx/util/validators.rb'
# This cop supports unsafe autocorrection (--autocorrect-all).
-# Configuration parameters: RequireEnglish, EnforcedStyle.
-# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
-Style/SpecialGlobalVars:
- Exclude:
- - 'test/benchmark.rb'
- - 'test/profile.rb'
-
-# This cop supports unsafe autocorrection (--autocorrect-all).
Style/StringChars:
Exclude:
- 'lib/axlsx/workbook/worksheet/sheet_protection.rb'
@@ -657,11 +664,6 @@ Style/StringLiteralsInInterpolation:
Style/SymbolArray:
EnforcedStyle: brackets
-# This cop supports safe autocorrection (--autocorrect).
-Style/SymbolLiteral:
- Exclude:
- - 'test/doc_props/tc_app.rb'
-
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments.
# AllowedMethods: define_method
@@ -674,11 +676,6 @@ Style/SymbolProc:
- 'lib/axlsx/workbook/worksheet/conditional_formatting.rb'
- 'lib/axlsx/workbook/worksheet/worksheet.rb'
- 'lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb'
- - 'test/doc_props/tc_app.rb'
- - 'test/doc_props/tc_core.rb'
- - 'test/stylesheet/tc_styles.rb'
- - 'test/workbook/tc_shared_strings_table.rb'
- - 'test/workbook/worksheet/tc_worksheet.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
@@ -741,10 +738,6 @@ Style/ZeroLengthPredicate:
- 'lib/axlsx/util/simple_typed_list.rb'
- 'lib/axlsx/workbook/workbook.rb'
- 'lib/axlsx/workbook/worksheet/sheet_pr.rb'
- - 'test/rels/tc_relationships.rb'
- - 'test/stylesheet/tc_styles.rb'
- - 'test/tc_package.rb'
- - 'test/util/tc_simple_typed_list.rb'
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
diff --git a/test/benchmark.rb b/test/benchmark.rb
index 3c0ebc95..7cbffa32 100644..100755
--- a/test/benchmark.rb
+++ b/test/benchmark.rb
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby -s
-$:.unshift "#{File.dirname(__FILE__)}/../lib"
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'axlsx'
require 'csv'
require 'benchmark'
@@ -9,7 +10,7 @@ input = (32..126).to_a.pack('U*').chars.to_a
20.times { row << input.shuffle.join }
times = 3000
Benchmark.bmbm(30) do |x|
- x.report('axlsx_noautowidth') {
+ x.report('axlsx_noautowidth') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -20,9 +21,9 @@ Benchmark.bmbm(30) do |x|
end
p.use_autowidth = false
p.serialize("example_noautowidth.xlsx")
- }
+ end
- x.report('axlsx') {
+ x.report('axlsx') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -32,9 +33,9 @@ Benchmark.bmbm(30) do |x|
end
end
p.serialize("example_autowidth.xlsx")
- }
+ end
- x.report('axlsx_shared') {
+ x.report('axlsx_shared') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -45,9 +46,9 @@ Benchmark.bmbm(30) do |x|
end
p.use_shared_strings = true
p.serialize("example_shared.xlsx")
- }
+ end
- x.report('axlsx_stream') {
+ x.report('axlsx_stream') do
p = Axlsx::Package.new
p.workbook do |wb|
wb.add_worksheet do |sheet|
@@ -57,15 +58,15 @@ Benchmark.bmbm(30) do |x|
end
end
s = p.to_stream()
- File.open('example_streamed.xlsx', 'wb') { |f| f.write(s.read) }
- }
+ File.binwrite('example_streamed.xlsx', s.read)
+ end
- x.report('csv') {
+ x.report('csv') do
CSV.open("example.csv", "wb") do |csv|
times.times do
csv << row
end
end
- }
+ end
end
File.delete("example.csv", "example_streamed.xlsx", "example_shared.xlsx", "example_autowidth.xlsx", "example_noautowidth.xlsx")
diff --git a/test/content_type/tc_content_type.rb b/test/content_type/tc_content_type.rb
index c79352ff..a657f7e2 100644
--- a/test/content_type/tc_content_type.rb
+++ b/test/content_type/tc_content_type.rb
@@ -19,10 +19,10 @@ class TestContentType < Test::Unit::TestCase
assert_equal(@doc.xpath("//xmlns:Default").size, 2, "There should be 2 default types")
node = @doc.xpath(d_path % Axlsx::XML_CT).first
- assert_equal(node["Extension"], "#{Axlsx::XML_EX}", "xml content type invalid")
+ assert_equal(node["Extension"], Axlsx::XML_EX.to_s, "xml content type invalid")
node = @doc.xpath(d_path % Axlsx::RELS_CT).first
- assert_equal(node["Extension"], "#{Axlsx::RELS_EX}", "relationships content type invalid")
+ assert_equal(node["Extension"], Axlsx::RELS_EX.to_s, "relationships content type invalid")
# overrride
assert_equal(@doc.xpath("//xmlns:Override").size, 4, "There should be 4 Override types")
diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb
index a7124be1..cee3e564 100644
--- a/test/doc_props/tc_app.rb
+++ b/test/doc_props/tc_app.rb
@@ -3,29 +3,29 @@ require 'tc_helper.rb'
class TestApp < Test::Unit::TestCase
def setup
options = {
- :'Template' => 'Foo.xlt',
- :'Manager' => 'Penny',
- :'Company' => "Bob's Repair",
- :'Pages' => 1,
- :'Words' => 2,
- :'Characters' => 7,
- :'PresentationFormat' => 'any',
- :'Lines' => 1,
- :'Paragraphs' => 1,
- :'Slides' => 4,
- :'Notes' => 1,
- :'TotalTime' => 2,
- :'HidddenSlides' => 3,
- :'MMClips' => 10,
- :'ScaleCrop' => true,
- :'LinksUpToDate' => true,
- :'CharactersWithSpaces' => 9,
- :'SharedDoc' => false,
- :'HyperlinkBase' => 'foo',
- :'HyperlInksChanged' => false,
- :'Application' => 'axlsx',
- :'AppVersion' => '1.1.5',
- :'DocSecurity' => 0
+ :Template => 'Foo.xlt',
+ :Manager => 'Penny',
+ :Company => "Bob's Repair",
+ :Pages => 1,
+ :Words => 2,
+ :Characters => 7,
+ :PresentationFormat => 'any',
+ :Lines => 1,
+ :Paragraphs => 1,
+ :Slides => 4,
+ :Notes => 1,
+ :TotalTime => 2,
+ :HidddenSlides => 3,
+ :MMClips => 10,
+ :ScaleCrop => true,
+ :LinksUpToDate => true,
+ :CharactersWithSpaces => 9,
+ :SharedDoc => false,
+ :HyperlinkBase => 'foo',
+ :HyperlInksChanged => false,
+ :Application => 'axlsx',
+ :AppVersion => '1.1.5',
+ :DocSecurity => 0
}
@app = Axlsx::App.new options
@@ -38,6 +38,6 @@ class TestApp < Test::Unit::TestCase
schema.validate(doc).each do |error|
errors << error
end
- assert_equal(errors.size, 0, "app.xml invalid" + errors.map { |e| e.message }.to_s)
+ assert_equal(errors.size, 0, "app.xml invalid" + errors.map(&:message).to_s)
end
end
diff --git a/test/doc_props/tc_core.rb b/test/doc_props/tc_core.rb
index b225266a..d5412a4f 100644
--- a/test/doc_props/tc_core.rb
+++ b/test/doc_props/tc_core.rb
@@ -15,7 +15,7 @@ class TestCore < Test::Unit::TestCase
puts error.message
errors << error
end
- assert_equal(errors.size, 0, "core.xml Invalid" + errors.map { |e| e.message }.to_s)
+ assert_equal(errors.size, 0, "core.xml Invalid" + errors.map(&:message).to_s)
end
def test_populates_created
@@ -23,7 +23,7 @@ class TestCore < Test::Unit::TestCase
end
def test_created_as_option
- time = Time.utc(2013, 1, 1, 12, 00)
+ time = Time.utc(2013, 1, 1, 12, 0)
c = Axlsx::Core.new :created => time
doc = Nokogiri::XML(c.to_xml_string)
assert_equal(doc.xpath('//dcterms:created').text, time.xmlschema, "dcterms:created incorrect")
diff --git a/test/drawing/tc_area_chart.rb b/test/drawing/tc_area_chart.rb
index fc928db9..490df25a 100644
--- a/test/drawing/tc_area_chart.rb
+++ b/test/drawing/tc_area_chart.rb
@@ -8,8 +8,7 @@ class TestAreaChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::AreaChart, :title => "fishery"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.grouping, :standard, "grouping defualt incorrect")
diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb
index 0f7108eb..0b3bddc0 100644
--- a/test/drawing/tc_axis.rb
+++ b/test/drawing/tc_axis.rb
@@ -103,9 +103,9 @@ class TestAxis < Test::Unit::TestCase
str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">'
doc = Nokogiri::XML(@axis.to_xml_string(str))
assert(doc.xpath('//a:noFill'))
- assert(doc.xpath("//c:crosses[@val='#{@axis.crosses.to_s}']"))
- assert(doc.xpath("//c:crossAx[@val='#{@axis.cross_axis.to_s}']"))
- assert(doc.xpath("//a:bodyPr[@rot='#{@axis.label_rotation.to_s}']"))
+ assert(doc.xpath("//c:crosses[@val='#{@axis.crosses}']"))
+ assert(doc.xpath("//c:crossAx[@val='#{@axis.cross_axis}']"))
+ assert(doc.xpath("//a:bodyPr[@rot='#{@axis.label_rotation}']"))
assert(doc.xpath("//a:t[text()='Foo']"))
end
end
diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb
index 3c22e191..178ee65a 100644
--- a/test/drawing/tc_bar_3D_chart.rb
+++ b/test/drawing/tc_bar_3D_chart.rb
@@ -8,8 +8,7 @@ class TestBar3DChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect")
diff --git a/test/drawing/tc_bar_chart.rb b/test/drawing/tc_bar_chart.rb
index 5106d266..62927bc7 100644
--- a/test/drawing/tc_bar_chart.rb
+++ b/test/drawing/tc_bar_chart.rb
@@ -8,8 +8,7 @@ class TestBarChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::BarChart, :title => "fishery"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect")
diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb
index 39d39b96..a1f98f64 100644
--- a/test/drawing/tc_bar_series.rb
+++ b/test/drawing/tc_bar_series.rb
@@ -36,7 +36,7 @@ class TestBarSeries < Test::Unit::TestCase
def test_to_xml_string
doc = Nokogiri::XML(@chart.to_xml_string)
- @series.colors.each_with_index do |color, index|
+ @series.colors.each_with_index do |_color, index|
assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size, 1)
assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size, 1)
end
diff --git a/test/drawing/tc_bubble_chart.rb b/test/drawing/tc_bubble_chart.rb
index 02745f92..eb07afee 100644
--- a/test/drawing/tc_bubble_chart.rb
+++ b/test/drawing/tc_bubble_chart.rb
@@ -21,8 +21,7 @@ class TestBubbleChart < Test::Unit::TestCase
end
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.series_type, Axlsx::BubbleSeries, "series type incorrect")
diff --git a/test/drawing/tc_cat_axis.rb b/test/drawing/tc_cat_axis.rb
index 79c0f8db..2cb029cc 100644
--- a/test/drawing/tc_cat_axis.rb
+++ b/test/drawing/tc_cat_axis.rb
@@ -5,8 +5,7 @@ class TestCatAxis < Test::Unit::TestCase
@axis = Axlsx::CatAxis.new
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@axis.auto, 1, "axis auto default incorrect")
diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb
index 4f60db17..c39bdc11 100644
--- a/test/drawing/tc_chart.rb
+++ b/test/drawing/tc_chart.rb
@@ -10,8 +10,7 @@ class TestChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::Bar3DChart, :title => "fishery", :bg_color => "000000"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@p.workbook.charts.last, @chart, "the chart is in the workbook")
diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb
index a8647f9c..7f4f77e5 100644
--- a/test/drawing/tc_d_lbls.rb
+++ b/test/drawing/tc_d_lbls.rb
@@ -20,7 +20,7 @@ class TestDLbls < Test::Unit::TestCase
end
def test_initialization_with_optoins
- options_hash = Hash[*[@boolean_attributes.map { |name| [name, true] }]]
+ options_hash = @boolean_attributes.map { |name| [name, true] }.to_h
d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart, options_hash.merge({ :d_lbl_pos => :t }))
diff --git a/test/drawing/tc_graphic_frame.rb b/test/drawing/tc_graphic_frame.rb
index eb638489..c57c4d96 100644
--- a/test/drawing/tc_graphic_frame.rb
+++ b/test/drawing/tc_graphic_frame.rb
@@ -8,8 +8,7 @@ class TestGraphicFrame < Test::Unit::TestCase
@frame = @chart.graphic_frame
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert(@frame.anchor.is_a?(Axlsx::TwoCellAnchor))
diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb
index f9deb5b8..dd27d084 100644
--- a/test/drawing/tc_hyperlink.rb
+++ b/test/drawing/tc_hyperlink.rb
@@ -9,8 +9,7 @@ class TestHyperlink < Test::Unit::TestCase
@hyperlink = @image.hyperlink
end
- def teardown
- end
+ def teardown; end
def test_href
assert_nothing_raised { @hyperlink.href = "http://axlsx.blogspot.com" }
diff --git a/test/drawing/tc_line_3d_chart.rb b/test/drawing/tc_line_3d_chart.rb
index c91e9216..64603b11 100644
--- a/test/drawing/tc_line_3d_chart.rb
+++ b/test/drawing/tc_line_3d_chart.rb
@@ -8,8 +8,7 @@ class TestLine3DChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::Line3DChart, :title => "fishery"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.grouping, :standard, "grouping defualt incorrect")
diff --git a/test/drawing/tc_line_chart.rb b/test/drawing/tc_line_chart.rb
index 113ef844..4a96af44 100644
--- a/test/drawing/tc_line_chart.rb
+++ b/test/drawing/tc_line_chart.rb
@@ -8,8 +8,7 @@ class TestLineChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::LineChart, :title => "fishery"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.grouping, :standard, "grouping defualt incorrect")
diff --git a/test/drawing/tc_marker.rb b/test/drawing/tc_marker.rb
index ccfb76fe..bc801965 100644
--- a/test/drawing/tc_marker.rb
+++ b/test/drawing/tc_marker.rb
@@ -5,8 +5,7 @@ class TestMarker < Test::Unit::TestCase
@marker = Axlsx::Marker.new
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert(@marker.col == 0)
diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb
index 7e7e12e3..10e35785 100644
--- a/test/drawing/tc_num_data.rb
+++ b/test/drawing/tc_num_data.rb
@@ -9,8 +9,7 @@ class TestNumData < Test::Unit::TestCase
assert_equal(@num_data.format_code, "General")
end
- def test_formula_based_cell
- end
+ def test_formula_based_cell; end
def test_format_code
assert_raise(ArgumentError) { @num_data.format_code = 7 }
diff --git a/test/drawing/tc_one_cell_anchor.rb b/test/drawing/tc_one_cell_anchor.rb
index 1b18f12e..e0f9da43 100644
--- a/test/drawing/tc_one_cell_anchor.rb
+++ b/test/drawing/tc_one_cell_anchor.rb
@@ -9,8 +9,7 @@ class TestOneCellAnchor < Test::Unit::TestCase
@anchor = @image.anchor
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert(@anchor.from.col == 0)
diff --git a/test/drawing/tc_picture_locking.rb b/test/drawing/tc_picture_locking.rb
index 6e5de47b..2543b1ca 100644
--- a/test/drawing/tc_picture_locking.rb
+++ b/test/drawing/tc_picture_locking.rb
@@ -5,8 +5,7 @@ class TestPictureLocking < Test::Unit::TestCase
@item = Axlsx::PictureLocking.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(Axlsx.instance_values_for(@item).size, 1)
diff --git a/test/drawing/tc_pie_3D_chart.rb b/test/drawing/tc_pie_3D_chart.rb
index f536f086..9692ccc4 100644
--- a/test/drawing/tc_pie_3D_chart.rb
+++ b/test/drawing/tc_pie_3D_chart.rb
@@ -8,8 +8,7 @@ class TestPie3DChart < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::Pie3DChart, :title => "fishery"
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@chart.view_3D.rot_x, 30, "view 3d default rot_x incorrect")
diff --git a/test/drawing/tc_pie_series.rb b/test/drawing/tc_pie_series.rb
index c3f5bb3a..2c897fd2 100644
--- a/test/drawing/tc_pie_series.rb
+++ b/test/drawing/tc_pie_series.rb
@@ -27,5 +27,5 @@ class TestPieSeries < Test::Unit::TestCase
doc = Nokogiri::XML(@series.to_xml_string)
assert(doc.xpath("//srgbClr[@val='#{@series.colors[0]}']"))
end
- # TODO test unique serialization parts
+ # TODO: test unique serialization parts
end
diff --git a/test/drawing/tc_scaling.rb b/test/drawing/tc_scaling.rb
index 8f92a024..1cd1538b 100644
--- a/test/drawing/tc_scaling.rb
+++ b/test/drawing/tc_scaling.rb
@@ -5,8 +5,7 @@ class TestScaling < Test::Unit::TestCase
@scaling = Axlsx::Scaling.new
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert(@scaling.orientation == :minMax)
diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb
index 359f7206..42d4a773 100644
--- a/test/drawing/tc_scatter_chart.rb
+++ b/test/drawing/tc_scatter_chart.rb
@@ -19,8 +19,7 @@ class TestScatterChart < Test::Unit::TestCase
end
end
- def teardown
- end
+ def teardown; end
def test_scatter_style
@chart.scatterStyle = :marker
diff --git a/test/drawing/tc_ser_axis.rb b/test/drawing/tc_ser_axis.rb
index 4b498a12..80800fb5 100644
--- a/test/drawing/tc_ser_axis.rb
+++ b/test/drawing/tc_ser_axis.rb
@@ -5,8 +5,7 @@ class TestSerAxis < Test::Unit::TestCase
@axis = Axlsx::SerAxis.new
end
- def teardown
- end
+ def teardown; end
def test_options
a = Axlsx::SerAxis.new(:tick_lbl_skip => 9, :tick_mark_skip => 7)
diff --git a/test/drawing/tc_series_title.rb b/test/drawing/tc_series_title.rb
index b85aece3..a304802b 100644
--- a/test/drawing/tc_series_title.rb
+++ b/test/drawing/tc_series_title.rb
@@ -9,19 +9,18 @@ class TestSeriesTitle < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::Bar3DChart
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert(@title.text == "")
- assert(@title.cell == nil)
+ assert(@title.cell.nil?)
end
def test_text
assert_raise(ArgumentError, "text must be a string") { @title.text = 123 }
@title.cell = @row.cells.first
@title.text = "bob"
- assert(@title.cell == nil, "setting title with text clears the cell")
+ assert(@title.cell.nil?, "setting title with text clears the cell")
end
def test_cell
diff --git a/test/drawing/tc_title.rb b/test/drawing/tc_title.rb
index eb549b35..f26c307e 100644
--- a/test/drawing/tc_title.rb
+++ b/test/drawing/tc_title.rb
@@ -11,12 +11,11 @@ class TestTitle < Test::Unit::TestCase
@chart = ws.add_chart Axlsx::Bar3DChart
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert(@title.text == "")
- assert(@title.cell == nil)
+ assert(@title.cell.nil?)
end
def test_initialize_title_size
@@ -28,7 +27,7 @@ class TestTitle < Test::Unit::TestCase
assert_raise(ArgumentError, "text must be a string") { @title.text = 123 }
@title.cell = @row.cells.first
@title.text = "bob"
- assert(@title.cell == nil, "setting title with text clears the cell")
+ assert(@title.cell.nil?, "setting title with text clears the cell")
end
def test_cell
diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb
index a607ddb1..cc67f448 100644
--- a/test/drawing/tc_val_axis.rb
+++ b/test/drawing/tc_val_axis.rb
@@ -5,8 +5,7 @@ class TestValAxis < Test::Unit::TestCase
@axis = Axlsx::ValAxis.new
end
- def teardown
- end
+ def teardown; end
def test_initialization
assert_equal(@axis.cross_between, :between, "axis crossBetween default incorrect")
diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb
index 43116023..6d59c219 100644
--- a/test/drawing/tc_view_3D.rb
+++ b/test/drawing/tc_view_3D.rb
@@ -5,8 +5,7 @@ class TestView3D < Test::Unit::TestCase
@view = Axlsx::View3D.new
end
- def teardown
- end
+ def teardown; end
def test_options
v = Axlsx::View3D.new :rot_x => 10, :rot_y => 5, :h_percent => "30%", :depth_percent => "45%", :r_ang_ax => false, :perspective => 10
diff --git a/test/drawing/tc_vml_drawing.rb b/test/drawing/tc_vml_drawing.rb
index debba561..1e2132af 100644
--- a/test/drawing/tc_vml_drawing.rb
+++ b/test/drawing/tc_vml_drawing.rb
@@ -15,7 +15,7 @@ class TestVmlDrawing < Test::Unit::TestCase
end
def test_to_xml_string
- str = @vml_drawing.to_xml_string()
+ str = @vml_drawing.to_xml_string
doc = Nokogiri::XML(str)
assert_equal(doc.xpath("//v:shape").size, 2)
assert(doc.xpath("//o:idmap[@o:data='#{@ws.index + 1}']"))
diff --git a/test/drawing/tc_vml_shape.rb b/test/drawing/tc_vml_shape.rb
index b8344a92..f93ea48d 100644
--- a/test/drawing/tc_vml_shape.rb
+++ b/test/drawing/tc_vml_shape.rb
@@ -92,7 +92,7 @@ class TestVmlShape < Test::Unit::TestCase
end
def test_to_xml_string
- str = @comments.vml_drawing.to_xml_string()
+ str = @comments.vml_drawing.to_xml_string
doc = Nokogiri::XML(str)
assert_equal(doc.xpath("//v:shape").size, 2)
assert_equal(1, doc.xpath("//x:Visible").size, 'ClientData/x:Visible element rendering')
diff --git a/test/profile.rb b/test/profile.rb
index ef42c2f8..a81c813b 100644..100755
--- a/test/profile.rb
+++ b/test/profile.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby -s
-$:.unshift "#{File.dirname(__FILE__)}/../lib"
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'axlsx'
require 'ruby-prof'
# RubyProf.measure_mode = RubyProf::MEMORY
@@ -21,4 +21,4 @@ profile = RubyProf.profile do
end
printer = RubyProf::FlatPrinter.new(profile)
-printer.print(STDOUT, {})
+printer.print($stdout, {})
diff --git a/test/rels/tc_relationships.rb b/test/rels/tc_relationships.rb
index 43e413cd..35adbc9b 100644
--- a/test/rels/tc_relationships.rb
+++ b/test/rels/tc_relationships.rb
@@ -2,7 +2,8 @@ require 'tc_helper.rb'
class TestRelationships < Test::Unit::TestCase
def test_for
- source_obj_1, source_obj_2 = Object.new, Object.new
+ source_obj_1 = Object.new
+ source_obj_2 = Object.new
rel_1 = Axlsx::Relationship.new(source_obj_1, Axlsx::WORKSHEET_R, "bar")
rel_2 = Axlsx::Relationship.new(source_obj_2, Axlsx::WORKSHEET_R, "bar")
rels = Axlsx::Relationships.new
@@ -30,6 +31,6 @@ class TestRelationships < Test::Unit::TestCase
errors << error
end
- assert(errors.size == 0)
+ assert(errors.empty?)
end
end
diff --git a/test/stylesheet/tc_border.rb b/test/stylesheet/tc_border.rb
index 9e29dda4..f7791d94 100644
--- a/test/stylesheet/tc_border.rb
+++ b/test/stylesheet/tc_border.rb
@@ -5,8 +5,7 @@ class TestBorder < Test::Unit::TestCase
@b = Axlsx::Border.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@b.diagonalUp, nil)
diff --git a/test/stylesheet/tc_border_pr.rb b/test/stylesheet/tc_border_pr.rb
index 3b25575b..652f4f6d 100644
--- a/test/stylesheet/tc_border_pr.rb
+++ b/test/stylesheet/tc_border_pr.rb
@@ -5,8 +5,7 @@ class TestBorderPr < Test::Unit::TestCase
@bpr = Axlsx::BorderPr.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@bpr.color, nil)
diff --git a/test/stylesheet/tc_cell_protection.rb b/test/stylesheet/tc_cell_protection.rb
index a1fc59b2..253b6c82 100644
--- a/test/stylesheet/tc_cell_protection.rb
+++ b/test/stylesheet/tc_cell_protection.rb
@@ -5,8 +5,7 @@ class TestCellProtection < Test::Unit::TestCase
@item = Axlsx::CellProtection.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.hidden, nil)
diff --git a/test/stylesheet/tc_cell_style.rb b/test/stylesheet/tc_cell_style.rb
index 18e7a1ab..06f20af3 100644
--- a/test/stylesheet/tc_cell_style.rb
+++ b/test/stylesheet/tc_cell_style.rb
@@ -5,8 +5,7 @@ class TestCellStyle < Test::Unit::TestCase
@item = Axlsx::CellStyle.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.name, nil)
diff --git a/test/stylesheet/tc_color.rb b/test/stylesheet/tc_color.rb
index 8f87111e..46e94f88 100644
--- a/test/stylesheet/tc_color.rb
+++ b/test/stylesheet/tc_color.rb
@@ -5,8 +5,7 @@ class TestColor < Test::Unit::TestCase
@item = Axlsx::Color.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.auto, nil)
diff --git a/test/stylesheet/tc_dxf.rb b/test/stylesheet/tc_dxf.rb
index 9e87007d..ecbd7112 100644
--- a/test/stylesheet/tc_dxf.rb
+++ b/test/stylesheet/tc_dxf.rb
@@ -6,8 +6,7 @@ class TestDxf < Test::Unit::TestCase
@styles = Axlsx::Styles.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.alignment, nil)
diff --git a/test/stylesheet/tc_fill.rb b/test/stylesheet/tc_fill.rb
index dd61204f..6e586e45 100644
--- a/test/stylesheet/tc_fill.rb
+++ b/test/stylesheet/tc_fill.rb
@@ -5,8 +5,7 @@ class TestFill < Test::Unit::TestCase
@item = Axlsx::Fill.new Axlsx::PatternFill.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert(@item.fill_type.is_a?(Axlsx::PatternFill))
diff --git a/test/stylesheet/tc_font.rb b/test/stylesheet/tc_font.rb
index 821e8820..601e7a65 100644
--- a/test/stylesheet/tc_font.rb
+++ b/test/stylesheet/tc_font.rb
@@ -5,8 +5,7 @@ class TestFont < Test::Unit::TestCase
@item = Axlsx::Font.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.name, nil)
diff --git a/test/stylesheet/tc_gradient_fill.rb b/test/stylesheet/tc_gradient_fill.rb
index 3950fcf7..3707cdad 100644
--- a/test/stylesheet/tc_gradient_fill.rb
+++ b/test/stylesheet/tc_gradient_fill.rb
@@ -5,8 +5,7 @@ class TestGradientFill < Test::Unit::TestCase
@item = Axlsx::GradientFill.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.type, :linear)
diff --git a/test/stylesheet/tc_gradient_stop.rb b/test/stylesheet/tc_gradient_stop.rb
index 6dc140e0..a4cd4ef8 100644
--- a/test/stylesheet/tc_gradient_stop.rb
+++ b/test/stylesheet/tc_gradient_stop.rb
@@ -5,8 +5,7 @@ class TestGradientStop < Test::Unit::TestCase
@item = Axlsx::GradientStop.new(Axlsx::Color.new(:rgb => "FFFF0000"), 1.0)
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.color.rgb, "FFFF0000")
diff --git a/test/stylesheet/tc_num_fmt.rb b/test/stylesheet/tc_num_fmt.rb
index 7c34be28..63c818b0 100644
--- a/test/stylesheet/tc_num_fmt.rb
+++ b/test/stylesheet/tc_num_fmt.rb
@@ -5,8 +5,7 @@ class TestNumFmt < Test::Unit::TestCase
@item = Axlsx::NumFmt.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.numFmtId, 0)
diff --git a/test/stylesheet/tc_pattern_fill.rb b/test/stylesheet/tc_pattern_fill.rb
index 1126e919..228d7ca2 100644
--- a/test/stylesheet/tc_pattern_fill.rb
+++ b/test/stylesheet/tc_pattern_fill.rb
@@ -5,8 +5,7 @@ class TestPatternFill < Test::Unit::TestCase
@item = Axlsx::PatternFill.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.patternType, :none)
diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb
index 1598a658..d6e9115a 100644
--- a/test/stylesheet/tc_styles.rb
+++ b/test/stylesheet/tc_styles.rb
@@ -5,8 +5,7 @@ class TestStyles < Test::Unit::TestCase
@styles = Axlsx::Styles.new
end
- def teardown
- end
+ def teardown; end
def test_valid_document
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
@@ -16,7 +15,7 @@ class TestStyles < Test::Unit::TestCase
errors.push error
puts error.message
end
- assert(errors.size == 0)
+ assert(errors.empty?)
end
def test_add_style_border_hash
@@ -73,7 +72,7 @@ class TestStyles < Test::Unit::TestCase
f_code = { :format_code => "YYYY/MM" }
num_fmt = { :num_fmt => 5 }
assert_equal(@styles.parse_num_fmt_options, nil, 'noop if neither :format_code or :num_fmt exist')
- max = @styles.numFmts.map { |nf| nf.numFmtId }.max
+ max = @styles.numFmts.map(&:numFmtId).max
@styles.parse_num_fmt_options(f_code)
assert_equal(@styles.numFmts.last.numFmtId, max + 1, "new numfmts gets next available id")
assert(@styles.parse_num_fmt_options(num_fmt).is_a?(Integer), "Should return the provided num_fmt if not dxf")
@@ -89,7 +88,7 @@ class TestStyles < Test::Unit::TestCase
def test_parse_border_basic_options
b_opts = { :border => { :diagonalUp => 1, :edges => [:left, :right], :color => "FFDADADA", :style => :thick } }
b = @styles.parse_border_options b_opts
- assert(b.is_a? Integer)
+ assert(b.is_a?(Integer))
assert_equal(@styles.parse_border_options(b_opts.merge({ :type => :dxf })).class, Axlsx::Border)
assert(@styles.borders.last.diagonalUp == 1, "border options are passed in to the initializer")
end
@@ -129,7 +128,7 @@ class TestStyles < Test::Unit::TestCase
end
def test_parse_alignment_options
- assert_equal(@styles.parse_alignment_options {}, nil, "noop if :alignment is not set")
+ assert_equal(@styles.parse_alignment_options, nil, "noop if :alignment is not set")
assert(@styles.parse_alignment_options(:alignment => {}).is_a?(Axlsx::CellAlignment))
end
@@ -140,7 +139,7 @@ class TestStyles < Test::Unit::TestCase
original_attributes = Axlsx.instance_values_for(original)
assert_equal(1, created.b)
assert_equal(99, created.sz)
- copied = original_attributes.reject { |key, value| %w(b sz).include? key }
+ copied = original_attributes.reject { |key, _value| %w(b sz).include? key }
instance_vals = Axlsx.instance_values_for(created)
copied.each do |key, value|
assert_equal(instance_vals[key], value)
@@ -161,7 +160,7 @@ class TestStyles < Test::Unit::TestCase
:family => 1,
:font_name => "woot font"
}
- assert_equal(@styles.parse_font_options {}, nil, "noop if no font keys are set")
+ assert_equal(@styles.parse_font_options, nil, "noop if no font keys are set")
assert(@styles.parse_font_options(:b => 1).is_a?(Integer), "return index of font if not :dxf type")
assert_equal(@styles.parse_font_options(:b => 1, :type => :dxf).class, Axlsx::Font, "return font object if :dxf type")
@@ -175,7 +174,7 @@ class TestStyles < Test::Unit::TestCase
end
def test_parse_fill_options
- assert_equal(@styles.parse_fill_options {}, nil, "noop if no fill keys are set")
+ assert_equal(@styles.parse_fill_options, nil, "noop if no fill keys are set")
assert(@styles.parse_fill_options(:bg_color => "DE").is_a?(Integer), "return index of fill if not :dxf type")
assert_equal(@styles.parse_fill_options(:bg_color => "DE", :type => :dxf).class, Axlsx::Fill, "return fill object if :dxf type")
f = @styles.parse_fill_options(:bg_color => "DE", :type => :dxf)
@@ -183,7 +182,7 @@ class TestStyles < Test::Unit::TestCase
end
def test_parse_protection_options
- assert_equal(@styles.parse_protection_options {}, nil, "noop if no protection keys are set")
+ assert_equal(@styles.parse_protection_options, nil, "noop if no protection keys are set")
assert_equal(@styles.parse_protection_options(:hidden => 1).class, Axlsx::CellProtection, "creates a new cell protection object")
end
@@ -240,8 +239,8 @@ class TestStyles < Test::Unit::TestCase
dxf = @styles.dxfs.last
assert_equal(@styles.dxfs.last.fill.fill_type.bgColor.rgb, "FF000000", "fill created with color")
- assert_equal(font_count, (@styles.fonts.size), "font not created under styles")
- assert_equal(fill_count, (@styles.fills.size), "fill not created under styles")
+ assert_equal(font_count, @styles.fonts.size, "font not created under styles")
+ assert_equal(fill_count, @styles.fills.size, "fill not created under styles")
assert(dxf.border.is_a?(Axlsx::Border), "border is set")
assert_equal(nil, dxf.numFmt, "number format is not set")
@@ -284,7 +283,7 @@ class TestStyles < Test::Unit::TestCase
errors.push error
puts error.message
end
- assert(errors.size == 0)
+ assert(errors.empty?)
end
def test_border_top_without_border_regression
diff --git a/test/stylesheet/tc_table_style.rb b/test/stylesheet/tc_table_style.rb
index f86cc54c..a003c37a 100644
--- a/test/stylesheet/tc_table_style.rb
+++ b/test/stylesheet/tc_table_style.rb
@@ -5,8 +5,7 @@ class TestTableStyle < Test::Unit::TestCase
@item = Axlsx::TableStyle.new "fisher"
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.name, "fisher")
diff --git a/test/stylesheet/tc_table_style_element.rb b/test/stylesheet/tc_table_style_element.rb
index 021d4fca..2b52a23d 100644
--- a/test/stylesheet/tc_table_style_element.rb
+++ b/test/stylesheet/tc_table_style_element.rb
@@ -5,8 +5,7 @@ class TestTableStyleElement < Test::Unit::TestCase
@item = Axlsx::TableStyleElement.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.type, nil)
@@ -39,6 +38,6 @@ class TestTableStyleElement < Test::Unit::TestCase
def test_to_xml_string
doc = Nokogiri::XML(@item.to_xml_string)
@item.type = :headerRow
- assert(doc.xpath("//tableStyleElement[@type='#{@item.type.to_s}']"))
+ assert(doc.xpath("//tableStyleElement[@type='#{@item.type}']"))
end
end
diff --git a/test/stylesheet/tc_table_styles.rb b/test/stylesheet/tc_table_styles.rb
index 751874b1..5ce315d5 100644
--- a/test/stylesheet/tc_table_styles.rb
+++ b/test/stylesheet/tc_table_styles.rb
@@ -5,8 +5,7 @@ class TestTableStyles < Test::Unit::TestCase
@item = Axlsx::TableStyles.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.defaultTableStyle, "TableStyleMedium9")
diff --git a/test/stylesheet/tc_xf.rb b/test/stylesheet/tc_xf.rb
index 00e2a8a3..9a972aaf 100644
--- a/test/stylesheet/tc_xf.rb
+++ b/test/stylesheet/tc_xf.rb
@@ -5,8 +5,7 @@ class TestXf < Test::Unit::TestCase
@item = Axlsx::Xf.new
end
- def teardown
- end
+ def teardown; end
def test_initialiation
assert_equal(@item.alignment, nil)
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb
index 73fdd9ab..ccfdbfab 100644
--- a/test/tc_axlsx.rb
+++ b/test/tc_axlsx.rb
@@ -3,14 +3,14 @@ require 'tc_helper.rb'
class TestAxlsx < Test::Unit::TestCase
def setup_wide
@wide_test_points = {
- "A3" => 0,
- "Z3" => 25,
- "B3" => 1,
- "AA3" => 1 * 26 + 0,
- "AAA3" => 1 * 26**2 + 1 * 26 + 0,
- "AAZ3" => 1 * 26**2 + 1 * 26 + 25,
- "ABA3" => 1 * 26**2 + 2 * 26 + 0,
- "BZU3" => 2 * 26**2 + 26 * 26 + 20
+ "A3" => 0,
+ "Z3" => 25,
+ "B3" => 1,
+ "AA3" => (1 * 26) + 0,
+ "AAA3" => (1 * (26**2)) + (1 * 26) + 0,
+ "AAZ3" => (1 * (26**2)) + (1 * 26) + 25,
+ "ABA3" => (1 * (26**2)) + (2 * 26) + 0,
+ "BZU3" => (2 * (26**2)) + (26 * 26) + 20
}
end
diff --git a/test/tc_package.rb b/test/tc_package.rb
index cc40a6e0..58fe8e76 100644
--- a/test/tc_package.rb
+++ b/test/tc_package.rb
@@ -67,7 +67,7 @@ class TestPackage < Test::Unit::TestCase
end
@fname = 'axlsx_test_serialization.xlsx'
- img = File.expand_path('../fixtures/image1.jpeg', __FILE__)
+ img = File.expand_path('fixtures/image1.jpeg', __dir__)
ws.add_image(:image_src => img, :noSelect => true, :noMove => true, :hyperlink => "http://axlsx.blogspot.com") do |image|
image.width = 720
image.height = 666
@@ -75,12 +75,12 @@ class TestPackage < Test::Unit::TestCase
image.start_at 5, 5
image.end_at 10, 10
end
- ws.add_image :image_src => File.expand_path('../fixtures/image1.gif', __FILE__) do |image|
+ ws.add_image :image_src => File.expand_path('fixtures/image1.gif', __dir__) do |image|
image.start_at 0, 20
image.width = 360
image.height = 333
end
- ws.add_image :image_src => File.expand_path('../fixtures/image1.png', __FILE__) do |image|
+ ws.add_image :image_src => File.expand_path('fixtures/image1.png', __dir__) do |image|
image.start_at 9, 20
image.width = 180
image.height = 167
@@ -118,7 +118,7 @@ class TestPackage < Test::Unit::TestCase
assert(Axlsx.instance_values_for(@package)["app"].is_a?(Axlsx::App), 'App object not created')
assert(Axlsx.instance_values_for(@package)["core"].is_a?(Axlsx::Core), 'Core object not created')
assert(@package.workbook.is_a?(Axlsx::Workbook), 'Workbook object not created')
- assert(Axlsx::Package.new.workbook.worksheets.size == 0, 'Workbook should not have sheets by default')
+ assert(Axlsx::Package.new.workbook.worksheets.empty?, 'Workbook should not have sheets by default')
end
def test_created_at_is_propagated_to_core
@@ -244,28 +244,28 @@ class TestPackage < Test::Unit::TestCase
def test_validation
assert_equal(@package.validate.size, 0, @package.validate)
Axlsx::Workbook.send(:class_variable_set, :@@date1904, 9900)
- assert(@package.validate.size > 0)
end
def test_parts
p = @package.send(:parts)
# all parts have an entry
- assert_equal(p.select { |part| part[:entry] =~ /_rels\/\.rels/ }.size, 1, "rels missing")
- assert_equal(p.select { |part| part[:entry] =~ /docProps\/core\.xml/ }.size, 1, "core missing")
- assert_equal(p.select { |part| part[:entry] =~ /docProps\/app\.xml/ }.size, 1, "app missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/_rels\/workbook\.xml\.rels/ }.size, 1, "workbook rels missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/workbook\.xml/ }.size, 1, "workbook missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{_rels/\.rels} }.size, 1, "rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{docProps/core\.xml} }.size, 1, "core missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{docProps/app\.xml} }.size, 1, "app missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/_rels/workbook\.xml\.rels} }.size, 1, "workbook rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/workbook\.xml} }.size, 1, "workbook missing")
assert_equal(p.select { |part| part[:entry] =~ /\[Content_Types\]\.xml/ }.size, 1, "content types missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/styles\.xml/ }.size, 1, "styles missin")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/drawings\/_rels\/drawing\d\.xml\.rels/ }.size, @package.workbook.drawings.size, "one or more drawing rels missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/drawings\/drawing\d\.xml/ }.size, @package.workbook.drawings.size, "one or more drawings missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/charts\/chart\d\.xml/ }.size, @package.workbook.charts.size, "one or more charts missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/worksheets\/sheet\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/worksheets\/_rels\/sheet\d\.xml\.rels/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/comments\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/pivotTables\/pivotTable\d\.xml/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/pivotTables\/_rels\/pivotTable\d\.xml.rels/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables rels missing")
- assert_equal(p.select { |part| part[:entry] =~ /xl\/pivotCache\/pivotCacheDefinition\d\.xml/ }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/styles\.xml} }.size, 1, "styles missin")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/drawings/_rels/drawing\d\.xml\.rels} }.size, @package.workbook.drawings.size, "one or more drawing rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/drawings/drawing\d\.xml} }.size, @package.workbook.drawings.size, "one or more drawings missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/charts/chart\d\.xml} }.size, @package.workbook.charts.size, "one or more charts missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/worksheets/sheet\d\.xml} }.size, @package.workbook.worksheets.size, "one or more sheet missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/worksheets/_rels/sheet\d\.xml\.rels} }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/comments\d\.xml} }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/pivotTables/pivotTable\d\.xml} }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/pivotTables/_rels/pivotTable\d\.xml.rels} }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables rels missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/pivotCache/pivotCacheDefinition\d\.xml} }.size, @package.workbook.worksheets.first.pivot_tables.size, "one or more pivot tables missing")
# no mystery parts
assert_equal(25, p.size)
@@ -273,14 +273,14 @@ class TestPackage < Test::Unit::TestCase
# sorted for correct MIME detection
assert_equal("[Content_Types].xml", p[0][:entry], "first entry should be `[Content_Types].xml`")
assert_equal("_rels/.rels", p[1][:entry], "second entry should be `_rels/.rels`")
- assert_match(/\Axl\//, p[2][:entry], "third entry should begin with `xl/`")
+ assert_match(%r{\Axl/}, p[2][:entry], "third entry should begin with `xl/`")
end
def test_shared_strings_requires_part
@package.use_shared_strings = true
@package.to_stream # ensure all cell_serializer paths are hit
p = @package.send(:parts)
- assert_equal(p.select { |part| part[:entry] =~ /xl\/sharedStrings.xml/ }.size, 1, "shared strings table missing")
+ assert_equal(p.select { |part| part[:entry] =~ %r{xl/sharedStrings.xml} }.size, 1, "shared strings table missing")
end
def test_workbook_is_a_workbook
diff --git a/test/util/tc_mime_type_utils.rb b/test/util/tc_mime_type_utils.rb
index 52c49e2e..e469f31e 100644
--- a/test/util/tc_mime_type_utils.rb
+++ b/test/util/tc_mime_type_utils.rb
@@ -8,8 +8,7 @@ class TestMimeTypeUtils < Test::Unit::TestCase
@test_img_url = "https://example.com/sample-image.png"
end
- def teardown
- end
+ def teardown; end
def test_mime_type_utils
assert_equal(Axlsx::MimeTypeUtils::get_mime_type(@test_img), 'image/jpeg')
diff --git a/test/util/tc_simple_typed_list.rb b/test/util/tc_simple_typed_list.rb
index fc1ab0a2..5624b903 100644
--- a/test/util/tc_simple_typed_list.rb
+++ b/test/util/tc_simple_typed_list.rb
@@ -4,8 +4,7 @@ class TestSimpleTypedList < Test::Unit::TestCase
@list = Axlsx::SimpleTypedList.new Integer
end
- def teardown
- end
+ def teardown; end
def test_type_is_a_class_or_array_of_class
assert_nothing_raised { Axlsx::SimpleTypedList.new Integer }
@@ -29,7 +28,7 @@ class TestSimpleTypedList < Test::Unit::TestCase
end
def test_concat_should_return_index
- assert(@list.size == 0)
+ assert(@list.empty?)
assert(@list << 1 == 0)
assert(@list << 2 == 1)
@list.delete_at 0
diff --git a/test/util/tc_validators.rb b/test/util/tc_validators.rb
index 7df2e41b..58aa6b7c 100644
--- a/test/util/tc_validators.rb
+++ b/test/util/tc_validators.rb
@@ -1,10 +1,8 @@
require 'tc_helper.rb'
class TestValidators < Test::Unit::TestCase
- def setup
- end
+ def setup; end
- def teardown
- end
+ def teardown; end
def test_validators
# unsigned_int
@@ -20,7 +18,7 @@ class TestValidators < Test::Unit::TestCase
assert_raise(ArgumentError) { Axlsx.validate_int(Array) }
# boolean (as 0 or 1, :true, :false, true, false, or "true," "false")
- [0, 1, :true, :false, true, false, "true", "false"].each do |v|
+ [0, 1, :true, :false, true, false, "true", "false"].each do |_v|
assert_nothing_raised { Axlsx.validate_boolean 0 }
end
assert_raise(ArgumentError) { Axlsx.validate_boolean 2 }
diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb
index cb7557c6..775f6ae7 100644
--- a/test/workbook/tc_shared_strings_table.rb
+++ b/test/workbook/tc_shared_strings_table.rb
@@ -39,7 +39,7 @@ class TestSharedStringsTable < Test::Unit::TestCase
puts error.message
errors << error
end
- assert_equal(errors.size, 0, "sharedStirngs.xml Invalid" + errors.map { |e| e.message }.to_s)
+ assert_equal(errors.size, 0, "sharedStirngs.xml Invalid" + errors.map(&:message).to_s)
end
def test_remove_control_characters_in_xml_serialization
@@ -47,7 +47,7 @@ class TestSharedStringsTable < Test::Unit::TestCase
@p.workbook.worksheets[0].add_row [nasties]
# test that the nasty string was added to the shared strings
- assert @p.workbook.shared_strings.unique_cells.has_key?(nasties)
+ assert @p.workbook.shared_strings.unique_cells.key?(nasties)
# test that none of the control characters are in the XML output for shared strings
assert_no_match(/#{Axlsx::CONTROL_CHARS}/, @p.workbook.shared_strings.to_xml_string)
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index 443dd392..f0a7ac19 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -6,8 +6,7 @@ class TestWorkbook < Test::Unit::TestCase
@wb = p.workbook
end
- def teardown
- end
+ def teardown; end
def test_worksheet_users_xml_space
sheet = @wb.add_worksheet(:name => 'foo')
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index 907ce97e..959304c8 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -99,7 +99,7 @@ class TestCell < Test::Unit::TestCase
assert_raise(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array }
assert_nothing_raised("type can be changed") { @c.type = :string }
assert_equal(@c.value, "1.0", "changing type casts the value")
- assert_equal(:float, @row.add_cell(1.0 / 10**7).type, 'properly identify exponential floats as float type')
+ assert_equal(:float, @row.add_cell(1.0 / (10**7)).type, 'properly identify exponential floats as float type')
assert_equal(@row.add_cell(Time.now).type, :time, 'time should be time')
assert_equal(@row.add_cell(Date.today).type, :date, 'date should be date')
assert_equal(@row.add_cell(true).type, :boolean, 'boolean should be boolean')
@@ -112,7 +112,7 @@ class TestCell < Test::Unit::TestCase
end
def test_col_ref
- # TODO move to axlsx spec
+ # TODO: move to axlsx spec
assert_equal(Axlsx.col_ref(0), "A")
end
@@ -133,7 +133,7 @@ class TestCell < Test::Unit::TestCase
assert_equal(@c.send(:cell_type_from_value, -1), :integer)
assert_equal(@c.send(:cell_type_from_value, true), :boolean)
assert_equal(@c.send(:cell_type_from_value, false), :boolean)
- assert_equal(@c.send(:cell_type_from_value, 1.0 / 10**6), :float)
+ assert_equal(@c.send(:cell_type_from_value, 1.0 / (10**6)), :float)
assert_equal(@c.send(:cell_type_from_value, Axlsx::RichText.new), :richtext)
assert_equal(:iso_8601, @c.send(:cell_type_from_value, '2008-08-30T01:45:36.123+09:00'))
end
@@ -520,7 +520,7 @@ class TestCell < Test::Unit::TestCase
end
def test_to_xml
- # TODO This could use some much more stringent testing related to the xml content generated!
+ # TODO: This could use some much more stringent testing related to the xml content generated!
@ws.add_row [Time.now, Date.today, true, 1, 1.0, "text", "=sum(A1:A2)", "2013-01-13T13:31:25.123"]
@ws.rows.last.cells[5].u = true
diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb
index 908e9931..986c6bb7 100644
--- a/test/workbook/worksheet/tc_col.rb
+++ b/test/workbook/worksheet/tc_col.rb
@@ -86,6 +86,6 @@ class TestCol < Test::Unit::TestCase
assert_equal(@col.style, nil)
@col.style = 1
assert_equal(@col.style, 1)
- # TODO check that the style specified is actually in the styles xfs collection
+ # TODO: check that the style specified is actually in the styles xfs collection
end
end
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb
index cbd93f01..8d5df652 100644
--- a/test/workbook/worksheet/tc_comment.rb
+++ b/test/workbook/worksheet/tc_comment.rb
@@ -53,7 +53,7 @@ class TestComment < Test::Unit::TestCase
def test_to_xml_string
doc = Nokogiri::XML(@c1.to_xml_string)
assert_equal(doc.xpath("//comment[@ref='#{@c1.ref}']").size, 1)
- assert_equal(doc.xpath("//comment[@authorId='#{@c1.author_index.to_s}']").size, 1)
+ assert_equal(doc.xpath("//comment[@authorId='#{@c1.author_index}']").size, 1)
assert_equal(doc.xpath("//t[text()='#{@c1.author}:\n']").size, 1)
assert_equal(doc.xpath("//t[text()='#{@c1.text}']").size, 1)
end
diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb
index 276dd3b0..cb2e3741 100644
--- a/test/workbook/worksheet/tc_comments.rb
+++ b/test/workbook/worksheet/tc_comments.rb
@@ -16,7 +16,7 @@ class TestComments < Test::Unit::TestCase
def test_add_comment
assert_equal(@ws.comments.size, 2)
- assert_raise(ArgumentError) { @ws.comments.add_comment() }
+ assert_raise(ArgumentError) { @ws.comments.add_comment }
assert_raise(ArgumentError) { @ws.comments.add_comment(:text => 'Yes We Can', :ref => 'A1') }
assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :ref => 'A1') }
assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can') }
@@ -49,7 +49,7 @@ class TestComments < Test::Unit::TestCase
end
assert_equal(0, errors.length)
- # TODO figure out why these xpath expressions dont work!
+ # TODO: figure out why these xpath expressions dont work!
# assert(doc.xpath("//comments"))
# assert_equal(doc.xpath("//xmlns:author").size, @ws.comments.authors.size)
# assert_equal(doc.xpath("//comment").size, @ws.comments.size)
diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb
index ff92b847..aac2019d 100644
--- a/test/workbook/worksheet/tc_data_validation.rb
+++ b/test/workbook/worksheet/tc_data_validation.rb
@@ -44,14 +44,14 @@ class TestDataValidation < Test::Unit::TestCase
end
def test_boolean_attribute_validation
- @boolean_options.each do |key, value|
+ @boolean_options.each do |key, _value|
assert_raise(ArgumentError, "#{key} must be boolean") { @dv.send("#{key}=".to_sym, 'A') }
assert_nothing_raised { @dv.send("#{key}=".to_sym, true) }
end
end
def test_string_attribute_validation
- @string_options.each do |key, value|
+ @string_options.each do |key, _value|
assert_raise(ArgumentError, "#{key} must be string") { @dv.send("#{key}=".to_sym, :symbol) }
assert_nothing_raised { @dv.send("#{key}=".to_sym, "foo") }
end
diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb
index 9c813486..891fa80f 100644
--- a/test/workbook/worksheet/tc_date_time_converter.rb
+++ b/test/workbook/worksheet/tc_date_time_converter.rb
@@ -7,7 +7,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
Time.parse "1893-08-05"
Time.parse "9999-12-31T23:59:59Z"
true
- rescue
+ rescue StandardError
false
end
end
@@ -114,8 +114,8 @@ 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)
+ assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - (local.utc_offset.to_f / 86400), Axlsx::DateTimeConverter::time_to_serial(utc)
end
end
diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb
index b7a36600..6dca8b0a 100644
--- a/test/workbook/worksheet/tc_page_setup.rb
+++ b/test/workbook/worksheet/tc_page_setup.rb
@@ -59,18 +59,18 @@ class TestPageSetup < Test::Unit::TestCase
end
def test_default_fit_to_page?
- assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
+ assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?)
assert(@ps.fit_to_page? == false)
end
def test_with_height_fit_to_page?
- assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
+ assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?)
@ps.set(:fit_to_height => 1)
assert(@ps.fit_to_page?)
end
def test_with_width_fit_to_page?
- assert(@ps.fit_to_width == nil && @ps.fit_to_height == nil)
+ assert(@ps.fit_to_width.nil? && @ps.fit_to_height.nil?)
@ps.set(:fit_to_width => 1)
assert(@ps.fit_to_page?)
end
diff --git a/test/workbook/worksheet/tc_rich_text.rb b/test/workbook/worksheet/tc_rich_text.rb
index 34117b1b..6c9627d4 100644
--- a/test/workbook/worksheet/tc_rich_text.rb
+++ b/test/workbook/worksheet/tc_rich_text.rb
@@ -7,7 +7,7 @@ class RichText < Test::Unit::TestCase
p.workbook.styles.add_style :sz => 20
@rt = Axlsx::RichText.new
b = true
- (0..26).each do |r|
+ 27.times do |r|
@rt.add_run "run #{r}, ", :b => (b = !b), :i => !b
end
@row = @ws.add_row [@rt]
@@ -17,7 +17,7 @@ class RichText < Test::Unit::TestCase
def test_initialize
assert_equal(@c.value, @rt)
rt_direct = Axlsx::RichText.new('hi', :i => true)
- rt_indirect = Axlsx::RichText.new()
+ rt_indirect = Axlsx::RichText.new
rt_indirect.add_run('hi', :i => true)
assert_equal(rt_direct.runs.length, 1)
assert_equal(rt_indirect.runs.length, 1)
diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb
index b14f3e03..e8f18df5 100644
--- a/test/workbook/worksheet/tc_sheet_protection.rb
+++ b/test/workbook/worksheet/tc_sheet_protection.rb
@@ -44,7 +44,7 @@ class TestSheetProtection < Test::Unit::TestCase
end
def test_boolean_attribute_validation
- @boolean_options.each do |key, value|
+ @boolean_options.each do |key, _value|
assert_raise(ArgumentError, "#{key} must be boolean") { @sp.send("#{key}=".to_sym, 'A') }
assert_nothing_raised { @sp.send("#{key}=".to_sym, true) }
assert_nothing_raised { @sp.send("#{key}=".to_sym, true) }
diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb
index 0f0986cf..18bb3308 100644
--- a/test/workbook/worksheet/tc_sheet_view.rb
+++ b/test/workbook/worksheet/tc_sheet_view.rb
@@ -45,14 +45,14 @@ class TestSheetView < Test::Unit::TestCase
end
def test_boolean_attribute_validation
- @boolean_options.each do |key, value|
+ @boolean_options.each do |key, _value|
assert_raise(ArgumentError, "#{key} must be boolean") { @sv.send("#{key}=".to_sym, 'A') }
assert_nothing_raised { @sv.send("#{key}=".to_sym, true) }
end
end
def test_string_attribute_validation
- @string_options.each do |key, value|
+ @string_options.each do |key, _value|
assert_raise(ArgumentError, "#{key} must be string") { @sv.send("#{key}=".to_sym, :symbol) }
assert_nothing_raised { @sv.send("#{key}=".to_sym, "foo") }
end
diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb
index 3d71dc9b..f6606225 100644
--- a/test/workbook/worksheet/tc_table_style_info.rb
+++ b/test/workbook/worksheet/tc_table_style_info.rb
@@ -24,7 +24,7 @@ class TestTableStyleInfo < Test::Unit::TestCase
def test_boolean_properties
table_style = Axlsx::TableStyleInfo.new
- @options.keys.each do |key|
+ @options.each_key do |key|
assert_nothing_raised { table_style.send("#{key.to_sym}=", true) }
assert_raises(ArgumentError) { table_style.send(key.to_sym, 'foo') }
end
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index d83cdf91..fde0611d 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -45,7 +45,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_exception_if_name_too_long_because_of_multibyte_characters
four_characters_for_excel = "\u{1F1EB 1F1F7}" # french flag emoji
assert_raises(ArgumentError, "name too long!") do
- @ws.name = four_characters_for_excel + "x" * 28
+ @ws.name = four_characters_for_excel + ("x" * 28)
end
assert_nothing_raised { @ws.name = "#{four_characters_for_excel}123456789012345678901234567" }
assert_nothing_raised { @ws.name = "123456789012345678901234567890…" }
@@ -53,45 +53,45 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_page_margins
- assert(@ws.page_margins.is_a? Axlsx::PageMargins)
+ assert(@ws.page_margins.is_a?(Axlsx::PageMargins))
end
def test_page_margins_yeild
@ws.page_margins do |pm|
- assert(pm.is_a? Axlsx::PageMargins)
+ assert(pm.is_a?(Axlsx::PageMargins))
assert(@ws.page_margins == pm)
end
end
def test_page_setup
- assert(@ws.page_setup.is_a? Axlsx::PageSetup)
+ assert(@ws.page_setup.is_a?(Axlsx::PageSetup))
end
def test_page_setup_yield
@ws.page_setup do |ps|
- assert(ps.is_a? Axlsx::PageSetup)
+ assert(ps.is_a?(Axlsx::PageSetup))
assert(@ws.page_setup == ps)
end
end
def test_print_options
- assert(@ws.print_options.is_a? Axlsx::PrintOptions)
+ assert(@ws.print_options.is_a?(Axlsx::PrintOptions))
end
def test_print_options_yield
@ws.print_options do |po|
- assert(po.is_a? Axlsx::PrintOptions)
+ assert(po.is_a?(Axlsx::PrintOptions))
assert(@ws.print_options == po)
end
end
def test_header_footer
- assert(@ws.header_footer.is_a? Axlsx::HeaderFooter)
+ assert(@ws.header_footer.is_a?(Axlsx::HeaderFooter))
end
def test_header_footer_yield
@ws.header_footer do |hf|
- assert(hf.is_a? Axlsx::HeaderFooter)
+ assert(hf.is_a?(Axlsx::HeaderFooter))
assert(@ws.header_footer == hf)
end
end
@@ -117,16 +117,16 @@ class TestWorksheet < Test::Unit::TestCase
print_options = { :grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true }
header_footer = { :different_first => false, :different_odd_even => false, :odd_header => 'Header' }
optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer)
- page_margins.keys.each do |key|
+ page_margins.each_key do |key|
assert_equal(page_margins[key], optioned.page_margins.send(key))
end
- page_setup.keys.each do |key|
+ page_setup.each_key do |key|
assert_equal(page_setup[key], optioned.page_setup.send(key))
end
- print_options.keys.each do |key|
+ print_options.each_key do |key|
assert_equal(print_options[key], optioned.print_options.send(key))
end
- header_footer.keys.each do |key|
+ header_footer.each_key do |key|
assert_equal(header_footer[key], optioned.header_footer.send(key))
end
assert_equal(optioned.name, 'bob')
@@ -215,7 +215,7 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_drawing
- assert @ws.drawing == nil
+ assert @ws.drawing.nil?
@ws.add_chart(Axlsx::Pie3DChart)
assert @ws.drawing.is_a?(Axlsx::Drawing)
end
@@ -260,7 +260,7 @@ class TestWorksheet < Test::Unit::TestCase
def test_cols_with_block
@ws.add_row [1, 2, 3]
@ws.add_row [1]
- cols = @ws.cols { |row, column| :foo }
+ cols = @ws.cols { |_row, _column| :foo }
assert_equal(:foo, cols[1][1])
end
@@ -451,7 +451,7 @@ class TestWorksheet < Test::Unit::TestCase
@ws.add_pivot_table 'G5:G6', 'A1:D10'
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
doc = Nokogiri::XML(@ws.to_xml_string)
- assert(schema.validate(doc).map { |e| puts e.message; e }.empty?, schema.validate(doc).map { |e| e.message }.join('\n'))
+ assert(schema.validate(doc).map { |e| puts e.message; e }.empty?, schema.validate(doc).map(&:message).join('\n'))
end
def test_relationships
@@ -786,7 +786,7 @@ class TestWorksheet < Test::Unit::TestCase
sz: 11,
family: 1
}
- assert_equal b2_cell_style, wb.styles.style_index.values.find { |x| x == b2_cell_style }
+ assert_equal b2_cell_style, (wb.styles.style_index.values.find { |x| x == b2_cell_style })
d3_cell_style = {
border: {
@@ -799,7 +799,7 @@ class TestWorksheet < Test::Unit::TestCase
sz: 11,
family: 1
}
- assert_equal d3_cell_style, wb.styles.style_index.values.find { |x| x == d3_cell_style }
+ assert_equal d3_cell_style, (wb.styles.style_index.values.find { |x| x == d3_cell_style })
end
def test_mixed_borders_1