summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2023-05-31 09:28:21 +0200
committerGitHub <[email protected]>2023-05-31 09:28:21 +0200
commit8918a00eb0ff7b40240be5c94c4c245c95579acb (patch)
tree351e306a7d104e08321d91f8467b9ae6ead46326
parent317383fc66da3f04d438c86afb5b639b62145408 (diff)
parent70bdceaf29e69c18f62df113e1706e749b3f4f29 (diff)
downloadcaxlsx-8918a00eb0ff7b40240be5c94c4c245c95579acb.tar.gz
caxlsx-8918a00eb0ff7b40240be5c94c4c245c95579acb.zip
Merge pull request #263 from tagliala/chore/fix-string-concatenation
Fix string concatenation in production code
-rw-r--r--.rubocop_todo.yml17
-rw-r--r--lib/axlsx/drawing/area_series.rb2
-rw-r--r--lib/axlsx/drawing/line_series.rb2
-rw-r--r--lib/axlsx/drawing/pie_series.rb2
-rw-r--r--lib/axlsx/drawing/scatter_series.rb2
-rw-r--r--lib/axlsx/stylesheet/color.rb2
-rw-r--r--lib/axlsx/util/constants.rb14
-rw-r--r--lib/axlsx/workbook/worksheet/dimension.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb2
9 files changed, 14 insertions, 31 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f6284caf..c53b9f5c 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -31,10 +31,6 @@ Layout/HashAlignment:
# 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'
@@ -210,7 +206,6 @@ Style/FormatString:
- 'lib/axlsx/drawing/vml_drawing.rb'
- 'lib/axlsx/util/accessors.rb'
- 'lib/axlsx/util/validators.rb'
- - 'lib/axlsx/workbook/worksheet/dimension.rb'
- 'lib/axlsx/workbook/worksheet/worksheet.rb'
# This cop supports safe autocorrection (--autocorrect).
@@ -455,18 +450,6 @@ Style/StringChars:
Exclude:
- 'lib/axlsx/workbook/worksheet/sheet_protection.rb'
-# This cop supports unsafe autocorrection (--autocorrect-all).
-# Configuration parameters: Mode.
-Style/StringConcatenation:
- Exclude:
- - 'lib/axlsx/drawing/area_series.rb'
- - 'lib/axlsx/drawing/line_series.rb'
- - 'lib/axlsx/drawing/pie_series.rb'
- - 'lib/axlsx/drawing/scatter_series.rb'
- - 'lib/axlsx/stylesheet/color.rb'
- - 'lib/axlsx/util/constants.rb'
- - 'lib/axlsx/workbook/worksheet/worksheet.rb'
-
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
diff --git a/lib/axlsx/drawing/area_series.rb b/lib/axlsx/drawing/area_series.rb
index cf4aaf13..afaf5ea0 100644
--- a/lib/axlsx/drawing/area_series.rb
+++ b/lib/axlsx/drawing/area_series.rb
@@ -89,7 +89,7 @@ module Axlsx
if !@show_marker
str << '<c:marker><c:symbol val="none"/></c:marker>'
elsif @marker_symbol != :default
- str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
+ str << '<c:marker><c:symbol val="' << @marker_symbol.to_s << '"/></c:marker>'
end
@labels.to_xml_string(str) unless @labels.nil?
diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb
index fbed4000..4854a718 100644
--- a/lib/axlsx/drawing/line_series.rb
+++ b/lib/axlsx/drawing/line_series.rb
@@ -89,7 +89,7 @@ module Axlsx
if !@show_marker
str << '<c:marker><c:symbol val="none"/></c:marker>'
elsif @marker_symbol != :default
- str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
+ str << '<c:marker><c:symbol val="' << @marker_symbol.to_s << '"/></c:marker>'
end
@labels.to_xml_string(str) unless @labels.nil?
diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb
index f3edd1e9..cce79648 100644
--- a/lib/axlsx/drawing/pie_series.rb
+++ b/lib/axlsx/drawing/pie_series.rb
@@ -46,7 +46,7 @@ module Axlsx
# @return [String]
def to_xml_string(str = +'')
super(str) do
- str << '<c:explosion val="' + @explosion.to_s + '"/>' unless @explosion.nil?
+ str << '<c:explosion val="' << @explosion.to_s << '"/>' unless @explosion.nil?
colors.each_with_index do |c, index|
str << '<c:dPt>'
str << '<c:idx val="' << index.to_s << '"/>'
diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb
index 9c6e12f2..9e3579f7 100644
--- a/lib/axlsx/drawing/scatter_series.rb
+++ b/lib/axlsx/drawing/scatter_series.rb
@@ -121,7 +121,7 @@ module Axlsx
if !@show_marker
'<c:symbol val="none"/>'
elsif @marker_symbol != :default
- '<c:symbol val="' + @marker_symbol.to_s + '"/>'
+ '<c:symbol val="' << @marker_symbol.to_s << '"/>'
end.to_s
end
end
diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb
index 24fe3bc3..0c40a073 100644
--- a/lib/axlsx/stylesheet/color.rb
+++ b/lib/axlsx/stylesheet/color.rb
@@ -73,7 +73,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = +'', tag_name = 'color')
- serialized_tag('' + tag_name + '', str)
+ serialized_tag(tag_name.to_s, str)
end
end
end
diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb
index 459e0099..0767be31 100644
--- a/lib/axlsx/util/constants.rb
+++ b/lib/axlsx/util/constants.rb
@@ -239,25 +239,25 @@ module Axlsx
COMMENT_PN = "comments%d.xml"
# location of schema files for validation
- SCHEMA_BASE = (File.dirname(__FILE__) + '/../../schema/').freeze
+ SCHEMA_BASE = "#{File.dirname(__FILE__)}/../../schema/"
# App validation schema
- APP_XSD = (SCHEMA_BASE + "shared-documentPropertiesExtended.xsd").freeze
+ APP_XSD = "#{SCHEMA_BASE}shared-documentPropertiesExtended.xsd"
# core validation schema
- CORE_XSD = (SCHEMA_BASE + "opc-coreProperties.xsd").freeze
+ CORE_XSD = "#{SCHEMA_BASE}opc-coreProperties.xsd"
# content types validation schema
- CONTENT_TYPES_XSD = (SCHEMA_BASE + "opc-contentTypes.xsd").freeze
+ CONTENT_TYPES_XSD = "#{SCHEMA_BASE}opc-contentTypes.xsd"
# rels validation schema
- RELS_XSD = (SCHEMA_BASE + "opc-relationships.xsd").freeze
+ RELS_XSD = "#{SCHEMA_BASE}opc-relationships.xsd"
# spreadsheetML validation schema
- SML_XSD = (SCHEMA_BASE + "sml.xsd").freeze
+ SML_XSD = "#{SCHEMA_BASE}sml.xsd"
# drawing validation schema
- DRAWING_XSD = (SCHEMA_BASE + "dml-spreadsheetDrawing.xsd").freeze
+ DRAWING_XSD = "#{SCHEMA_BASE}dml-spreadsheetDrawing.xsd"
# number format id for pecentage formatting using the default formatting id.
NUM_FMT_PERCENT = 9
diff --git a/lib/axlsx/workbook/worksheet/dimension.rb b/lib/axlsx/workbook/worksheet/dimension.rb
index 42e02e72..f27404b6 100644
--- a/lib/axlsx/workbook/worksheet/dimension.rb
+++ b/lib/axlsx/workbook/worksheet/dimension.rb
@@ -39,7 +39,7 @@ module Axlsx
def to_xml_string(str = +'')
return if worksheet.rows.empty?
- str << "<dimension ref=\"%s\"></dimension>" % sqref
+ str << '<dimension ref="' << sqref << '"></dimension>'
end
# The first cell in the dimension
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index 8c6e53b4..aaeadb11 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -45,7 +45,7 @@ module Axlsx
# The name of the worksheet
# @return [String]
def name
- @name ||= "Sheet" + (index + 1).to_s
+ @name ||= "Sheet#{index + 1}"
end
# Whether to treat values starting with an equals sign as formulas or as literal strings.