Project

General

Profile

Patch #38146 » 0007-Fix-RuboCop-offense-Performance-RedundantMatch.patch

Go MAEDA, 2023-01-04 07:28

View differences:

.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/RedundantMatch:
Exclude:
- 'app/models/issue_relation.rb'
- 'lib/redmine/wiki_formatting/textile/formatter.rb'
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
# This cop supports safe autocorrection (--autocorrect).
Performance/RedundantSplitRegexpArgument:
Exclude:
app/models/issue_relation.rb
attrs = attrs.deep_dup
if issue_id = attrs.delete('issue_to_id')
if issue_id.to_s.strip.match(/\A#?(\d+)\z/)
if issue_id.to_s.strip =~ /\A#?(\d+)\z/
issue_id = $1.to_i
self.issue_to = Issue.visible(user).find_by_id(issue_id)
end
lib/redmine/wiki_formatting/textile/formatter.rb
text.gsub!(/<redpre#(\d+)>/) do
content = @pre_list[$1.to_i]
# This regex must match any data produced by RedCloth3#rip_offtags
if content.match(/<code\s+class=(?:"([^"]+)"|'([^']+)')>\s?(.*)/m)
if content =~ /<code\s+class=(?:"([^"]+)"|'([^']+)')>\s?(.*)/m
language = $1 || $2
text = $3
# original language for extension development
lib/redmine/wiki_formatting/textile/redcloth3.rb
### 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}([^>]*)>/o)
first =~ /<#{OFFTAGS}([^>]*)>/o
tag = $1
$2.to_s.match(/(class\=("[^"]+"|'[^']+'))/i)
$2.to_s =~ /(class\=("[^"]+"|'[^']+'))/i
tag << " #{$1}" if $1 && tag == 'code'
@pre_list << +"<#{tag}>#{aftertag}"
end
(7-7/9)