summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGeremia Taglialatela <[email protected]>2023-06-10 11:48:13 +0200
committerGeremia Taglialatela <[email protected]>2023-06-10 11:48:13 +0200
commitee14c1bf5c6aaa96867eb4b90b510f91c3a614f8 (patch)
tree63a893a73f1cc51003edf218fed178bb93c604d7 /test
parentcfb516062de3d0725b3245cc328f96d702d662d3 (diff)
downloadcaxlsx-ee14c1bf5c6aaa96867eb4b90b510f91c3a614f8.tar.gz
caxlsx-ee14c1bf5c6aaa96867eb4b90b510f91c3a614f8.zip
Fix safe Style/ColonMethodCall offenses
Caxlsx is using both `.` and `::`, 220 occurrences vs 280 to invoke methods on `Axlsx` module. This commit standardizes the approach towards `.`, which will also allow shorter lines. Performance is not affected ``` Comparison: Axlsx.validate: 8515252.3 i/s Axlsx::validate: 8512863.7 i/s - same-ish: difference falls within error ```
Diffstat (limited to 'test')
-rw-r--r--test/drawing/tc_d_lbls.rb2
-rw-r--r--test/tc_axlsx.rb16
-rw-r--r--test/tc_package.rb4
-rw-r--r--test/util/tc_mime_type_utils.rb6
-rw-r--r--test/workbook/tc_workbook.rb4
-rw-r--r--test/workbook/worksheet/tc_comment.rb2
-rw-r--r--test/workbook/worksheet/tc_date_time_converter.rb12
-rw-r--r--test/workbook/worksheet/tc_table_style_info.rb2
-rw-r--r--test/workbook/worksheet/tc_worksheet.rb6
9 files changed, 27 insertions, 27 deletions
diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb
index 9bb2d4ba..c3172326 100644
--- a/test/drawing/tc_d_lbls.rb
+++ b/test/drawing/tc_d_lbls.rb
@@ -53,7 +53,7 @@ class TestDLbls < Test::Unit::TestCase
doc = Nokogiri::XML(str)
Axlsx.instance_values_for(@d_lbls).each do |name, value|
- assert(doc.xpath("//c:#{Axlsx::camel(name, false)}[@val='#{value}']"), "#{name} is properly serialized")
+ assert(doc.xpath("//c:#{Axlsx.camel(name, false)}[@val='#{value}']"), "#{name} is properly serialized")
end
end
end
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb
index f4f6a01d..66b12ff9 100644
--- a/test/tc_axlsx.rb
+++ b/test/tc_axlsx.rb
@@ -96,9 +96,9 @@ class TestAxlsx < Test::Unit::TestCase
end
def test_range_to_a
- assert_equal([['A1', 'B1', 'C1']], Axlsx::range_to_a('A1:C1'))
- assert_equal([['A1', 'B1', 'C1'], ['A2', 'B2', 'C2']], Axlsx::range_to_a('A1:C2'))
- assert_equal([['Z5', 'AA5', 'AB5'], ['Z6', 'AA6', 'AB6']], Axlsx::range_to_a('Z5:AB6'))
+ assert_equal([['A1', 'B1', 'C1']], Axlsx.range_to_a('A1:C1'))
+ assert_equal([['A1', 'B1', 'C1'], ['A2', 'B2', 'C2']], Axlsx.range_to_a('A1:C2'))
+ assert_equal([['Z5', 'AA5', 'AB5'], ['Z6', 'AA6', 'AB6']], Axlsx.range_to_a('Z5:AB6'))
end
def test_sanitize_frozen_control_strippped
@@ -165,15 +165,15 @@ class TestAxlsx < Test::Unit::TestCase
def test_escape_formulas
Axlsx.instance_variable_set(:@escape_formulas, nil)
- refute Axlsx::escape_formulas
+ refute Axlsx.escape_formulas
- Axlsx::escape_formulas = true
+ Axlsx.escape_formulas = true
- assert Axlsx::escape_formulas
+ assert Axlsx.escape_formulas
- Axlsx::escape_formulas = false
+ Axlsx.escape_formulas = false
- refute Axlsx::escape_formulas
+ refute Axlsx.escape_formulas
ensure
Axlsx.instance_variable_set(:@escape_formulas, nil)
end
diff --git a/test/tc_package.rb b/test/tc_package.rb
index 75fe2cdf..9b057a94 100644
--- a/test/tc_package.rb
+++ b/test/tc_package.rb
@@ -319,8 +319,8 @@ class TestPackage < Test::Unit::TestCase
end
def test_name_to_indices
- assert_equal([0, 0], Axlsx::name_to_indices('A1'))
- assert_equal([0, 99], Axlsx::name_to_indices('A100'), 'needs to axcept rows that contain 0')
+ assert_equal([0, 0], Axlsx.name_to_indices('A1'))
+ assert_equal([0, 99], Axlsx.name_to_indices('A100'), 'needs to axcept rows that contain 0')
end
def test_to_stream
diff --git a/test/util/tc_mime_type_utils.rb b/test/util/tc_mime_type_utils.rb
index 16ba45cd..f990e8e2 100644
--- a/test/util/tc_mime_type_utils.rb
+++ b/test/util/tc_mime_type_utils.rb
@@ -14,11 +14,11 @@ class TestMimeTypeUtils < Test::Unit::TestCase
def teardown; end
def test_mime_type_utils
- assert_equal('image/jpeg', Axlsx::MimeTypeUtils::get_mime_type(@test_img))
- assert_equal('image/png', Axlsx::MimeTypeUtils::get_mime_type_from_uri(@test_img_url))
+ assert_equal('image/jpeg', Axlsx::MimeTypeUtils.get_mime_type(@test_img))
+ assert_equal('image/png', Axlsx::MimeTypeUtils.get_mime_type_from_uri(@test_img_url))
end
def test_escape_uri
- assert_raise(URI::InvalidURIError) { Axlsx::MimeTypeUtils::get_mime_type_from_uri('| ls') }
+ assert_raise(URI::InvalidURIError) { Axlsx::MimeTypeUtils.get_mime_type_from_uri('| ls') }
end
end
diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb
index 51fe3976..2422cc79 100644
--- a/test/workbook/tc_workbook.rb
+++ b/test/workbook/tc_workbook.rb
@@ -185,7 +185,7 @@ class TestWorkbook < Test::Unit::TestCase
end
def test_escape_formulas
- Axlsx::escape_formulas = false
+ Axlsx.escape_formulas = false
p = Axlsx::Package.new
@wb = p.workbook
@@ -194,7 +194,7 @@ class TestWorkbook < Test::Unit::TestCase
assert_false @wb.add_worksheet(escape_formulas: false).escape_formulas
assert @wb.add_worksheet(escape_formulas: true).escape_formulas
- Axlsx::escape_formulas = true
+ Axlsx.escape_formulas = true
p = Axlsx::Package.new
@wb = p.workbook
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb
index aa33dba4..80bd01cb 100644
--- a/test/workbook/worksheet/tc_comment.rb
+++ b/test/workbook/worksheet/tc_comment.rb
@@ -41,7 +41,7 @@ class TestComment < Test::Unit::TestCase
end
def test_vml_shape
- pos = Axlsx::name_to_indices(@c1.ref)
+ pos = Axlsx.name_to_indices(@c1.ref)
assert(@c1.vml_shape.is_a?(Axlsx::VmlShape))
assert_equal(@c1.vml_shape.column, pos[0])
diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb
index 5cc9d619..6d95b111 100644
--- a/test/workbook/worksheet/tc_date_time_converter.rb
+++ b/test/workbook/worksheet/tc_date_time_converter.rb
@@ -16,7 +16,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
"2006-02-01" => 38_749.0,
"9999-12-31" => 2_958_465.0
}.each do |date_string, expected|
- serial = Axlsx::DateTimeConverter::date_to_serial Date.parse(date_string)
+ serial = Axlsx::DateTimeConverter.date_to_serial Date.parse(date_string)
assert_equal expected, serial
end
@@ -31,7 +31,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
"2006-02-01" => 37_287.0,
"9999-12-31" => 2_957_003.0
}.each do |date_string, expected|
- serial = Axlsx::DateTimeConverter::date_to_serial Date.parse(date_string)
+ serial = Axlsx::DateTimeConverter.date_to_serial Date.parse(date_string)
assert_equal expected, serial
end
@@ -46,7 +46,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
"1900-01-01T12:00:00Z" => 2.5, # wrongly indicated as 1.5 in the spec!
"9999-12-31T23:59:59Z" => 2_958_465.9999884
}.each do |time_string, expected|
- serial = Axlsx::DateTimeConverter::time_to_serial Time.parse(time_string)
+ serial = Axlsx::DateTimeConverter.time_to_serial Time.parse(time_string)
assert_in_delta expected, serial, @margin_of_error
end
@@ -61,7 +61,7 @@ class TestDateTimeConverter < Test::Unit::TestCase
"1904-01-01T12:00:00Z" => 0.5000000,
"9999-12-31T23:59:59Z" => 2_957_003.9999884
}.each do |time_string, expected|
- serial = Axlsx::DateTimeConverter::time_to_serial Time.parse(time_string)
+ serial = Axlsx::DateTimeConverter.time_to_serial Time.parse(time_string)
assert_in_delta expected, serial, @margin_of_error
end
@@ -72,9 +72,9 @@ 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 / 86_400), Axlsx::DateTimeConverter::time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter.time_to_serial(local) - (local.utc_offset.to_f / 86_400), Axlsx::DateTimeConverter.time_to_serial(utc)
Axlsx::Workbook.date1904 = true
- assert_equal Axlsx::DateTimeConverter::time_to_serial(local) - (local.utc_offset.to_f / 86_400), Axlsx::DateTimeConverter::time_to_serial(utc)
+ assert_equal Axlsx::DateTimeConverter.time_to_serial(local) - (local.utc_offset.to_f / 86_400), Axlsx::DateTimeConverter.time_to_serial(utc)
end
end
diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb
index 6cb12b94..2e327a73 100644
--- a/test/workbook/worksheet/tc_table_style_info.rb
+++ b/test/workbook/worksheet/tc_table_style_info.rb
@@ -9,7 +9,7 @@ class TestTableStyleInfo < Test::Unit::TestCase
40.times do
@ws.add_row %w(aa bb cc dd ee ff gg hh ii jj kk)
end
- @table = @ws.add_table(Axlsx::cell_range([@ws.rows.first.cells.first, @ws.rows.last.cells.last], false), name: 'foo')
+ @table = @ws.add_table(Axlsx.cell_range([@ws.rows.first.cells.first, @ws.rows.last.cells.last], false), name: 'foo')
@options = { show_first_column: 1,
show_last_column: 1,
show_row_stripes: 1,
diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb
index 4ec74efb..464d2e64 100644
--- a/test/workbook/worksheet/tc_worksheet.rb
+++ b/test/workbook/worksheet/tc_worksheet.rb
@@ -456,14 +456,14 @@ class TestWorksheet < Test::Unit::TestCase
end
def test_to_xml_string_with_illegal_chars
- old = Axlsx::trust_input
- Axlsx::trust_input = false
+ old = Axlsx.trust_input
+ Axlsx.trust_input = false
nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
@ws.add_row [nasties]
assert_equal(0, @ws.rows.last.cells.last.value.index("\v"))
assert_nil(@ws.to_xml_string.index("\v"))
- Axlsx::trust_input = old
+ Axlsx.trust_input = old
end
def test_to_xml_string_with_newlines