]> source.dussan.org Git - redmine.git/commitdiff
Replace regular expression matches with String#start_with? / end_with? (#40010).
authorGo MAEDA <maeda@farend.jp>
Thu, 11 Jan 2024 11:27:25 +0000 (11:27 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 11 Jan 2024 11:27:25 +0000 (11:27 +0000)
Patch by Go MAEDA (@maeda).

git-svn-id: https://svn.redmine.org/redmine/trunk@22605 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue_query.rb
lib/redmine/scm/adapters/abstract_adapter.rb
lib/redmine/scm/adapters/bazaar_adapter.rb
lib/redmine/scm/adapters/cvs_adapter.rb
lib/redmine/scm/adapters/subversion_adapter.rb
lib/redmine/wiki_formatting/textile/redcloth3.rb
lib/tasks/locales.rake

index 7c1027ad3247a19edc57b5218c32b5d703c585ef..4905b1cfb6d43690a4673250683eb354bb94ed0a 100644 (file)
@@ -481,7 +481,7 @@ class IssueQuery < Query
       " WHERE #{Journal.table_name}.journalized_type='Issue' AND #{Journal.table_name}.journalized_id=#{Issue.table_name}.id" +
       " AND (#{sql_for_field field, operator.delete_prefix('!'), value, Journal.table_name, 'notes'})" +
       " AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})"
-    "#{/^!/.match?(operator) ? "NOT EXISTS" : "EXISTS"} (#{subquery})"
+    "#{operator.start_with?('!') ? "NOT EXISTS" : "EXISTS"} (#{subquery})"
   end
 
   def sql_for_updated_by_field(field, operator, value)
index 0baf2962c35227f7d62e100d59180e07658784be..23477046d8889a5e551c2042dbc2dc22573d1b59 100644 (file)
@@ -194,7 +194,7 @@ module Redmine
 
         def target(path, sq=true)
           path ||= ''
-          base = /^\//.match?(path) ? root_url : url
+          base = path.start_with?('/') ? root_url : url
           str = "#{base}/#{path}".gsub(/[?<>\*]/, '')
           if sq
             str = shell_quote(str)
index 048b6b59fa6177a7ff5287fb7648bb662a708636..c1d9481d23343591e0a1f09e9c329acb8b287c8c 100644 (file)
@@ -136,7 +136,7 @@ module Redmine
             revision = nil
             parsing  = nil
             io.each_line do |line|
-              if /^----/.match?(line)
+              if line.start_with?('----')
                 revisions << revision if revision
                 revision = Revision.new(:paths => [], :message => '')
                 parsing = nil
@@ -151,7 +151,7 @@ module Redmine
                   revision.scmid = $1.strip
                 elsif line =~ /^timestamp: (.+)$/
                   revision.time = Time.parse($1).localtime
-                elsif /^    -----/.match?(line)
+                elsif line.start_with?('    -----')
                   # partial revisions
                   parsing = nil unless parsing == 'message'
                 elsif line =~ /^(message|added|modified|removed|renamed):/
index 4d694a6abdfe7dad8796046ab6b5ced0a4eb6f55..9439eb5139a6e8822ba2852b1c26f482952ad16c 100644 (file)
@@ -173,7 +173,7 @@ module Redmine
             file_state = nil
             branch_map = nil
             io.each_line() do |line|
-              if state != "revision" && /^#{ENDLOG}/o.match?(line)
+              if state != "revision" && line.start_with?(ENDLOG)
                 commit_log = ""
                 revision   = nil
                 state      = "entry_start"
@@ -186,9 +186,9 @@ module Redmine
                   logger.debug("Path #{entry_path} <=> Name #{entry_name}")
                 elsif /^head: (.+)$/ =~ line
                   entry_headRev = $1
-                elsif /^symbolic names:/.match?(line)
+                elsif line.start_with?('symbolic names:')
                   state = "symbolic"
-                elsif /^#{STARTLOG}/o.match?(line)
+                elsif line.start_with?(STARTLOG)
                   commit_log = ""
                   state      = "revision"
                 end
@@ -201,15 +201,15 @@ module Redmine
                   next
                 end
               elsif state == "tags"
-                if /^#{STARTLOG}/o.match?(line)
+                if line.start_with?(STARTLOG)
                   commit_log = ""
                   state = "revision"
-                elsif /^#{ENDLOG}/o.match?(line)
+                elsif line.start_with?(ENDLOG)
                   state = "head"
                 end
                 next
               elsif state == "revision"
-                if /^#{ENDLOG}/o =~ line || /^#{STARTLOG}/o =~ line
+                if line.start_with?(ENDLOG, STARTLOG)
                   if revision
                     revHelper = CvsRevisionHelper.new(revision)
                     revBranch = "HEAD"
@@ -239,7 +239,7 @@ module Redmine
                   end
                   commit_log = ""
                   revision   = nil
-                  if /^#{ENDLOG}/o.match?(line)
+                  if line.start_with?(ENDLOG)
                     state = "entry_start"
                   end
                   next
@@ -267,7 +267,7 @@ module Redmine
                   #                  version.line_minus = 0
                   #                end
                 else
-                  commit_log += line unless /^\*\*\* empty log message \*\*\*/.match?(line)
+                  commit_log += line unless line.start_with?('*** empty log message ***')
                 end
               end
             end
index b7827cb93c92a3f80b163afff88e81a794d4607a..a64006ebf25bd37eca160b84c6885468a82b6bc1 100644 (file)
@@ -299,7 +299,7 @@ module Redmine
         end
 
         def target(path = '')
-          base = /^\//.match?(path) ? root_url : url
+          base = path.start_with?('/') ? root_url : url
           uri = "#{base}/#{path}"
           uri = Addressable::URI.encode(uri)
           shell_quote(uri.gsub(/[?<>\*]/, ''))
index 647bd6f8ba3c7110997f1617c3cc38fa0a333ffb..3bc8ea29d462b4a2dc79fc96026e7cc02babe4be 100644 (file)
@@ -537,7 +537,7 @@ class RedCloth3 < String
                 # the regexp prevents wiki links with a | from being cut as cells
                 row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/o) do |modifiers, cell|
                     ctyp = 'd'
-                    ctyp = 'h' if modifiers && modifiers =~ /^_/
+                    ctyp = 'h' if modifiers&.start_with?('_')
 
                     catts = nil
                     catts = pba( modifiers, 'td' ) if modifiers
@@ -637,7 +637,7 @@ class RedCloth3 < String
     end
 
     def lT( text )
-        /\#$/.match?(text) ? 'o' : 'u'
+        text.end_with?('#') ? 'o' : 'u'
     end
 
     def hard_break( text )
@@ -673,7 +673,7 @@ class RedCloth3 < String
 
                     block_applied = 0
                     @rules.each do |rule_name|
-                        block_applied += 1 if rule_name.to_s.match /^block_/ and method(rule_name).call(blk)
+                        block_applied += 1 if rule_name.to_s.start_with?('block_') and method(rule_name).call(blk)
                     end
                     if block_applied.zero?
                         if deep_code
@@ -909,7 +909,7 @@ class RedCloth3 < String
 
     def refs( text )
         @rules.each do |rule_name|
-            method( rule_name ).call( text ) if rule_name.to_s.match? /^refs_/
+            method( rule_name ).call( text ) if rule_name.to_s.start_with?('refs_')
         end
     end
 
index 1b56e68a73baaa2ebdd0f11692c1f9ed5a69c9e9..aec65a9713f75ed14409e46a1fbcb829126580f3 100644 (file)
@@ -43,7 +43,7 @@ namespace :locales do
 
       missing_keys.each do |key|
         {key => en_strings[key]}.to_yaml.each_line do |line|
-          next if line =~ /^---/ || line.empty?
+          next if line.start_with?('---') || line.empty?
           puts "  #{line}"
           lang << "  #{line}"
         end
@@ -133,7 +133,7 @@ END_DESC
       File.open(path, 'a') do |file|
         adds.each do |kv|
           Hash[*kv].to_yaml.each_line do |line|
-            file.puts "  #{line}" unless (line =~ /^---/ || line.empty?)
+            file.puts "  #{line}" unless (line.start_with?('---') || line.empty?)
           end
         end
       end