diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-05-22 10:21:51 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-22 10:21:51 +0200 |
| commit | 32d1fd900604131fcb0549b2b052944238d63155 (patch) | |
| tree | 1c596cb16aca0f9db0e78ed6daf0fd8b7bb33ece | |
| parent | cae05b4a78c05e3dd753d6438ca15215f44066d8 (diff) | |
| parent | 497457b7a9221944a91d595465599e8451d678e4 (diff) | |
| download | caxlsx-32d1fd900604131fcb0549b2b052944238d63155.tar.gz caxlsx-32d1fd900604131fcb0549b2b052944238d63155.zip | |
Merge pull request #237 from tagliala/chore/fix-hash-transform-keys
Fix hash transformation related offenses
| -rw-r--r-- | .rubocop_todo.yml | 13 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell_serializer.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/rich_text_run.rb | 2 |
3 files changed, 2 insertions, 15 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 19c4b3f5..20efee78 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -223,13 +223,6 @@ Style/GuardClause: - 'lib/axlsx/workbook/worksheet/table.rb' - 'lib/axlsx/workbook/worksheet/worksheet.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowSplatArgument. -Style/HashConversion: - Exclude: - - 'lib/axlsx/workbook/worksheet/cell_serializer.rb' - - 'lib/axlsx/workbook/worksheet/rich_text_run.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedReceivers. # AllowedReceivers: Thread.current @@ -244,12 +237,6 @@ Style/HashEachMethods: Style/HashSyntax: Enabled: false -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/HashTransformKeys: - Exclude: - - 'lib/axlsx/workbook/worksheet/cell_serializer.rb' - - 'lib/axlsx/workbook/worksheet/rich_text_run.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfModifier. Style/IfInsideElse: diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb index f45d3c73..dceca7eb 100644 --- a/lib/axlsx/workbook/worksheet/cell_serializer.rb +++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb @@ -26,7 +26,7 @@ module Axlsx def run_xml_string(cell, str = +'') if cell.is_text_run? valid = RichTextRun::INLINE_STYLES - [:value, :type] - data = Hash[Axlsx.instance_values_for(cell).map { |k, v| [k.to_sym, v] }] + data = Axlsx.instance_values_for(cell).transform_keys(&:to_sym) data = data.select { |key, value| valid.include?(key) && !value.nil? } RichText.new(cell.value.to_s, data).to_xml_string(str) elsif cell.contains_rich_text? diff --git a/lib/axlsx/workbook/worksheet/rich_text_run.rb b/lib/axlsx/workbook/worksheet/rich_text_run.rb index 883d01d3..ffd2f941 100644 --- a/lib/axlsx/workbook/worksheet/rich_text_run.rb +++ b/lib/axlsx/workbook/worksheet/rich_text_run.rb @@ -207,7 +207,7 @@ module Axlsx # @return [String] def to_xml_string(str = +'') valid = RichTextRun::INLINE_STYLES - data = Hash[Axlsx.instance_values_for(self).map { |k, v| [k.to_sym, v] }] + data = Axlsx.instance_values_for(self).transform_keys(&:to_sym) data = data.select { |key, value| valid.include?(key) && !value.nil? } str << '<r><rPr>' |
