]> source.dussan.org Git - redmine.git/commitdiff
Fix RuboCop offense Performance/RedundantMatch (#38146).
authorGo MAEDA <maeda@farend.jp>
Wed, 11 Jan 2023 13:31:57 +0000 (13:31 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 11 Jan 2023 13:31:57 +0000 (13:31 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22032 e93f8b46-1217-0410-a6f0-8f06a7374b81

.rubocop_todo.yml
app/models/issue_relation.rb
lib/redmine/wiki_formatting/textile/formatter.rb
lib/redmine/wiki_formatting/textile/redcloth3.rb

index 87e78d17dcdccd1eedadac2c9b73a63338117442..b794a7124cf617aee3e822d55ea823d530e4fd13 100644 (file)
@@ -486,13 +486,6 @@ Naming/VariableNumber:
     - 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
     - 'test/unit/project_test.rb'
 
-# This cop supports safe autocorrection (--autocorrect).
-Performance/RedundantMatch:
-  Exclude:
-    - 'app/models/issue_relation.rb'
-    - 'lib/redmine/wiki_formatting/textile/formatter.rb'
-    - 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
-
 # This cop supports safe autocorrection (--autocorrect).
 Performance/RedundantSplitRegexpArgument:
   Exclude:
index f2821340f7b9909e36bc2544d74e9fd75b778f21..639c88e5e0f3c967c1f94e0af61d459c2c94411a 100644 (file)
@@ -91,7 +91,7 @@ class IssueRelation < ActiveRecord::Base
 
     attrs = attrs.deep_dup
     if issue_id = attrs.delete('issue_to_id')
-      if issue_id.to_s.strip.match(/\A#?(\d+)\z/)
+      if issue_id.to_s.strip =~ /\A#?(\d+)\z/
         issue_id = $1.to_i
         self.issue_to = Issue.visible(user).find_by_id(issue_id)
       end
index 04464763ed17a6cdef73e62a227a5ba5f4646351..53c04341d82d9ec247970c368c0b4e7ea0105b51 100644 (file)
@@ -109,7 +109,7 @@ module Redmine
             text.gsub!(/<redpre#(\d+)>/) do
               content = @pre_list[$1.to_i]
               # This regex must match any data produced by RedCloth3#rip_offtags
-              if content.match(/<code\s+class=(?:"([^"]+)"|'([^']+)')>\s?(.*)/m)
+              if content =~ /<code\s+class=(?:"([^"]+)"|'([^']+)')>\s?(.*)/m
                 language = $1 || $2
                 text = $3
                 # original language for extension development
index 637f2883e5a17e77739ebc34a8926ee38ad58f6f..77bfa0ab6842cd6b1a084434786de9a3553f119e 100644 (file)
@@ -1100,9 +1100,9 @@ class RedCloth3 < String
                         ###   and it breaks following lines
                         htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag && !first.match(/<code\s+class="(\w+)">/)
                         line = +"<redpre##{@pre_list.length}>"
-                        first.match(/<#{OFFTAGS}([^>]*)>/o)
+                        first =~ /<#{OFFTAGS}([^>]*)>/o
                         tag = $1
-                        $2.to_s.match(/(class\=("[^"]+"|'[^']+'))/i)
+                        $2.to_s =~ /(class\=("[^"]+"|'[^']+'))/i
                         tag << " #{$1}" if $1 && tag == 'code'
                         @pre_list << +"<#{tag}>#{aftertag}"
                     end