summaryrefslogtreecommitdiffhomepage
path: root/test/stylesheet
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 /test/stylesheet
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)
Diffstat (limited to 'test/stylesheet')
-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
17 files changed, 29 insertions, 46 deletions
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)