diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 21552dfd6..0ef83a473 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -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.sub(/^!/, ''), 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) diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 0baf2962c..23477046d 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -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) diff --git a/lib/redmine/scm/adapters/bazaar_adapter.rb b/lib/redmine/scm/adapters/bazaar_adapter.rb index 048b6b59f..c1d9481d2 100644 --- a/lib/redmine/scm/adapters/bazaar_adapter.rb +++ b/lib/redmine/scm/adapters/bazaar_adapter.rb @@ -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):/ diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb index 4d694a6ab..9439eb513 100644 --- a/lib/redmine/scm/adapters/cvs_adapter.rb +++ b/lib/redmine/scm/adapters/cvs_adapter.rb @@ -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 diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb index b7827cb93..a64006ebf 100644 --- a/lib/redmine/scm/adapters/subversion_adapter.rb +++ b/lib/redmine/scm/adapters/subversion_adapter.rb @@ -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(/[?<>\*]/, '')) diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index 647bd6f8b..3bc8ea29d 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -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 diff --git a/lib/tasks/locales.rake b/lib/tasks/locales.rake index 1b56e68a7..aec65a971 100644 --- a/lib/tasks/locales.rake +++ b/lib/tasks/locales.rake @@ -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