summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-01-11 13:26:31 +0000
committerGo MAEDA <maeda@farend.jp>2023-01-11 13:26:31 +0000
commit70ef2a3db14e9ea2588ddd206664a225d90396d4 (patch)
tree5278d2e3c0dd70612277249fe012d8fd8cf7b798 /lib
parentc53bf36b9a966d1a91fc8f9cb40dc1a9b4e73d95 (diff)
downloadredmine-70ef2a3db14e9ea2588ddd206664a225d90396d4.tar.gz
redmine-70ef2a3db14e9ea2588ddd206664a225d90396d4.zip
Fix RuboCop offense Performance/ConstantRegexp (#38146).
git-svn-id: https://svn.redmine.org/redmine/trunk@22029 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/scm/adapters/cvs_adapter.rb12
-rw-r--r--lib/redmine/wiki_formatting/textile/formatter.rb2
-rw-r--r--lib/redmine/wiki_formatting/textile/redcloth3.rb8
3 files changed, 11 insertions, 11 deletions
diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb
index e5cb524ab..9436562f7 100644
--- a/lib/redmine/scm/adapters/cvs_adapter.rb
+++ b/lib/redmine/scm/adapters/cvs_adapter.rb
@@ -179,7 +179,7 @@ module Redmine
file_state = nil
branch_map = nil
io.each_line() do |line|
- if state != "revision" && /^#{ENDLOG}/.match?(line)
+ if state != "revision" && /^#{ENDLOG}/o.match?(line)
commit_log = ""
revision = nil
state = "entry_start"
@@ -194,7 +194,7 @@ module Redmine
entry_headRev = $1
elsif /^symbolic names:/.match?(line)
state = "symbolic"
- elsif /^#{STARTLOG}/.match?(line)
+ elsif /^#{STARTLOG}/o.match?(line)
commit_log = ""
state = "revision"
end
@@ -207,15 +207,15 @@ module Redmine
next
end
elsif state == "tags"
- if /^#{STARTLOG}/.match?(line)
+ if /^#{STARTLOG}/o.match?(line)
commit_log = ""
state = "revision"
- elsif /^#{ENDLOG}/.match?(line)
+ elsif /^#{ENDLOG}/o.match?(line)
state = "head"
end
next
elsif state == "revision"
- if /^#{ENDLOG}/ =~ line || /^#{STARTLOG}/ =~ line
+ if /^#{ENDLOG}/o =~ line || /^#{STARTLOG}/o =~ line
if revision
revHelper = CvsRevisionHelper.new(revision)
revBranch = "HEAD"
@@ -245,7 +245,7 @@ module Redmine
end
commit_log = ""
revision = nil
- if /^#{ENDLOG}/.match?(line)
+ if /^#{ENDLOG}/o.match?(line)
state = "entry_start"
end
next
diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb
index 54686ca6d..04464763e 100644
--- a/lib/redmine/wiki_formatting/textile/formatter.rb
+++ b/lib/redmine/wiki_formatting/textile/formatter.rb
@@ -57,7 +57,7 @@ module Redmine
l = 1
started = false
ended = false
- text.scan(/(((?:.*?)(\A|\r?\n\s*\r?\n))(h(\d+)(#{A}#{C})\.(?::(\S+))?[ \t](.*?)$)|.*)/m).each do |all, content, lf, heading, level|
+ text.scan(/(((?:.*?)(\A|\r?\n\s*\r?\n))(h(\d+)(#{A}#{C})\.(?::(\S+))?[ \t](.*?)$)|.*)/mo).each do |all, content, lf, heading, level|
if heading.nil?
if ended
after << all
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index c292926a5..637f2883e 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -532,10 +532,10 @@ class RedCloth3 < String
rows = []
fullrow.gsub!(/([^|\s])\s*\n/, "\\1<br />")
fullrow.each_line do |row|
- ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/m
+ ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/mo
cells = []
# the regexp prevents wiki links with a | from being cut as cells
- row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/) do |modifiers, cell|
+ row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/o) do |modifiers, cell|
ctyp = 'd'
ctyp = 'h' if modifiers && modifiers =~ /^_/
@@ -791,7 +791,7 @@ class RedCloth3 < String
when :limit
sta,oqs,qtag,content,oqa = $~[1..6]
atts = nil
- if content =~ /^(#{C})(.+)$/
+ if content =~ /^(#{C})(.+)$/o
atts, content = $~[1..2]
end
else
@@ -1100,7 +1100,7 @@ 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}([^>]*)>/)
+ first.match(/<#{OFFTAGS}([^>]*)>/o)
tag = $1
$2.to_s.match(/(class\=("[^"]+"|'[^']+'))/i)
tag << " #{$1}" if $1 && tag == 'code'