Skip to content

Commit 78dfef0

Browse files
committed
Replace gsub with tr, delete, or squeeze (#34161).
git-svn-id: http://svn.redmine.org/redmine/trunk@20176 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent b469532 commit 78dfef0

15 files changed

+18
-40
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,6 @@ Performance/RedundantMatch:
564564
- 'lib/redmine/wiki_formatting/textile/formatter.rb'
565565
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
566566

567-
# Cop supports --auto-correct.
568-
Performance/Squeeze:
569-
Exclude:
570-
- 'test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb'
571-
572567
# Cop supports --auto-correct.
573568
# Configuration parameters: AutoCorrect.
574569
Performance/StringInclude:
@@ -578,23 +573,6 @@ Performance/StringInclude:
578573
- 'test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb'
579574
- 'test/unit/lib/redmine/wiki_formatting/macros_test.rb'
580575

581-
# Cop supports --auto-correct.
582-
Performance/StringReplacement:
583-
Exclude:
584-
- 'app/helpers/application_helper.rb'
585-
- 'app/helpers/imports_helper.rb'
586-
- 'app/helpers/settings_helper.rb'
587-
- 'lib/redmine/core_ext/string/conversions.rb'
588-
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
589-
- 'test/functional/repositories_cvs_controller_test.rb'
590-
- 'test/functional/repositories_git_controller_test.rb'
591-
- 'test/helpers/application_helper_test.rb'
592-
- 'test/integration/repositories_git_test.rb'
593-
- 'test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb'
594-
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
595-
- 'test/unit/repository_cvs_test.rb'
596-
- 'test/unit/repository_git_test.rb'
597-
598576
# Cop supports --auto-correct.
599577
Performance/Sum:
600578
Exclude:

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ def parse_inline_attachments(text, project, obj, attr, only_path, options)
895895
# search for the picture in attachments
896896
if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
897897
image_url = download_named_attachment_url(found, found.filename, :only_path => only_path)
898-
desc = found.description.to_s.gsub('"', '')
898+
desc = found.description.to_s.delete('"')
899899
if !desc.blank? && alttext.blank?
900900
alt = " title=\"#{desc}\" alt=\"#{desc}\""
901901
end

app/helpers/imports_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def mapping_select_tag(import, field, options={})
4646
# Returns the options for the date_format setting
4747
def date_format_options
4848
Import::DATE_FORMATS.map do |f|
49-
format = f.gsub('%', '').gsub(/[dmY]/) do
49+
format = f.delete('%').gsub(/[dmY]/) do
5050
{'d' => 'DD', 'm' => 'MM', 'Y' => 'YYYY'}[$&]
5151
end
5252
[format, f]

app/helpers/settings_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def parent_issue_done_ratio_options
209209
def date_format_setting_options(locale)
210210
Setting::DATE_FORMATS.map do |f|
211211
today = ::I18n.l(User.current.today, :locale => locale, :format => f)
212-
format = f.gsub('%', '').gsub(/[dmY]/) do
212+
format = f.delete('%').gsub(/[dmY]/) do
213213
{'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]
214214
end
215215
["#{today} (#{format})", f]

lib/redmine/core_ext/string/conversions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def to_hours
3838
s.gsub!(%r{^((\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}i) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0) : m[0] }
3939
end
4040
# 2,5 => 2.5
41-
s.gsub!(',', '.')
41+
s.tr!(',', '.')
4242
begin; Kernel.Float(s); rescue; nil; end
4343
end
4444
end

lib/redmine/wiki_formatting/textile/redcloth3.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ def no_textile( text )
10161016
def clean_white_space( text )
10171017
# normalize line breaks
10181018
text.gsub!( /\r\n/, "\n" )
1019-
text.gsub!( /\r/, "\n" )
1019+
text.tr!( "\r", "\n" )
10201020
text.gsub!( /\t/, ' ' )
10211021
text.gsub!( /^ +$/, '' )
10221022
text.gsub!( /\n{3,}/, "\n\n" )

test/functional/repositories_cvs_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest
2626
:repositories, :enabled_modules
2727

2828
REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
29-
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
29+
REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
3030
# CVS module
3131
MODULE_NAME = 'test'
3232
PRJ_ID = 3

test/functional/repositories_git_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
2626
:repositories, :enabled_modules
2727

2828
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
29-
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
29+
REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
3030
PRJ_ID = 3
3131
NUM_REV = 28
3232

test/helpers/application_helper_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ def test_table_of_content
14231423
'</ul>'
14241424

14251425
@project = Project.find(1)
1426-
assert textilizable(raw).gsub("\n", "").include?(expected)
1426+
assert textilizable(raw).delete("\n").include?(expected)
14271427
end
14281428

14291429
def test_table_of_content_should_generate_unique_anchors
@@ -1447,7 +1447,7 @@ def test_table_of_content_should_generate_unique_anchors
14471447
'</li>' +
14481448
'</ul>'
14491449
@project = Project.find(1)
1450-
result = textilizable(raw).gsub("\n", "")
1450+
result = textilizable(raw).delete("\n")
14511451
assert_include expected, result
14521452
assert_include '<a name="Subtitle">', result
14531453
assert_include '<a name="Subtitle-2">', result
@@ -1468,7 +1468,7 @@ def test_table_of_content_should_contain_included_page_headings
14681468
'<li><a href="#Child-page-1">Child page 1</a></li>' +
14691469
'</ul>'
14701470
@project = Project.find(1)
1471-
assert textilizable(raw).gsub("\n", "").include?(expected)
1471+
assert textilizable(raw).delete("\n").include?(expected)
14721472
end
14731473

14741474
def test_toc_with_textile_formatting_should_be_parsed
@@ -1519,7 +1519,7 @@ def test_section_edit_links
15191519
:edit_section_links =>
15201520
{:controller => 'wiki', :action => 'edit',
15211521
:project_id => '1', :id => 'Test'}
1522-
).gsub("\n", "")
1522+
).delete("\n")
15231523
# heading that contains inline code
15241524
assert_match(
15251525
Regexp.new('<div class="contextual heading-2" title="Edit this section" id="section-4">' +

test/integration/repositories_git_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class RepositoriesGitTest < Redmine::IntegrationTest
2424
:repositories, :enabled_modules
2525

2626
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
27-
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
27+
REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
2828
PRJ_ID = 3
2929
NUM_REV = 28
3030

0 commit comments

Comments
 (0)