From a8d93e0f5163fba23e6f7b5213b8d67d2dd30e6d Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Wed, 17 May 2023 11:05:45 +0200 Subject: Fix safe performance RuboCop offenses - Fix Performance/RedundantMatch and Performance/RegexpMatch - Fix Performance/RedundantSplitRegexpArgument --- .rubocop_todo.yml | 15 --------------- lib/axlsx/stylesheet/color.rb | 2 +- lib/axlsx/workbook/worksheet/sheet_protection.rb | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a80ac256..19c4b3f5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -101,21 +101,6 @@ Performance/RedundantBlockCall: Exclude: - 'lib/axlsx/util/zip_command.rb' -# This cop supports safe autocorrection (--autocorrect). -Performance/RedundantMatch: - Exclude: - - 'lib/axlsx/stylesheet/color.rb' - -# This cop supports safe autocorrection (--autocorrect). -Performance/RedundantSplitRegexpArgument: - Exclude: - - 'lib/axlsx/workbook/worksheet/sheet_protection.rb' - -# This cop supports safe autocorrection (--autocorrect). -Performance/RegexpMatch: - Exclude: - - 'lib/axlsx/stylesheet/color.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: separated, grouped diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index 47617da5..87308bb1 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -55,7 +55,7 @@ module Axlsx v = v.upcase v = v * 3 if v.size == 2 v = v.rjust(8, 'FF') - raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/) + raise ArgumentError, "Invalid color rgb value: #{v}." unless /[0-9A-F]{8}/.match?(v) @rgb = v end diff --git a/lib/axlsx/workbook/worksheet/sheet_protection.rb b/lib/axlsx/workbook/worksheet/sheet_protection.rb index faf34f97..e506f8d9 100644 --- a/lib/axlsx/workbook/worksheet/sheet_protection.rb +++ b/lib/axlsx/workbook/worksheet/sheet_protection.rb @@ -98,7 +98,7 @@ module Axlsx # @return [String] def encode_password(password) i = 0 - chars = password.split(//) + chars = password.split("") count = chars.size chars.collect! do |char| -- cgit v1.2.3