summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-10-03 16:09:57 +0200
committerRobert Speicher <rspeicher@gmail.com>2016-10-03 16:09:57 +0200
commit4a191c83d1db31aac16241dbf99ac45088efb99a (patch)
treec5035e58f55263a2d59a8b5cb606326056a13a58
parentdfb9cab828a11cf00522734d11c2472e8b540b5c (diff)
downloadgitlab-ce-4a191c83d1db31aac16241dbf99ac45088efb99a.tar.gz
Enable Lint/StringConversionInInterpolation cop and autocorrect offensesrs-string-conversion-in-interpolation
-rw-r--r--.rubocop.yml4
-rw-r--r--.rubocop_todo.yml5
-rw-r--r--app/controllers/concerns/spammable_actions.rb2
-rw-r--r--app/helpers/projects_helper.rb2
-rw-r--r--app/models/commit_range.rb2
-rw-r--r--app/services/system_hooks_service.rb2
-rw-r--r--app/services/system_note_service.rb2
-rw-r--r--spec/finders/access_requests_finder_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/attribute_configuration_spec.rb2
-rw-r--r--spec/services/members/approve_access_request_service_spec.rb2
-rw-r--r--spec/services/members/request_access_service_spec.rb2
11 files changed, 13 insertions, 14 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 5bd31ccf329..c84755859cb 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -639,6 +639,10 @@ Lint/RescueException:
Lint/ShadowedException:
Enabled: false
+# Checks for Object#to_s usage in string interpolation.
+Lint/StringConversionInInterpolation:
+ Enabled: true
+
# Do not use prefix `_` for a variable that is used.
Lint/UnderscorePrefixedVariableName:
Enabled: true
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 87520c67dd5..b6ed6e33397 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -27,11 +27,6 @@ Lint/Loop:
Lint/ShadowingOuterLocalVariable:
Enabled: false
-# Offense count: 6
-# Cop supports --auto-correct.
-Lint/StringConversionInInterpolation:
- Enabled: false
-
# Offense count: 49
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb
index 29e243c66a3..99acd98ae13 100644
--- a/app/controllers/concerns/spammable_actions.rb
+++ b/app/controllers/concerns/spammable_actions.rb
@@ -7,7 +7,7 @@ module SpammableActions
def mark_as_spam
if SpamService.new(spammable).mark_as_spam!
- redirect_to spammable, notice: "#{spammable.class.to_s} was submitted to Akismet successfully."
+ redirect_to spammable, notice: "#{spammable.class} was submitted to Akismet successfully."
else
redirect_to spammable, alert: 'Error with Akismet. Please check the logs for more info.'
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 56477733ea2..e667c9e4e2e 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -139,7 +139,7 @@ module ProjectsHelper
end
options = options_for_select(options, selected: highest_available_option || @project.project_feature.public_send(field))
- content_tag(:select, options, name: "project[project_feature_attributes][#{field.to_s}]", id: "project_project_feature_attributes_#{field.to_s}", class: "pull-right form-control", data: { field: field }).html_safe
+ content_tag(:select, options, name: "project[project_feature_attributes][#{field}]", id: "project_project_feature_attributes_#{field}", class: "pull-right form-control", data: { field: field }).html_safe
end
private
diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb
index 656a242c265..ac2477fd973 100644
--- a/app/models/commit_range.rb
+++ b/app/models/commit_range.rb
@@ -80,7 +80,7 @@ class CommitRange
end
def inspect
- %(#<#{self.class}:#{object_id} #{to_s}>)
+ %(#<#{self.class}:#{object_id} #{self}>)
end
def to_s
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb
index 1fb72cf89e9..a2bfa422c9d 100644
--- a/app/services/system_hooks_service.rb
+++ b/app/services/system_hooks_service.rb
@@ -72,7 +72,7 @@ class SystemHooksService
return 'user_add_to_group' if event == :create
return 'user_remove_from_group' if event == :destroy
else
- "#{model.class.name.downcase}_#{event.to_s}"
+ "#{model.class.name.downcase}_#{event}"
end
end
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 5ccaa5275b7..bf251816e7e 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -246,7 +246,7 @@ module SystemNoteService
'deleted'
end
- body = "#{verb} #{branch_type.to_s} branch `#{branch}`".capitalize
+ body = "#{verb} #{branch_type} branch `#{branch}`".capitalize
create_note(noteable: noteable, project: project, author: author, note: body)
end
diff --git a/spec/finders/access_requests_finder_spec.rb b/spec/finders/access_requests_finder_spec.rb
index 626513200e4..8cfea9659cb 100644
--- a/spec/finders/access_requests_finder_spec.rb
+++ b/spec/finders/access_requests_finder_spec.rb
@@ -16,7 +16,7 @@ describe AccessRequestsFinder, services: true do
access_requesters = described_class.new(source).public_send(method_name, user)
expect(access_requesters.size).to eq(1)
- expect(access_requesters.first).to be_a "#{source.class.to_s}Member".constantize
+ expect(access_requesters.first).to be_a "#{source.class}Member".constantize
expect(access_requesters.first.user).to eq(access_requester)
end
end
diff --git a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb
index 2ba344092ce..2e19d590d83 100644
--- a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb
+++ b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb
@@ -27,7 +27,7 @@ describe 'Import/Export attribute configuration', lib: true do
relation_names.each do |relation_name|
relation_class = relation_class_for_name(relation_name)
- expect(safe_model_attributes[relation_class.to_s]).not_to be_nil, "Expected exported class #{relation_class.to_s} to exist in safe_model_attributes"
+ expect(safe_model_attributes[relation_class.to_s]).not_to be_nil, "Expected exported class #{relation_class} to exist in safe_model_attributes"
current_attributes = parsed_attributes(relation_name, relation_class.attribute_names)
safe_attributes = safe_model_attributes[relation_class.to_s]
diff --git a/spec/services/members/approve_access_request_service_spec.rb b/spec/services/members/approve_access_request_service_spec.rb
index 6fca80b5613..03e296259f9 100644
--- a/spec/services/members/approve_access_request_service_spec.rb
+++ b/spec/services/members/approve_access_request_service_spec.rb
@@ -26,7 +26,7 @@ describe Members::ApproveAccessRequestService, services: true do
it 'returns a <Source>Member' do
member = described_class.new(source, user, params).execute
- expect(member).to be_a "#{source.class.to_s}Member".constantize
+ expect(member).to be_a "#{source.class}Member".constantize
expect(member.requested_at).to be_nil
end
diff --git a/spec/services/members/request_access_service_spec.rb b/spec/services/members/request_access_service_spec.rb
index dff5b4917ae..0d2d5f03199 100644
--- a/spec/services/members/request_access_service_spec.rb
+++ b/spec/services/members/request_access_service_spec.rb
@@ -19,7 +19,7 @@ describe Members::RequestAccessService, services: true do
it 'returns a <Source>Member' do
member = described_class.new(source, user).execute
- expect(member).to be_a "#{source.class.to_s}Member".constantize
+ expect(member).to be_a "#{source.class}Member".constantize
expect(member.requested_at).to be_present
end
end