Commit 73322a0e authored by gfyoung's avatar gfyoung 🤔

Enable frozen string in app/controllers/**/*.rb

Enables frozen string for the following:

* app/controllers/*.rb
* app/controllers/admin/**/*.rb
* app/controllers/boards/**/*.rb
* app/controllers/ci/**/*.rb
* app/controllers/concerns/**/*.rb

Partially addresses #47424.
parent 2dac058d
Pipeline #30634163 failed with stages
in 112 minutes and 33 seconds
# frozen_string_literal: true
class AbuseReportsController < ApplicationController
before_action :set_user, only: [:new]
......
# frozen_string_literal: true
class Admin::AbuseReportsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
......
# frozen_string_literal: true
class Admin::AppearancesController < Admin::ApplicationController
before_action :set_appearance, except: :create
......
# frozen_string_literal: true
# Provides a base class for Admin controllers to subclass
#
# Automatically sets the layout and ensures an administrator is logged in
......
# frozen_string_literal: true
class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :set_application_setting
......
# frozen_string_literal: true
class Admin::ApplicationsController < Admin::ApplicationController
include OauthApplications
......
# frozen_string_literal: true
class Admin::BackgroundJobsController < Admin::ApplicationController
def show
ps_output, _ = Gitlab::Popen.popen(%W(ps ww -U #{Gitlab.config.gitlab.user} -o pid,pcpu,pmem,stat,start,command))
......
# frozen_string_literal: true
class Admin::BroadcastMessagesController < Admin::ApplicationController
include BroadcastMessagesHelper
......
# frozen_string_literal: true
class Admin::DashboardController < Admin::ApplicationController
include CountHelper
......
# frozen_string_literal: true
class Admin::DeployKeysController < Admin::ApplicationController
before_action :deploy_keys, only: [:index]
before_action :deploy_key, only: [:destroy, :edit, :update]
......
# frozen_string_literal: true
class Admin::GitalyServersController < Admin::ApplicationController
def index
@gitaly_servers = Gitaly::Server.all
......
# frozen_string_literal: true
class Admin::GroupsController < Admin::ApplicationController
include MembersPresentation
......
# frozen_string_literal: true
class Admin::HealthCheckController < Admin::ApplicationController
def show
@errors = HealthCheck::Utils.process_checks(['standard'])
......
# frozen_string_literal: true
class Admin::HookLogsController < Admin::ApplicationController
include HooksExecution
......
# frozen_string_literal: true
class Admin::HooksController < Admin::ApplicationController
include HooksExecution
......
# frozen_string_literal: true
class Admin::IdentitiesController < Admin::ApplicationController
before_action :user
before_action :identity, except: [:index, :new, :create]
......
# frozen_string_literal: true
class Admin::ImpersonationTokensController < Admin::ApplicationController
before_action :user
......
# frozen_string_literal: true
class Admin::ImpersonationsController < Admin::ApplicationController
skip_before_action :authenticate_admin!
before_action :authenticate_impersonator!
......
# frozen_string_literal: true
class Admin::JobsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
......
# frozen_string_literal: true
class Admin::KeysController < Admin::ApplicationController
before_action :user, only: [:show, :destroy]
......
# frozen_string_literal: true
class Admin::LabelsController < Admin::ApplicationController
before_action :set_label, only: [:show, :edit, :update, :destroy]
......
# frozen_string_literal: true
class Admin::LogsController < Admin::ApplicationController
before_action :loggers
......
# frozen_string_literal: true
class Admin::ProjectsController < Admin::ApplicationController
include MembersPresentation
......
# frozen_string_literal: true
class Admin::RequestsProfilesController < Admin::ApplicationController
def index
@profile_token = Gitlab::RequestProfiler.profile_token
......
# frozen_string_literal: true
class Admin::RunnerProjectsController < Admin::ApplicationController
before_action :project, only: [:create]
......
# frozen_string_literal: true
class Admin::RunnersController < Admin::ApplicationController
before_action :runner, except: :index
......
# frozen_string_literal: true
class Admin::SpamLogsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
......
# frozen_string_literal: true
class Admin::SystemInfoController < Admin::ApplicationController
EXCLUDED_MOUNT_OPTIONS = [
'nobrowse',
......
# frozen_string_literal: true
class Admin::UsersController < Admin::ApplicationController
before_action :user, except: [:index, :new, :create]
......
# frozen_string_literal: true
require 'gon'
require 'fogbugz'
......
# frozen_string_literal: true
class AutocompleteController < ApplicationController
skip_before_action :authenticate_user!, only: [:users, :award_emojis]
......
# frozen_string_literal: true
module Boards
class ApplicationController < ::ApplicationController
respond_to :json
......
# frozen_string_literal: true
module Boards
class IssuesController < Boards::ApplicationController
include BoardsResponses
......
# frozen_string_literal: true
module Boards
class ListsController < Boards::ApplicationController
include BoardsResponses
......
# frozen_string_literal: true
module Ci
class LintsController < ::ApplicationController
before_action :authenticate_user!
......
# frozen_string_literal: true
module AcceptsPendingInvitations
extend ActiveSupport::Concern
......
# frozen_string_literal: true
# == AuthenticatesWithTwoFactor
#
# Controller concern to handle two-factor authentication
......
# frozen_string_literal: true
module BoardsResponses
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module ChecksCollaboration
def can_collaborate_with_project?(project, ref: nil)
return true if can?(current_user, :push_code, project)
......
# frozen_string_literal: true
module ContinueParams
include InternalRedirect
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module ControllerWithCrossProjectAccessCheck
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module CreatesCommit
extend ActiveSupport::Concern
include Gitlab::Utils::StrongMemoize
......@@ -65,7 +67,7 @@ module CreatesCommit
flash[:notice] = nil
else
target = different_project? ? "project" : "branch"
flash[:notice] << " You can now submit a merge request to get this change into the original #{target}."
flash[:notice] = flash[:notice] + " You can now submit a merge request to get this change into the original #{target}."
end
end
end
......
# frozen_string_literal: true
module CycleAnalyticsParams
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module DiffForPath
extend ActiveSupport::Concern
......
# frozen_string_literal: true
# == EnforcesTwoFactorAuthentication
#
# Controller concern to enforce two-factor authentication requirements
......
# frozen_string_literal: true
module GroupTree
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop: disable CodeReuse/ActiveRecord
......
# frozen_string_literal: true
module HooksExecution
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module InternalRedirect
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module IssuableActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module IssuableCollections
extend ActiveSupport::Concern
include CookiesHelper
......
# frozen_string_literal: true
module IssuesAction
extend ActiveSupport::Concern
include IssuableCollections
......
# frozen_string_literal: true
module IssuesCalendar
extend ActiveSupport::Concern
......
# frozen_string_literal: true
# This concern assumes:
# - a `#project` accessor
# - a `#user` accessor
......
# frozen_string_literal: true
module MembersPresentation
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module MembershipActions
include MembersPresentation
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module MergeRequestsAction
extend ActiveSupport::Concern
include IssuableCollections
......
# frozen_string_literal: true
module MilestoneActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module NotesActions
include RendersNotes
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module OauthApplications
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module ParamsBackwardCompatibility
private
......
# frozen_string_literal: true
module PreviewMarkdown
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module RendersBlob
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module RendersCommits
def limited_commits(commits)
if commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
......
# frozen_string_literal: true
module RendersMemberAccess
def prepare_groups_for_rendering(groups)
preload_max_member_access_for_collection(Group, groups)
......
# frozen_string_literal: true
module RendersNotes
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def prepare_notes_for_rendering(notes, noteable = nil)
......
# frozen_string_literal: true
module RepositorySettingsRedirect
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module RequiresWhitelistedMonitoringClient
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module RoutableActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module SendFileUpload
def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, disposition: 'attachment')
if attachment
......
# frozen_string_literal: true
module ServiceParams
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module SnippetsActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module SpammableActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module TodosActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module ToggleAwardEmoji
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module ToggleSubscriptionAction
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module UploadsActions
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module WithPerformanceBar
extend ActiveSupport::Concern
......
# frozen_string_literal: true
module WorkhorseRequest
extend ActiveSupport::Concern
......
# frozen_string_literal: true
class ConfirmationsController < Devise::ConfirmationsController
include AcceptsPendingInvitations
......@@ -20,7 +22,7 @@ class ConfirmationsController < Devise::ConfirmationsController
after_sign_in(resource)
else
Gitlab::AppLogger.info("Email Confirmed: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip}")
flash[:notice] += " Please sign in."
flash[:notice] = flash[:notice] + " Please sign in."
new_session_path(:user, anchor: 'login-pane')
end
end
......
# frozen_string_literal: true
class DashboardController < Dashboard::ApplicationController
include IssuesAction
include MergeRequestsAction
......
# frozen_string_literal: true
class GraphqlController < ApplicationController
# Unauthenticated users have access to the API for public data
skip_before_action :authenticate_user!
......
# frozen_string_literal: true
class GroupsController < Groups::ApplicationController
include API::Helpers::RelatedResourcesHelpers
include IssuesAction
......
# frozen_string_literal: true
class HealthCheckController < HealthCheck::HealthCheckController
include RequiresWhitelistedMonitoringClient
end
# frozen_string_literal: true
class HealthController < ActionController::Base
protect_from_forgery with: :exception, except: :storage_check, prepend: true
include RequiresWhitelistedMonitoringClient
......
# frozen_string_literal: true
class HelpController < ApplicationController
skip_before_action :authenticate_user!
......
# frozen_string_literal: true
class IdeController < ApplicationController
layout 'fullscreen'
......
# frozen_string_literal: true
class InvitesController < ApplicationController
before_action :member
skip_before_action :authenticate_user!, only: :decline
......@@ -50,9 +52,9 @@ class InvitesController < ApplicationController
def authenticate_user!
return if current_user
notice = "To accept this invitation, sign in"
notice << " or create an account" if Gitlab::CurrentSettings.allow_signup?
notice << "."
notice = ["To accept this invitation, sign in"]
notice << "or create an account" if Gitlab::CurrentSettings.allow_signup?
notice = notice.join(' ') + "."
store_location_for :user, request.fullpath
redirect_to new_user_session_path, notice: notice
......
# frozen_string_literal: true
class JwtController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token
......
# frozen_string_literal: true
class KodingController < ApplicationController
before_action :check_integration!
layout 'koding'
......
# frozen_string_literal: true
class MetricsController < ActionController::Base
include RequiresWhitelistedMonitoringClient
......
# frozen_string_literal: true
class NotificationSettingsController < ApplicationController
before_action :authenticate_user!
......
# frozen_string_literal: true
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
include AuthenticatesWithTwoFactor
include Devise::Controllers::Rememberable
......@@ -135,14 +137,13 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def handle_signup_error
label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider'])
message = "Signing in using your #{label} account without a pre-existing GitLab account is not allowed."
message = ["Signing in using your #{label} account without a pre-existing GitLab account is not allowed."]
if Gitlab::CurrentSettings.allow_signup?
message << " Create a GitLab account first, and then connect it to your #{label} account."
message << "Create a GitLab account first, and then connect it to your #{label} account."
end
flash[:notice] = message
flash[:notice] = message.join(' ')
redirect_to new_user_session_path
end
......
# frozen_string_literal: true
class PasswordsController < Devise::PasswordsController
skip_before_action :require_no_authentication, only: [:edit, :update]
......
# frozen_string_literal: true
class ProfilesController < Profiles::ApplicationController
include ActionView::Helpers::SanitizeHelper
......
# frozen_string_literal: true
class ProjectsController < Projects::ApplicationController
include API::Helpers::RelatedResourcesHelpers
include IssuableCollections
......
# frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController
include Recaptcha::Verify
include AcceptsPendingInvitations
......