From fe9a77cd6729d3a5c32fc0a8c7492c9da941cdc7 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 15 Nov 2022 21:41:05 +0100 Subject: [PATCH] Fix lints --- app/controllers/user_controller.rb | 18 +++++++++--------- ...1115194933_add_privacy_hide_social_graph.rb | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 119b056e..f71e41dc 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class UserController < ApplicationController before_action :set_user before_action :hidden_social_graph_redirect, only: %i[followers followings] @@ -22,7 +24,7 @@ class UserController < ApplicationController end def followers - @title = 'Followers' + @title = "Followers" @relationships = @user.cursored_follower_relationships(last_id: params[:last_id]) @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? @@ -35,9 +37,8 @@ class UserController < ApplicationController end end - # rubocop:disable Metrics/AbcSize def followings - @title = 'Following' + @title = "Following" @relationships = @user.cursored_following_relationships(last_id: params[:last_id]) @relationships_last_id = @relationships.map(&:id).min @more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero? @@ -49,10 +50,9 @@ class UserController < ApplicationController format.turbo_stream { render "show_follow" } end end - # rubocop:enable Metrics/AbcSize def questions - @title = 'Questions' + @title = "Questions" @questions = @user.cursored_questions(author_is_anonymous: false, direct: belongs_to_current_user? || moderation_view?, last_id: params[:last_id]) @questions_last_id = @questions.map(&:id).min @more_data_available = !@user.cursored_questions(author_is_anonymous: false, direct: belongs_to_current_user? || moderation_view?, last_id: @questions_last_id, size: 1).count.zero? @@ -66,13 +66,13 @@ class UserController < ApplicationController private def set_user - @user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first! + @user = User.where("LOWER(screen_name) = ?", params[:username].downcase).includes(:profile).first! end def hidden_social_graph_redirect - unless belongs_to_current_user? || !@user.privacy_hide_social_graph - redirect_to user_path(@user) - end + return if belongs_to_current_user? || !@user.privacy_hide_social_graph + + redirect_to user_path(@user) end def belongs_to_current_user? = @user == current_user diff --git a/db/migrate/20221115194933_add_privacy_hide_social_graph.rb b/db/migrate/20221115194933_add_privacy_hide_social_graph.rb index dde49d97..8685dafb 100644 --- a/db/migrate/20221115194933_add_privacy_hide_social_graph.rb +++ b/db/migrate/20221115194933_add_privacy_hide_social_graph.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AddPrivacyHideSocialGraph < ActiveRecord::Migration[6.1] def up add_column :users, :privacy_hide_social_graph, :boolean, default: false