Patch #38146 » 0004-Fix-RuboCop-offense-Performance-ConstantRegexp.patch
| .rubocop_todo.yml | ||
|---|---|---|
|
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
|
||
|
- 'test/unit/project_test.rb'
|
||
|
# This cop supports safe autocorrection (--autocorrect).
|
||
|
Performance/ConstantRegexp:
|
||
|
Exclude:
|
||
|
- 'app/models/changeset.rb'
|
||
|
- 'lib/redmine/scm/adapters/cvs_adapter.rb'
|
||
|
- 'lib/redmine/wiki_formatting/textile/formatter.rb'
|
||
|
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
|
||
|
Performance/FixedSize:
|
||
|
Exclude:
|
||
|
- 'test/integration/api_test/issues_test.rb'
|
||
| app/models/changeset.rb | ||
|---|---|---|
|
refs = match[3]
|
||
|
next unless action.present? || ref_keywords_any
|
||
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
||
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/o).each do |m|
|
||
|
issue = find_referenced_issue_by_id(m[0].to_i)
|
||
|
hours = m[2]
|
||
|
if issue && !issue_linked_to_same_commit?(issue)
|
||
| lib/redmine/scm/adapters/cvs_adapter.rb | ||
|---|---|---|
|
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"
|
||
| ... | ... | |
|
entry_headRev = $1
|
||
|
elsif /^symbolic names:/.match?(line)
|
||
|
state = "symbolic"
|
||
|
elsif /^#{STARTLOG}/.match?(line)
|
||
|
elsif /^#{STARTLOG}/o.match?(line)
|
||
|
commit_log = ""
|
||
|
state = "revision"
|
||
|
end
|
||
| ... | ... | |
|
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"
|
||
| ... | ... | |
|
end
|
||
|
commit_log = ""
|
||
|
revision = nil
|
||
|
if /^#{ENDLOG}/.match?(line)
|
||
|
if /^#{ENDLOG}/o.match?(line)
|
||
|
state = "entry_start"
|
||
|
end
|
||
|
next
|
||
| lib/redmine/wiki_formatting/textile/formatter.rb | ||
|---|---|---|
|
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
|
||
| lib/redmine/wiki_formatting/textile/redcloth3.rb | ||
|---|---|---|
|
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 =~ /^_/
|
||
| ... | ... | |
|
when :limit
|
||
|
sta,oqs,qtag,content,oqa = $~[1..6]
|
||
|
atts = nil
|
||
|
if content =~ /^(#{C})(.+)$/
|
||
|
if content =~ /^(#{C})(.+)$/o
|
||
|
atts, content = $~[1..2]
|
||
|
end
|
||
|
else
|
||
| ... | ... | |
|
### 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'
|
||