From 0cc60e3eb08e11542612871e2e15350ed07fff06 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Mon, 5 Jun 2023 16:49:23 +0200 Subject: Fix Style/RedundantInterpolation offenses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `%` is an operation on `String` that will return a new `String`, so the interpolation is redundant Also adds a missing spec on PivotTable#rels_pn ``` IPS: uninterpolated: 4045715.7 i/s interpolated: 2359775.6 i/s - 1.71x (± 0.00) slower Memory: uninterpolated: 160 allocated interpolated: 232 allocated - 1.45x more ``` --- lib/axlsx/drawing/chart.rb | 2 +- lib/axlsx/drawing/drawing.rb | 4 ++-- lib/axlsx/drawing/pic.rb | 2 +- lib/axlsx/workbook/worksheet/comments.rb | 2 +- lib/axlsx/workbook/worksheet/pivot_table.rb | 4 ++-- lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb | 2 +- lib/axlsx/workbook/worksheet/table.rb | 2 +- lib/axlsx/workbook/worksheet/worksheet.rb | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 9f59dc6a..6b3acab1 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -124,7 +124,7 @@ module Axlsx # The part name for this chart # @return [String] def pn - "#{CHART_PN % (index + 1)}" + CHART_PN % (index + 1) end # The title object for the chart. diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb index fa7a608c..8ae4ed0c 100644 --- a/lib/axlsx/drawing/drawing.rb +++ b/lib/axlsx/drawing/drawing.rb @@ -128,14 +128,14 @@ module Axlsx # The part name for this drawing # @return [String] def pn - "#{DRAWING_PN % (index + 1)}" + DRAWING_PN % (index + 1) end # The relational part name for this drawing # #NOTE This should be rewritten to return an Axlsx::Relationship object. # @return [String] def rels_pn - "#{DRAWING_RELS_PN % (index + 1)}" + DRAWING_RELS_PN % (index + 1) end # A list of objects this drawing holds. diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb index c9efb378..08beb2d9 100644 --- a/lib/axlsx/drawing/pic.rb +++ b/lib/axlsx/drawing/pic.rb @@ -131,7 +131,7 @@ module Axlsx # @return [Relationship] def relationship if remote? - Relationship.new(self, IMAGE_R, "#{image_src}", target_mode: :External) + Relationship.new(self, IMAGE_R, image_src.to_s, target_mode: :External) else Relationship.new(self, IMAGE_R, "../#{pn}") end diff --git a/lib/axlsx/workbook/worksheet/comments.rb b/lib/axlsx/workbook/worksheet/comments.rb index cb8efdaa..b27a1940 100644 --- a/lib/axlsx/workbook/worksheet/comments.rb +++ b/lib/axlsx/workbook/worksheet/comments.rb @@ -20,7 +20,7 @@ module Axlsx # The part name for this object # @return [String] def pn - "#{COMMENT_PN % (index + 1)}" + COMMENT_PN % (index + 1) end # Creates a new Comments object diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb index aca3ccb5..00ffe92d 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table.rb @@ -159,13 +159,13 @@ module Axlsx # The part name for this table # @return [String] def pn - "#{PIVOT_TABLE_PN % (index + 1)}" + PIVOT_TABLE_PN % (index + 1) end # The relationship part name of this pivot table # @return [String] def rels_pn - "#{PIVOT_TABLE_RELS_PN % (index + 1)}" + PIVOT_TABLE_RELS_PN % (index + 1) end # The cache_definition for this pivot table diff --git a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb index 4928d5ac..5bb946a0 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb @@ -26,7 +26,7 @@ module Axlsx # The part name for this table # @return [String] def pn - "#{PIVOT_TABLE_CACHE_DEFINITION_PN % (index + 1)}" + PIVOT_TABLE_CACHE_DEFINITION_PN % (index + 1) end # The identifier for this cache diff --git a/lib/axlsx/workbook/worksheet/table.rb b/lib/axlsx/workbook/worksheet/table.rb index 210833e0..4221925d 100644 --- a/lib/axlsx/workbook/worksheet/table.rb +++ b/lib/axlsx/workbook/worksheet/table.rb @@ -44,7 +44,7 @@ module Axlsx # The part name for this table # @return [String] def pn - "#{TABLE_PN % (index + 1)}" + TABLE_PN % (index + 1) end # The relationship id for this table. diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 07221b3f..d4840050 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -345,13 +345,13 @@ module Axlsx # The part name of this worksheet # @return [String] def pn - "#{WORKSHEET_PN % (index + 1)}" + WORKSHEET_PN % (index + 1) end # The relationship part name of this worksheet # @return [String] def rels_pn - "#{WORKSHEET_RELS_PN % (index + 1)}" + WORKSHEET_RELS_PN % (index + 1) end # The relationship id of this worksheet. -- cgit v1.2.3