Merge branch 'rs-string-conversion-in-interpolation' into 'master'

Enable Lint/StringConversionInInterpolation cop and autocorrect offenses



See merge request !6654
This commit is contained in:
Rémy Coutable 2016-10-03 15:36:09 +00:00
commit a1aea3266e
11 changed files with 13 additions and 14 deletions

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -80,7 +80,7 @@ class CommitRange
end
def inspect
%(#<#{self.class}:#{object_id} #{to_s}>)
%(#<#{self.class}:#{object_id} #{self}>)
end
def to_s

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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]

View file

@ -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

View file

@ -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