Skip to content

Commit

Permalink
replace string concatenation with string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
bhushan354 committed Jan 3, 2025
1 parent 9c01b0b commit f45afa8
Show file tree
Hide file tree
Showing 26 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/controllers/analytics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def campaign_stats

def campaign_intersection
set_campaigns
campaign_name = @campaign_1.title + ' + ' + @campaign_2.title
campaign_name = "#{@campaign_1.title} + #{@campaign_2.title}"
campaign_1_course_ids = @campaign_1.courses.pluck(:id)
course_ids = @campaign_2.courses.where(id: campaign_1_course_ids).pluck(:id)

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def hot_javascript_path(filename)
def fingerprinted(path, filename, file_prefix = nil)
manifest_path = "#{Rails.root}/public/#{path}/manifest.json"
manifest = Oj.load(File.read(File.expand_path(manifest_path, __FILE__)))
"#{file_prefix}#{manifest[filename + '.js']}"
"#{file_prefix}#{manifest["#{filename}.js"]}"
end

def css_fingerprinted(filename)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/surveys_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def survey_preview_url(survey)
def question_answer_field_name(form, multiple)
name = "answer_group[#{form.object.question_id}][answer_text]"
if multiple
name + '[]'
"#{name}[]"
else
name
end
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/fall2017_cmu_experiment_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def email(course, instructor, email_code, reminder: false)
@course = course
@instructor = instructor
subject = 'Peer support for students in your Wikipedia assignment'
subject = 'Reminder: ' + subject if reminder
subject = "Reminder: #{subject}" if reminder
@opt_in_link = "https://#{ENV['dashboard_url']}/experiments/fall2017_cmu_experiment/"\
"#{@course.id}/#{email_code}/opt_in"
@opt_out_link = "https://#{ENV['dashboard_url']}/experiments/fall2017_cmu_experiment/"\
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/spring2018_cmu_experiment_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def email(course, instructor, email_code, reminder: false)
@course = course
@instructor = instructor
subject = 'Peer support for students in your Wikipedia assignment'
subject = 'Reminder: ' + subject if reminder
subject = "Reminder: #{subject}" if reminder
@opt_in_link = "https://#{ENV['dashboard_url']}/experiments/spring2018_cmu_experiment/"\
"#{@course.id}/#{email_code}/opt_in"
@opt_out_link = "https://#{ENV['dashboard_url']}/experiments/spring2018_cmu_experiment/"\
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/suspected_plagiarism_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def content_expert_email(alert, content_experts)
@article_url = @article&.url
@courses_user = @user.courses_users.last
@course = alert.course
@talk_page_new_section_url = @courses_user.talk_page_url + '?action=edit&section=new'
@talk_page_new_section_url = "#{@courses_user.talk_page_url}?action=edit&section=new"
@report_url = alert.url
mail(to: @course.instructors.pluck(:email),
cc: content_experts.pluck(:email),
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/ticket_notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def carbon_copy

def email_subject
subject_prefix = @course ? "#{@course.title}: " : ''
subject_prefix + 'Response to your help request'
"#{subject_prefix}Response to your help request"
end
end
2 changes: 1 addition & 1 deletion app/models/wiki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def domain
end

def base_url
'https://' + domain
"https://#{domain}"
end

def api_url
Expand Down
2 changes: 1 addition & 1 deletion app/services/add_sandbox_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def replace_default_with_sandbox_template

def add_sandbox_template
sandbox_summary = "adding #{@sandbox_template}"
new_line_template = @sandbox_template + "\n"
new_line_template = "#{@sandbox_template}\n"
@wiki_editor.add_to_page_top(@sandbox, @current_user, new_line_template, sandbox_summary)
end
end
2 changes: 1 addition & 1 deletion app/services/copy_course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def retrieve_users_data
end

def retrieve_all_training_modules
dashboard_uri = URI.parse(@host + '/training_modules.json')
dashboard_uri = URI.parse("#{@host}/training_modules.json")
response = Net::HTTP.get_response(dashboard_uri)
return [] unless response.is_a?(Net::HTTPSuccess)

Expand Down
2 changes: 1 addition & 1 deletion lib/analytics/tagged_courses_csv_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(tag)

def row(course) # rubocop:disable Metrics/AbcSize
row = [course.title]
row << (course.school + '/' + course.term)
row << ("#{course.school}/#{course.term}")
row << (@wiki_experts.find { |user| user.course_id == course.id }&.user&.username || 'N/A')
row << course.courses_users.where(role: 1).first&.real_name
row << course.recent_revision_count
Expand Down
2 changes: 1 addition & 1 deletion lib/default_campaign_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def current_term
month = Time.zone.today.month
# Determine if it's spring or fall semester based on academic calendar
semester = month.between?(1, 6) ? 'spring' : 'fall'
semester + '_' + year.to_s
"#{semester}_#{year}"
end
end
2 changes: 1 addition & 1 deletion lib/errors/rescue_development_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.included(base)
def self.rescue_from_rev_manifest(base)
base.rescue_from ActionView::Template::Error do |e|
raise e unless /rev-manifest.json/.match?(e.message)
explanation = '<p><code>' + String.new(e.message) + '</p></code>'
explanation = "<p><code>#{String.new(e.message)}</p></code>"
explanation << REV_MANIFEST_EXPLANATION

render plain: explanation,
Expand Down
2 changes: 1 addition & 1 deletion lib/pagepile_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def query_url

def pagepile
conn = Faraday.new(url: 'https://pagepile.toolforge.org')
conn.headers['User-Agent'] = ENV['dashboard_url'] + ' ' + Rails.env
conn.headers['User-Agent'] = "#{ENV['dashboard_url']} #{Rails.env}"
conn
end

Expand Down
2 changes: 1 addition & 1 deletion lib/petscan_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def query_url(psid)

def petscan
conn = Faraday.new(url: 'https://petscan.wmcloud.org')
conn.headers['User-Agent'] = ENV['dashboard_url'] + ' ' + Rails.env
conn.headers['User-Agent'] = "#{ENV['dashboard_url']} #{Rails.env}"
conn
end

Expand Down
2 changes: 1 addition & 1 deletion lib/training/wiki_training_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def translated_pages(base_page:, base_page_wikitext:)
return [] unless response
translations = []
response.data['messagegroupstats'].each do |language|
translations << (base_page + '/' + language['code']) if any_translations?(language)
translations << ("#{base_page}/#{language['code']}") if any_translations?(language)
end
return translations
end
Expand Down
4 changes: 2 additions & 2 deletions lib/wiki_course_edits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def add_template_to_user_page
return if initial_page_content.include?(template)

summary = @generator.enrollment_summary
new_line_template = template + "\n"
new_line_template = "#{template}\n"
@wiki_editor.add_to_page_top(user_page, @current_user, new_line_template, summary)
end

Expand All @@ -170,7 +170,7 @@ def add_template_to_user_talk_page
return if initial_page_content.include?(talk_template)

talk_summary = "adding {{#{template_name(@templates, 'user_talk')}}}"
new_line_template = talk_template + "\n"
new_line_template = "#{talk_template}\n"
@wiki_editor.add_to_page_top(talk_page, @current_user, new_line_template, talk_summary)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/wiki_course_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def translate_course_to_wikitext

def course_details_and_description
description = Wikitext.markdown_to_mediawiki(@course.description)
course_details + "\r" + description
"#{course_details}\r#{description}"
end

def course_details # rubocop:disable Metrics/MethodLength
Expand Down
2 changes: 1 addition & 1 deletion lib/wiki_edits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def oauth_credentials_valid?(current_user)
def notify_untrained(course, current_user)
untrained_users = course.students_with_overdue_training
training_link = "https://#{ENV['dashboard_url']}/training/students"
signed_text = I18n.t('wiki_edits.notify_overdue.message', link: training_link) + ' --~~~~'
signed_text = "#{I18n.t('wiki_edits.notify_overdue.message', link: training_link)} --~~~~"

message = { sectiontitle: I18n.t('wiki_edits.notify_overdue.header'),
text: signed_text,
Expand Down
4 changes: 2 additions & 2 deletions lib/wikitext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def self.assignments_to_wikilinks(assignments, home_wiki)
formatted_titles = assignments.map do |assignment|
format_assignment_title(assignment, home_wiki)
end
wikitext = '[[' + formatted_titles.join(']], [[') + ']]'
wikitext = "[[#{formatted_titles.join(']], [[')}]]"
wikitext
end

Expand All @@ -90,7 +90,7 @@ def self.format_assignment_title(assignment, home_wiki)
# If the project is different, a project prefix is also necessary.
project_prefix = project == home_wiki.project ? '' : ":#{project}"

(INTERWIKI_PREFIXES[project_prefix] || project_prefix) + language_prefix + ':' + title
"#{INTERWIKI_PREFIXES[project_prefix] || project_prefix}#{language_prefix}:#{title}"
end

# converts page title to a format suitable for on-wiki use
Expand Down
2 changes: 1 addition & 1 deletion spec/features/surveys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
expect(SurveyNotification.last.completed).to eq(true)

expect(Survey.last.to_csv).to match('username,') # beginning of header
expect(Survey.last.to_csv).to match(@instructor.username + ',') # beginning of response row
expect(Survey.last.to_csv).to match("#{@instructor.username},") # beginning of response row
end

it 'loads a question group preview' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/analytics/course_wikidata_csv_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

it 'generates csv data' do
expect(builder.generate_csv.lines.first).to start_with('course name,claims created')
expect(builder.generate_csv.lines.last).to start_with(course.title + ',2')
expect(builder.generate_csv.lines.last).to start_with("#{course.title},2")
expect(builder.generate_csv.lines.count).to eq 2
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/importers/user_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@

it 'removes invisible left-to-right and right-to-left marks from start or end of username' do
VCR.use_cassette 'user/new_from_username_with_ltr' do
username = 'Jashan1994' + 8206.chr + 8206.chr
username = "Jashan1994#{8206.chr}#{8206.chr}"
user = described_class.new_from_username(username)
expect(user.username).to eq('Jashan1994')

username = 8206.chr + 'Jashan1994'
username = "#{8206.chr}Jashan1994"
user = described_class.new_from_username(username)
expect(user.username).to eq('Jashan1994')

username = 8207.chr + 'Ofrit Assaf'
username = "#{8207.chr}Ofrit Assaf"
user = described_class.new_from_username(username)
expect(user.username).to eq('Ofrit Assaf')
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/wiki_assignment_output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
output = wiki_assignment_output
.build_assignment_page_content(assignment_tag,
initial_talk_page_content)
expected_output = assignment_tag + "\n\n" + initial_talk_page_content
expected_output = "#{assignment_tag}\n\n#{initial_talk_page_content}"
expect(output).to eq(expected_output)
end

Expand All @@ -209,7 +209,7 @@
output = wiki_assignment_output
.build_assignment_page_content(assignment_tag,
initial_talk_page_content)
expected_output = talk_page_templates + assignment_tag + "\n" + additional_talk_content
expected_output = "#{talk_page_templates}#{assignment_tag}\n#{additional_talk_content}"
expect(output).to eq(expected_output)
end

Expand Down Expand Up @@ -254,7 +254,7 @@
output = wiki_assignment_output
.build_assignment_page_content(assignment_tag,
initial_talk_page_content)
expected_output = initial_talk_page_content + assignment_tag + "\n"
expected_output = "#{initial_talk_page_content}#{assignment_tag}\n"
expect(output).to eq(expected_output)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/course_approval_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

it 'delivers an email with an enrollment link' do
allow(Features).to receive(:email?).and_return(true)
expect(mail.html_part.body).to include(escaped_slug(course.slug) + '?enroll=')
expect(mail.html_part.body).to include("#{escaped_slug(course.slug)}?enroll=")
expect(mail.to).to eq([instructor.email])
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/services/copy_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
let(:existent_prod_course_slug) do
'University_of_South_Carolina/Invertebrate_Zoology_(COPIED_FROM_Spring_2022)'
end
let(:course_url) { url_base + existent_prod_course_slug + '/course.json' }
let(:categories_url) { url_base + existent_prod_course_slug + '/categories.json' }
let(:users_url) { url_base + existent_prod_course_slug + '/users.json' }
let(:timeline_url) { url_base + existent_prod_course_slug + '/timeline.json' }
let(:training_modules_url) { @selected_dashboard + '/training_modules.json' }
let(:course_url) { "#{url_base}#{existent_prod_course_slug}/course.json" }
let(:categories_url) { "#{url_base}#{existent_prod_course_slug}/categories.json" }
let(:users_url) { "#{url_base}#{existent_prod_course_slug}/users.json" }
let(:timeline_url) { "#{url_base}#{existent_prod_course_slug}/timeline.json" }
let(:training_modules_url) { "#{@selected_dashboard}/training_modules.json" }
let(:course_response_body) do
'{
"course": {
Expand Down

0 comments on commit f45afa8

Please sign in to comment.