mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 07:46:17 +01:00
Use match? instead of =~ when MatchData is not used (#34150).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@20168 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -179,7 +179,7 @@ class IssueImport < Import
|
|||||||
else
|
else
|
||||||
add_callback(parent_issue_id, 'set_as_parent', item.position)
|
add_callback(parent_issue_id, 'set_as_parent', item.position)
|
||||||
end
|
end
|
||||||
elsif parent_issue_id =~ /\A\d+\z/
|
elsif /\A\d+\z/.match?(parent_issue_id)
|
||||||
# refers to other row by position
|
# refers to other row by position
|
||||||
parent_issue_id = parent_issue_id.to_i
|
parent_issue_id = parent_issue_id.to_i
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class Setting < ActiveRecord::Base
|
|||||||
if settings.key?(:mail_from)
|
if settings.key?(:mail_from)
|
||||||
begin
|
begin
|
||||||
mail_from = Mail::Address.new(settings[:mail_from])
|
mail_from = Mail::Address.new(settings[:mail_from])
|
||||||
raise unless mail_from.address =~ EmailAddress::EMAIL_REGEXP
|
raise unless EmailAddress::EMAIL_REGEXP.match?(mail_from.address)
|
||||||
rescue
|
rescue
|
||||||
messages << [:mail_from, l('activerecord.errors.messages.invalid')]
|
messages << [:mail_from, l('activerecord.errors.messages.invalid')]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class ChangeRepositoriesToFullSti < ActiveRecord::Migration[4.2]
|
|||||||
Repository.connection.
|
Repository.connection.
|
||||||
select_rows("SELECT id, type FROM #{Repository.table_name}").
|
select_rows("SELECT id, type FROM #{Repository.table_name}").
|
||||||
each do |repository_id, repository_type|
|
each do |repository_id, repository_type|
|
||||||
unless repository_type =~ /^Repository::/
|
unless /^Repository::/.match?(repository_type)
|
||||||
Repository.where(["id = ?", repository_id]).
|
Repository.where(["id = ?", repository_id]).
|
||||||
update_all(["type = ?", "Repository::#{repository_type}"])
|
update_all(["type = ?", "Repository::#{repository_type}"])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ChangeSqliteBooleansTo0And1 < ActiveRecord::Migration[5.2]
|
|||||||
}
|
}
|
||||||
|
|
||||||
def up
|
def up
|
||||||
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name)
|
||||||
COLUMNS.each do |klass, columns|
|
COLUMNS.each do |klass, columns|
|
||||||
columns.each do |column|
|
columns.each do |column|
|
||||||
klass.where("#{column} = 't'").update_all(column => 1)
|
klass.where("#{column} = 't'").update_all(column => 1)
|
||||||
@@ -34,7 +34,7 @@ class ChangeSqliteBooleansTo0And1 < ActiveRecord::Migration[5.2]
|
|||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name)
|
||||||
COLUMNS.each do |klass, columns|
|
COLUMNS.each do |klass, columns|
|
||||||
columns.each do |column|
|
columns.each do |column|
|
||||||
klass.where("#{column} = 1").update_all(column => 't')
|
klass.where("#{column} = 1").update_all(column => 't')
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class ChangeSqliteBooleansDefault < ActiveRecord::Migration[5.2]
|
|||||||
}
|
}
|
||||||
|
|
||||||
def up
|
def up
|
||||||
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name)
|
||||||
DEFAULTS.each do |table, defaults|
|
DEFAULTS.each do |table, defaults|
|
||||||
defaults.each do |column, value|
|
defaults.each do |column, value|
|
||||||
# Reset default values for boolean column (t/f => 1/0)
|
# Reset default values for boolean column (t/f => 1/0)
|
||||||
@@ -85,7 +85,7 @@ class ChangeSqliteBooleansDefault < ActiveRecord::Migration[5.2]
|
|||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
if ActiveRecord::Base.connection.adapter_name =~ /sqlite/i
|
if /sqlite/i.match?(ActiveRecord::Base.connection.adapter_name)
|
||||||
# Cannot restore default values as t/f
|
# Cannot restore default values as t/f
|
||||||
raise ActiveRecord::IrreversibleMigration
|
raise ActiveRecord::IrreversibleMigration
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ module Redmine
|
|||||||
revision = nil
|
revision = nil
|
||||||
parsing = nil
|
parsing = nil
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
if line =~ /^----/
|
if /^----/.match?(line)
|
||||||
revisions << revision if revision
|
revisions << revision if revision
|
||||||
revision = Revision.new(:paths => [], :message => '')
|
revision = Revision.new(:paths => [], :message => '')
|
||||||
parsing = nil
|
parsing = nil
|
||||||
@@ -152,7 +152,7 @@ module Redmine
|
|||||||
revision.scmid = $1.strip
|
revision.scmid = $1.strip
|
||||||
elsif line =~ /^timestamp: (.+)$/
|
elsif line =~ /^timestamp: (.+)$/
|
||||||
revision.time = Time.parse($1).localtime
|
revision.time = Time.parse($1).localtime
|
||||||
elsif line =~ /^ -----/
|
elsif /^ -----/.match?(line)
|
||||||
# partial revisions
|
# partial revisions
|
||||||
parsing = nil unless parsing == 'message'
|
parsing = nil unless parsing == 'message'
|
||||||
elsif line =~ /^(message|added|modified|removed|renamed):/
|
elsif line =~ /^(message|added|modified|removed|renamed):/
|
||||||
|
|||||||
@@ -198,10 +198,10 @@ module Redmine
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
elsif state == "tags"
|
elsif state == "tags"
|
||||||
if /^#{STARTLOG}/ =~ line
|
if /^#{STARTLOG}/.match?(line)
|
||||||
commit_log = ""
|
commit_log = ""
|
||||||
state = "revision"
|
state = "revision"
|
||||||
elsif /^#{ENDLOG}/ =~ line
|
elsif /^#{ENDLOG}/.match?(line)
|
||||||
state = "head"
|
state = "head"
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
@@ -232,13 +232,13 @@ module Redmine
|
|||||||
end
|
end
|
||||||
commit_log = ""
|
commit_log = ""
|
||||||
revision = nil
|
revision = nil
|
||||||
if /^#{ENDLOG}/ =~ line
|
if /^#{ENDLOG}/.match?(line)
|
||||||
state = "entry_start"
|
state = "entry_start"
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
if /^branches: (.+)$/ =~ line
|
if /^branches: (.+)$/.match?(line)
|
||||||
# TODO: version.branch = $1
|
# TODO: version.branch = $1
|
||||||
elsif /^revision (\d+(?:\.\d+)+).*$/ =~ line
|
elsif /^revision (\d+(?:\.\d+)+).*$/ =~ line
|
||||||
revision = $1
|
revision = $1
|
||||||
@@ -260,7 +260,7 @@ module Redmine
|
|||||||
# version.line_minus = 0
|
# version.line_minus = 0
|
||||||
# end
|
# end
|
||||||
else
|
else
|
||||||
commit_log += line unless line =~ /^\*\*\* empty log message \*\*\*/
|
commit_log += line unless /^\*\*\* empty log message \*\*\*/.match?(line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ class RedCloth3 < String
|
|||||||
end
|
end
|
||||||
|
|
||||||
def lT( text )
|
def lT( text )
|
||||||
text =~ /\#$/ ? 'o' : 'u'
|
/\#$/.match?(text) ? 'o' : 'u'
|
||||||
end
|
end
|
||||||
|
|
||||||
def hard_break( text )
|
def hard_break( text )
|
||||||
@@ -908,7 +908,7 @@ class RedCloth3 < String
|
|||||||
|
|
||||||
def refs( text )
|
def refs( text )
|
||||||
@rules.each do |rule_name|
|
@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.match? /^refs_/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1061,9 +1061,9 @@ class RedCloth3 < String
|
|||||||
text.gsub!( ALLTAG_MATCH ) do |line|
|
text.gsub!( ALLTAG_MATCH ) do |line|
|
||||||
## matches are off if we're between <code>, <pre> etc.
|
## matches are off if we're between <code>, <pre> etc.
|
||||||
if $1
|
if $1
|
||||||
if line =~ OFFTAG_OPEN
|
if OFFTAG_OPEN.match?(line)
|
||||||
codepre += 1
|
codepre += 1
|
||||||
elsif line =~ OFFTAG_CLOSE
|
elsif OFFTAG_CLOSE.match?(line)
|
||||||
codepre -= 1
|
codepre -= 1
|
||||||
codepre = 0 if codepre < 0
|
codepre = 0 if codepre < 0
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user