From f05da14fb607c4b3906f0f83faea4b0f5694f043 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 9 Jan 2023 13:59:43 +0000 Subject: [PATCH] DEV: Do not include method definitions in serializer `attributes` These accidental inclusions are mostly no-ops (because the method name is also included as an explicit symbol). The mistakes were made more obvious because syntax_tree adjusted the indentation of these methods --- .../current_user_option_serializer.rb | 9 +++++---- app/serializers/topic_link_serializer.rb | 9 +++++---- .../topic_post_count_serializer.rb | 9 +++++---- app/serializers/user_option_serializer.rb | 10 +++++----- app/serializers/user_serializer.rb | 19 +++++++++---------- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/serializers/current_user_option_serializer.rb b/app/serializers/current_user_option_serializer.rb index f3223f79243..93c57a49049 100644 --- a/app/serializers/current_user_option_serializer.rb +++ b/app/serializers/current_user_option_serializer.rb @@ -17,10 +17,11 @@ class CurrentUserOptionSerializer < ApplicationSerializer :seen_popups, :should_be_redirected_to_top, :redirected_to_top, - :treat_as_new_topic_start_date, - def likes_notifications_disabled - object.likes_notifications_disabled? - end + :treat_as_new_topic_start_date + + def likes_notifications_disabled + object.likes_notifications_disabled? + end def include_redirected_to_top? object.redirected_to_top.present? diff --git a/app/serializers/topic_link_serializer.rb b/app/serializers/topic_link_serializer.rb index d4b814d2c98..a31feaa2a84 100644 --- a/app/serializers/topic_link_serializer.rb +++ b/app/serializers/topic_link_serializer.rb @@ -10,10 +10,11 @@ class TopicLinkSerializer < ApplicationSerializer :clicks, :user_id, :domain, - :root_domain, - def attachment - Discourse.store.has_been_uploaded?(object.url) - end + :root_domain + + def attachment + Discourse.store.has_been_uploaded?(object.url) + end def include_user_id? object.user_id.present? diff --git a/app/serializers/topic_post_count_serializer.rb b/app/serializers/topic_post_count_serializer.rb index 4495019bec5..5283910f168 100644 --- a/app/serializers/topic_post_count_serializer.rb +++ b/app/serializers/topic_post_count_serializer.rb @@ -9,10 +9,11 @@ class TopicPostCountSerializer < BasicUserSerializer :flair_bg_color, :admin, :moderator, - :trust_level, - def id - object[:user].id - end + :trust_level + + def id + object[:user].id + end def username object[:user].username diff --git a/app/serializers/user_option_serializer.rb b/app/serializers/user_option_serializer.rb index bd16f075364..d78dad82ebd 100644 --- a/app/serializers/user_option_serializer.rb +++ b/app/serializers/user_option_serializer.rb @@ -36,11 +36,11 @@ class UserOptionSerializer < ApplicationSerializer :skip_new_user_tips, :default_calendar, :oldest_search_log_date, - :seen_popups, - def auto_track_topics_after_msecs - object.auto_track_topics_after_msecs || - SiteSetting.default_other_auto_track_topics_after_msecs - end + :seen_popups + + def auto_track_topics_after_msecs + object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs + end def notification_level_when_replying object.notification_level_when_replying || diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index eeda5132f68..91c267d9ad6 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -67,16 +67,15 @@ class UserSerializer < UserCardSerializer :sidebar_list_destination, :display_sidebar_tags - untrusted_attributes :bio_raw, - :bio_cooked, - :profile_background_upload_url, - ### - ### ATTRIBUTES - ### - # - def user_notification_schedule - object.user_notification_schedule || UserNotificationSchedule::DEFAULT - end + untrusted_attributes :bio_raw, :bio_cooked, :profile_background_upload_url + + ### + ### ATTRIBUTES + ### + # + def user_notification_schedule + object.user_notification_schedule || UserNotificationSchedule::DEFAULT + end def mailing_list_posts_per_day val = Post.estimate_posts_per_day