Skip to content

Commit

Permalink
rubocop のルールStyle/HashSyntaxを一部に適用
Browse files Browse the repository at this point in the history
  • Loading branch information
kyokucho1989 committed Jan 31, 2024
1 parent 496a1c3 commit 1ed34a2
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 47 deletions.
10 changes: 0 additions & 10 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ Style/HashSyntax:
- 'app/controllers/api/session_controller.rb'
- 'app/controllers/api/watches/toggle_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/notifications/read_by_category_controller.rb'
- 'app/controllers/notifications_controller.rb'
- 'app/controllers/products_controller.rb'
- 'app/controllers/user_sessions_controller.rb'
- 'app/helpers/meta_tags_helper.rb'
- 'app/helpers/page_tab_helper.rb'
- 'app/helpers/reactions_helper.rb'
- 'app/jobs/ai_answer_create_job.rb'
- 'app/mailers/activity_mailer.rb'
- 'app/mailers/notification_mailer.rb'
- 'app/models/announcement_notifier.rb'
- 'app/models/answer.rb'
- 'app/models/answer_notifier.rb'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ def create
target = params[:target].presence&.to_sym
notifications = current_user.notifications.by_target(target).unreads
current_user.mark_all_as_read_and_delete_cache_of_unreads(target_notifications: notifications)
redirect_to notifications_path(target: target), notice: '既読にしました'
redirect_to notifications_path(target:), notice: '既読にしました'
end
end
2 changes: 1 addition & 1 deletion app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index

def show
link = @notification.read_attribute :link
@notifications = current_user.notifications.where(link: link)
@notifications = current_user.notifications.where(link:)
current_user.mark_all_as_read_and_delete_cache_of_unreads(target_notifications: @notifications)
redirect_to link
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def update
set_wip
update_published_at
if @product.update(product_params)
Newspaper.publish(:product_update, { product: @product, current_user: current_user })
Newspaper.publish(:product_update, { product: @product, current_user: })
Newspaper.publish(:product_save, { product: @product })
notice_another_mentor_assigned_as_checker
redirect_to Redirection.determin_url(self, @product), notice: notice_message(@product, :update)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/user_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def callback
auth = request.env['omniauth.auth']
github_id = auth[:uid]
if current_user.blank?
user = User.find_by(github_id: github_id)
user = User.find_by(github_id:)
if user.blank?
flash[:alert] = 'ログインに失敗しました。先にアカウントを作成後、GitHub連携を行ってください。'
redirect_to root_url
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/meta_tags_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def default_meta_tags

def welcome_meta_tags
default_meta_tags.deep_merge({
title: title,
title:,
description: '月額29,800円、全機能が使えるお試し期間付き。フィヨルドブートキャンプは現場の即戦力になるためのスキルとプログラミングの楽しさを伝える、現役エンジニアが考える理想のプログラミングスクールの実現に励んでいます。',
og: {
title: title || 'FJORD BOOT CAMP(フィヨルドブートキャンプ)',
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/page_tab_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def root_tab(resource)

def page_tab_member(path, tab_name, is_products_tab: false)
{
path: path,
path:,
target_name: tab_name.to_s,
display_name: display_tab_name(tab_name),
is_products_tab: is_products_tab
is_products_tab:
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/reactions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def reactions_attributes(reactionable)
end

def reaction_attributes(reactionable, kind, only_reacted: true)
attributes = { data: { reaction: { kind: kind } } }
attributes = { data: { reaction: { kind: } } }
attributes[:hidden] = reactionable.reaction_count_by(kind).zero? if only_reacted
reaction_id = reactionable.find_reaction_id_by(kind, current_user.login_name)

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/ai_answer_create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def perform(question_id:)
token = Rails.application.secrets[:open_ai][:access_token]
generator = AI::AnswerGenerator.new(open_ai_access_token: token)
ai_answer = generator.call("#{question.body}\n#{question.description}")
question.update(ai_answer: ai_answer)
question.update(ai_answer:)
end
end
44 changes: 22 additions & 22 deletions app/mailers/activity_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def comebacked(args = {})
kind: Notification.kinds[:comebacked]
)
subject = "[FBC] #{@sender.login_name}さんが休会から復帰しました。"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end

# required params: comment, message, receiver
Expand All @@ -48,7 +48,7 @@ def came_comment(args = {})
@user = @receiver
link = "/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}"
@link_url = notification_redirector_url(
link: link,
link:,
kind: Notification.kinds[:came_comment]
)
mail to: @user.email, subject: "[FBC] #{@message}"
Expand All @@ -67,7 +67,7 @@ def graduated(args = {})
kind: Notification.kinds[:graduated]
)
subject = "[FBC] #{@sender.login_name}さんが卒業しました。"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end

# required params: answer
Expand Down Expand Up @@ -95,7 +95,7 @@ def submitted(args = {})
kind: Notification.kinds[:submitted]
)
subject = "[FBC] #{@product.user.login_name}さんが#{@product.title}を提出しました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -112,7 +112,7 @@ def post_announcement(args = {})
kind: Notification.kinds[:announced]
)
subject = "[FBC] お知らせ「#{@announcement.title}」"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -129,7 +129,7 @@ def came_question(args = {})
kind: Notification.kinds[:came_question]
)
subject = "[FBC] #{@sender.login_name}さんから質問「#{@question.title}」が投稿されました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)

message.perform_deliveries = @user.mail_notification? && !@user.retired?
message
Expand All @@ -146,7 +146,7 @@ def retired(args = {})
kind: Notification.kinds[:retired]
)
subject = "[FBC] #{@sender.login_name}さんが退会しました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -163,7 +163,7 @@ def checked(args = {})
kind: Notification.kinds[:checked]
)
subject = "[FBC] #{@user.login_name}さんの#{@check.checkable.title}を確認しました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -180,7 +180,7 @@ def mentioned(args = {})
kind: Notification.kinds[:mentioned]
)
subject = "[FBC] #{@mentionable.where_mention}#{@mentionable.sender.login_name}さんからメンションがありました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -198,7 +198,7 @@ def create_page(args = {})
)
subject = "[FBC] #{@page.user.login_name}さんがDocsに#{@page.title}を投稿しました。"

message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -214,7 +214,7 @@ def moved_up_event_waiting_user(args = {})
kind: Notification.kinds[:moved_up_event_waiting_user]
)
subject = "[FBC] #{@event.title}で、補欠から参加に繰り上がりました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -232,7 +232,7 @@ def following_report(args = {})
)
subject = "[FBC] #{@report.user.login_name}さんが日報【 #{@report.title} 】を書きました!"

message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -253,7 +253,7 @@ def watching_notification(args = {})
@action = @watchable.instance_of?(Question) ? '回答' : 'コメント'
subject = "[FBC] #{@watchable.user.login_name}さんの#{@watchable.notification_title}#{@sender.login_name}さんが#{@action}しました。"

message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?
message
end
Expand All @@ -270,7 +270,7 @@ def assigned_as_checker(args = {})
)

subject = "[FBC] #{@product.user.login_name}さんの提出物#{@product.title}の担当になりました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -288,7 +288,7 @@ def hibernated(args = {})
)

subject = "[FBC] #{@sender.login_name}さんが休会しました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?
message
end
Expand All @@ -305,7 +305,7 @@ def first_report(args = {})
)

subject = "[FBC] #{@report.user.login_name}さんがはじめての日報を書きました!"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?
message
end
Expand All @@ -321,7 +321,7 @@ def consecutive_sad_report(args = {})
kind: Notification.kinds[:consecutive_sad_report]
)
subject = "[FBC] #{@report.user.login_name}さんが#{User::DEPRESSED_SIZE}回連続でsadアイコンの日報を提出しました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -338,7 +338,7 @@ def update_regular_event(args = {})
)

subject = "[FBC] 定期イベント【#{@regular_event.title}】が更新されました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -356,7 +356,7 @@ def no_correct_answer(args = {})
)

subject = "[FBC] #{@user.login_name}さんの質問【 #{@question.title} 】のベストアンサーがまだ選ばれていません。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -375,7 +375,7 @@ def signed_up(args = {})
)

subject = "[FBC] #{@sender.login_name}さん#{@sender_roles}が新しく入会しました!"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand All @@ -393,7 +393,7 @@ def chose_correct_answer(args = {})
)

subject = "[FBC] #{@answer.receiver.login_name}さんの質問【 #{@answer.question.title} 】で#{@answer.sender.login_name}さんの回答がベストアンサーに選ばれました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?
message
end
Expand All @@ -409,7 +409,7 @@ def product_update(args = {})
kind: Notification.kinds[:product_update]
)
subject = "[FBC] #{@product.user.login_name}さんが#{@product.title}を更新しました。"
message = mail to: @user.email, subject: subject
message = mail(to: @user.email, subject:)
message.perform_deliveries = @user.mail_notification? && !@user.retired?

message
Expand Down
12 changes: 6 additions & 6 deletions app/mailers/notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,39 @@ def mentioned
@user = @receiver
@notification = @user.notifications.find_by(link: @mentionable.path)
subject = "[FBC] #{@mentionable.where_mention}#{@mentionable.sender.login_name}さんからメンションがありました。"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end

# required params: check
def checked
@user = @check.receiver
link = "/#{@check.checkable_type.downcase.pluralize}/#{@check.checkable.id}"
@notification = @user.notifications.find_by(link: link)
@notification = @user.notifications.find_by(link:)
subject = "[FBC] #{@user.login_name}さんの#{@check.checkable.title}を確認しました。"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end

# required params: sender, receiver
def retired
@user = @receiver
@notification = @user.notifications.find_by(link: "/users/#{@sender.id}")
subject = "[FBC] #{@sender.login_name}さんが退会しました。"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end

# required params: report, receiver
def trainee_report
@user = @receiver
@notification = @user.notifications.find_by(link: "/reports/#{@report.id}")
subject = "[FBC] #{@report.user.login_name}さんが日報【 #{@report.title} 】を書きました!"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end

# required params: page, receiver
def create_page
@user = @receiver
@notification = @user.notifications.find_by(link: "/pages/#{@page.id}")
subject = "[FBC] #{@page.user.login_name}さんがDocsに#{@page.title}を投稿しました。"
mail to: @user.email, subject: subject
mail to: @user.email, subject:
end
end

0 comments on commit 1ed34a2

Please sign in to comment.