Patch #38146 » 0007-Fix-RuboCop-offense-Performance-RedundantMatch.patch
| .rubocop_todo.yml | ||
|---|---|---|
| 486 | 486 |
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb' |
| 487 | 487 |
- 'test/unit/project_test.rb' |
| 488 | 488 | |
| 489 |
# This cop supports safe autocorrection (--autocorrect). |
|
| 490 |
Performance/RedundantMatch: |
|
| 491 |
Exclude: |
|
| 492 |
- 'app/models/issue_relation.rb' |
|
| 493 |
- 'lib/redmine/wiki_formatting/textile/formatter.rb' |
|
| 494 |
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb' |
|
| 495 | ||
| 496 | 489 |
# This cop supports safe autocorrection (--autocorrect). |
| 497 | 490 |
Performance/RedundantSplitRegexpArgument: |
| 498 | 491 |
Exclude: |
| app/models/issue_relation.rb | ||
|---|---|---|
| 91 | 91 | |
| 92 | 92 |
attrs = attrs.deep_dup |
| 93 | 93 |
if issue_id = attrs.delete('issue_to_id')
|
| 94 |
if issue_id.to_s.strip.match(/\A#?(\d+)\z/)
|
|
| 94 |
if issue_id.to_s.strip =~ /\A#?(\d+)\z/
|
|
| 95 | 95 |
issue_id = $1.to_i |
| 96 | 96 |
self.issue_to = Issue.visible(user).find_by_id(issue_id) |
| 97 | 97 |
end |
| lib/redmine/wiki_formatting/textile/formatter.rb | ||
|---|---|---|
| 109 | 109 |
text.gsub!(/<redpre#(\d+)>/) do |
| 110 | 110 |
content = @pre_list[$1.to_i] |
| 111 | 111 |
# This regex must match any data produced by RedCloth3#rip_offtags |
| 112 |
if content.match(/<code\s+class=(?:"([^"]+)"|'([^']+)')>\s?(.*)/m)
|
|
| 112 |
if content =~ /<code\s+class=(?:"([^"]+)"|'([^']+)')>\s?(.*)/m
|
|
| 113 | 113 |
language = $1 || $2 |
| 114 | 114 |
text = $3 |
| 115 | 115 |
# original language for extension development |
| lib/redmine/wiki_formatting/textile/redcloth3.rb | ||
|---|---|---|
| 1100 | 1100 |
### and it breaks following lines |
| 1101 | 1101 |
htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag && !first.match(/<code\s+class="(\w+)">/) |
| 1102 | 1102 |
line = +"<redpre##{@pre_list.length}>"
|
| 1103 |
first.match(/<#{OFFTAGS}([^>]*)>/o)
|
|
| 1103 |
first =~ /<#{OFFTAGS}([^>]*)>/o
|
|
| 1104 | 1104 |
tag = $1 |
| 1105 |
$2.to_s.match(/(class\=("[^"]+"|'[^']+'))/i)
|
|
| 1105 |
$2.to_s =~ /(class\=("[^"]+"|'[^']+'))/i
|
|
| 1106 | 1106 |
tag << " #{$1}" if $1 && tag == 'code'
|
| 1107 | 1107 |
@pre_list << +"<#{tag}>#{aftertag}"
|
| 1108 | 1108 |
end |