summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.rubocop_todo.yml22
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/imports_helper.rb2
-rw-r--r--app/helpers/settings_helper.rb2
-rw-r--r--lib/redmine/core_ext/string/conversions.rb2
-rw-r--r--lib/redmine/wiki_formatting/textile/redcloth3.rb2
-rw-r--r--test/functional/repositories_cvs_controller_test.rb2
-rw-r--r--test/functional/repositories_git_controller_test.rb2
-rw-r--r--test/helpers/application_helper_test.rb8
-rw-r--r--test/integration/repositories_git_test.rb2
-rw-r--r--test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb2
-rw-r--r--test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb2
-rw-r--r--test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb2
-rw-r--r--test/unit/repository_cvs_test.rb2
-rw-r--r--test/unit/repository_git_test.rb4
15 files changed, 18 insertions, 40 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f225a4535..9722b1dca 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -565,11 +565,6 @@ Performance/RedundantMatch:
- 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
# Cop supports --auto-correct.
-Performance/Squeeze:
- Exclude:
- - 'test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb'
-
-# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/StringInclude:
Exclude:
@@ -579,23 +574,6 @@ Performance/StringInclude:
- 'test/unit/lib/redmine/wiki_formatting/macros_test.rb'
# Cop supports --auto-correct.
-Performance/StringReplacement:
- Exclude:
- - 'app/helpers/application_helper.rb'
- - 'app/helpers/imports_helper.rb'
- - 'app/helpers/settings_helper.rb'
- - 'lib/redmine/core_ext/string/conversions.rb'
- - 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
- - 'test/functional/repositories_cvs_controller_test.rb'
- - 'test/functional/repositories_git_controller_test.rb'
- - 'test/helpers/application_helper_test.rb'
- - 'test/integration/repositories_git_test.rb'
- - 'test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb'
- - 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
- - 'test/unit/repository_cvs_test.rb'
- - 'test/unit/repository_git_test.rb'
-
-# Cop supports --auto-correct.
Performance/Sum:
Exclude:
- 'app/helpers/issues_helper.rb'
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 2e54fbefe..5a0868c2e 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -895,7 +895,7 @@ module ApplicationHelper
# search for the picture in attachments
if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
image_url = download_named_attachment_url(found, found.filename, :only_path => only_path)
- desc = found.description.to_s.gsub('"', '')
+ desc = found.description.to_s.delete('"')
if !desc.blank? && alttext.blank?
alt = " title=\"#{desc}\" alt=\"#{desc}\""
end
diff --git a/app/helpers/imports_helper.rb b/app/helpers/imports_helper.rb
index c2d4c59ea..ab3a26b6e 100644
--- a/app/helpers/imports_helper.rb
+++ b/app/helpers/imports_helper.rb
@@ -46,7 +46,7 @@ module ImportsHelper
# Returns the options for the date_format setting
def date_format_options
Import::DATE_FORMATS.map do |f|
- format = f.gsub('%', '').gsub(/[dmY]/) do
+ format = f.delete('%').gsub(/[dmY]/) do
{'d' => 'DD', 'm' => 'MM', 'Y' => 'YYYY'}[$&]
end
[format, f]
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 05518d21c..e9a163588 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -209,7 +209,7 @@ module SettingsHelper
def date_format_setting_options(locale)
Setting::DATE_FORMATS.map do |f|
today = ::I18n.l(User.current.today, :locale => locale, :format => f)
- format = f.gsub('%', '').gsub(/[dmY]/) do
+ format = f.delete('%').gsub(/[dmY]/) do
{'d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy'}[$&]
end
["#{today} (#{format})", f]
diff --git a/lib/redmine/core_ext/string/conversions.rb b/lib/redmine/core_ext/string/conversions.rb
index a6ff884ec..c52b334e4 100644
--- a/lib/redmine/core_ext/string/conversions.rb
+++ b/lib/redmine/core_ext/string/conversions.rb
@@ -38,7 +38,7 @@ module Redmine
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] }
end
# 2,5 => 2.5
- s.gsub!(',', '.')
+ s.tr!(',', '.')
begin; Kernel.Float(s); rescue; nil; end
end
end
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index b47296b1b..3c43a54d9 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -1016,7 +1016,7 @@ class RedCloth3 < String
def clean_white_space( text )
# normalize line breaks
text.gsub!( /\r\n/, "\n" )
- text.gsub!( /\r/, "\n" )
+ text.tr!( "\r", "\n" )
text.gsub!( /\t/, ' ' )
text.gsub!( /^ +$/, '' )
text.gsub!( /\n{3,}/, "\n\n" )
diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb
index 1ac98ee95..54b867599 100644
--- a/test/functional/repositories_cvs_controller_test.rb
+++ b/test/functional/repositories_cvs_controller_test.rb
@@ -26,7 +26,7 @@ class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest
:repositories, :enabled_modules
REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
- REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
# CVS module
MODULE_NAME = 'test'
PRJ_ID = 3
diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb
index 555446fa8..3891a9ba3 100644
--- a/test/functional/repositories_git_controller_test.rb
+++ b/test/functional/repositories_git_controller_test.rb
@@ -26,7 +26,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
:repositories, :enabled_modules
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
- REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
PRJ_ID = 3
NUM_REV = 28
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index adff43530..91f1b097a 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1423,7 +1423,7 @@ class ApplicationHelperTest < Redmine::HelperTest
'</ul>'
@project = Project.find(1)
- assert textilizable(raw).gsub("\n", "").include?(expected)
+ assert textilizable(raw).delete("\n").include?(expected)
end
def test_table_of_content_should_generate_unique_anchors
@@ -1447,7 +1447,7 @@ class ApplicationHelperTest < Redmine::HelperTest
'</li>' +
'</ul>'
@project = Project.find(1)
- result = textilizable(raw).gsub("\n", "")
+ result = textilizable(raw).delete("\n")
assert_include expected, result
assert_include '<a name="Subtitle">', result
assert_include '<a name="Subtitle-2">', result
@@ -1468,7 +1468,7 @@ class ApplicationHelperTest < Redmine::HelperTest
'<li><a href="#Child-page-1">Child page 1</a></li>' +
'</ul>'
@project = Project.find(1)
- assert textilizable(raw).gsub("\n", "").include?(expected)
+ assert textilizable(raw).delete("\n").include?(expected)
end
def test_toc_with_textile_formatting_should_be_parsed
@@ -1519,7 +1519,7 @@ class ApplicationHelperTest < Redmine::HelperTest
:edit_section_links =>
{:controller => 'wiki', :action => 'edit',
:project_id => '1', :id => 'Test'}
- ).gsub("\n", "")
+ ).delete("\n")
# heading that contains inline code
assert_match(
Regexp.new('<div class="contextual heading-2" title="Edit this section" id="section-4">' +
diff --git a/test/integration/repositories_git_test.rb b/test/integration/repositories_git_test.rb
index c6761004d..5c54d1e2f 100644
--- a/test/integration/repositories_git_test.rb
+++ b/test/integration/repositories_git_test.rb
@@ -24,7 +24,7 @@ class RepositoriesGitTest < Redmine::IntegrationTest
:repositories, :enabled_modules
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
- REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
PRJ_ID = 3
NUM_REV = 28
diff --git a/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb
index 201a0e4e2..239e5ce30 100644
--- a/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb
+++ b/test/unit/lib/redmine/scm/adapters/bazaar_adapter_test.rb
@@ -21,7 +21,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__)
class BazaarAdapterTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
- REPOSITORY_PATH.gsub!(/\/+/, '/')
+ REPOSITORY_PATH.squeeze!('/')
if File.directory?(REPOSITORY_PATH)
def setup
diff --git a/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb
index 0c679d6d2..f0ceca300 100644
--- a/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb
+++ b/test/unit/lib/redmine/scm/adapters/cvs_adapter_test.rb
@@ -21,7 +21,7 @@ require File.expand_path('../../../../../../test_helper', __FILE__)
class CvsAdapterTest < ActiveSupport::TestCase
REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s
- REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
MODULE_NAME = 'test'
if File.directory?(REPOSITORY_PATH)
diff --git a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
index e0f506bfd..2c0b949c3 100644
--- a/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
+++ b/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb
@@ -85,7 +85,7 @@ class MercurialAdapterTest < ActiveSupport::TestCase
[REPOSITORY_PATH, REPOSITORY_PATH + "/",
REPOSITORY_PATH + "//"].each do |repo|
adp = Redmine::Scm::Adapters::MercurialAdapter.new(repo)
- repo_path = adp.info.root_url.gsub(/\\/, "/")
+ repo_path = adp.info.root_url.tr('\\', "/")
assert_equal REPOSITORY_PATH, repo_path
assert_equal '39', adp.info.lastrev.revision
assert_equal '04aed9840e9266e535f5f20f7e42c9f9f84f9cf4', adp.info.lastrev.scmid
diff --git a/test/unit/repository_cvs_test.rb b/test/unit/repository_cvs_test.rb
index c3c592e68..2eafa8395 100644
--- a/test/unit/repository_cvs_test.rb
+++ b/test/unit/repository_cvs_test.rb
@@ -25,7 +25,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
include Redmine::I18n
REPOSITORY_PATH = repository_path('cvs')
- REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
# CVS module
MODULE_NAME = 'test'
CHANGESETS_NUM = 7
diff --git a/test/unit/repository_git_test.rb b/test/unit/repository_git_test.rb
index 1a2c51ea8..23557c067 100644
--- a/test/unit/repository_git_test.rb
+++ b/test/unit/repository_git_test.rb
@@ -25,10 +25,10 @@ class RepositoryGitTest < ActiveSupport::TestCase
include Redmine::I18n
REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s
- REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
REPOSITORY_UTF8_PATH = Rails.root.join('tmp/test/git_utf8_repository').to_s
- REPOSITORY_UTF8_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ REPOSITORY_UTF8_PATH.tr!('/', "\\") if Redmine::Platform.mswin?
NUM_REV = 28
NUM_HEAD = 8