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.
This commit is contained in:
gfyoung 2018-09-13 22:42:05 -07:00
parent 2dac058de2
commit 73322a0e55
105 changed files with 221 additions and 9 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AbuseReportsController < ApplicationController
before_action :set_user, only: [:new]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::AbuseReportsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::AppearancesController < Admin::ApplicationController
before_action :set_appearance, except: :create

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Provides a base class for Admin controllers to subclass
#
# Automatically sets the layout and ensures an administrator is logged in

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :set_application_setting

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::ApplicationsController < Admin::ApplicationController
include OauthApplications

View file

@ -1,3 +1,5 @@
# 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))

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::BroadcastMessagesController < Admin::ApplicationController
include BroadcastMessagesHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::DashboardController < Admin::ApplicationController
include CountHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::DeployKeysController < Admin::ApplicationController
before_action :deploy_keys, only: [:index]
before_action :deploy_key, only: [:destroy, :edit, :update]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::GitalyServersController < Admin::ApplicationController
def index
@gitaly_servers = Gitaly::Server.all

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::GroupsController < Admin::ApplicationController
include MembersPresentation

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::HealthCheckController < Admin::ApplicationController
def show
@errors = HealthCheck::Utils.process_checks(['standard'])

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::HookLogsController < Admin::ApplicationController
include HooksExecution

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::HooksController < Admin::ApplicationController
include HooksExecution

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::IdentitiesController < Admin::ApplicationController
before_action :user
before_action :identity, except: [:index, :new, :create]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::ImpersonationTokensController < Admin::ApplicationController
before_action :user

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::ImpersonationsController < Admin::ApplicationController
skip_before_action :authenticate_admin!
before_action :authenticate_impersonator!

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::JobsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::KeysController < Admin::ApplicationController
before_action :user, only: [:show, :destroy]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::LabelsController < Admin::ApplicationController
before_action :set_label, only: [:show, :edit, :update, :destroy]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::LogsController < Admin::ApplicationController
before_action :loggers

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::ProjectsController < Admin::ApplicationController
include MembersPresentation

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::RequestsProfilesController < Admin::ApplicationController
def index
@profile_token = Gitlab::RequestProfiler.profile_token

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::RunnerProjectsController < Admin::ApplicationController
before_action :project, only: [:create]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::RunnersController < Admin::ApplicationController
before_action :runner, except: :index

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::SpamLogsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::SystemInfoController < Admin::ApplicationController
EXCLUDED_MOUNT_OPTIONS = [
'nobrowse',

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Admin::UsersController < Admin::ApplicationController
before_action :user, except: [:index, :new, :create]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'gon'
require 'fogbugz'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AutocompleteController < ApplicationController
skip_before_action :authenticate_user!, only: [:users, :award_emojis]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Boards
class ApplicationController < ::ApplicationController
respond_to :json

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Boards
class IssuesController < Boards::ApplicationController
include BoardsResponses

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Boards
class ListsController < Boards::ApplicationController
include BoardsResponses

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class LintsController < ::ApplicationController
before_action :authenticate_user!

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module AcceptsPendingInvitations
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# == AuthenticatesWithTwoFactor
#
# Controller concern to handle two-factor authentication

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module BoardsResponses
include Gitlab::Utils::StrongMemoize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ChecksCollaboration
def can_collaborate_with_project?(project, ref: nil)
return true if can?(current_user, :push_code, project)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ContinueParams
include InternalRedirect
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ControllerWithCrossProjectAccessCheck
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module CycleAnalyticsParams
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DiffForPath
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# == EnforcesTwoFactorAuthentication
#
# Controller concern to enforce two-factor authentication requirements

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module GroupTree
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop: disable CodeReuse/ActiveRecord

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module HooksExecution
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module InternalRedirect
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module IssuableActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module IssuableCollections
extend ActiveSupport::Concern
include CookiesHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module IssuesAction
extend ActiveSupport::Concern
include IssuableCollections

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module IssuesCalendar
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This concern assumes:
# - a `#project` accessor
# - a `#user` accessor

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MembersPresentation
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MembershipActions
include MembersPresentation
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MergeRequestsAction
extend ActiveSupport::Concern
include IssuableCollections

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MilestoneActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module NotesActions
include RendersNotes
include Gitlab::Utils::StrongMemoize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module OauthApplications
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ParamsBackwardCompatibility
private

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PreviewMarkdown
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RendersBlob
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RendersCommits
def limited_commits(commits)
if commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RendersMemberAccess
def prepare_groups_for_rendering(groups)
preload_max_member_access_for_collection(Group, groups)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RendersNotes
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def prepare_notes_for_rendering(notes, noteable = nil)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RepositorySettingsRedirect
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RequiresWhitelistedMonitoringClient
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RoutableActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module SendFileUpload
def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, disposition: 'attachment')
if attachment

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ServiceParams
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module SnippetsActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module SpammableActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module TodosActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ToggleAwardEmoji
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ToggleSubscriptionAction
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module UploadsActions
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module WithPerformanceBar
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module WorkhorseRequest
extend ActiveSupport::Concern

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DashboardController < Dashboard::ApplicationController
include IssuesAction
include MergeRequestsAction

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GraphqlController < ApplicationController
# Unauthenticated users have access to the API for public data
skip_before_action :authenticate_user!

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupsController < Groups::ApplicationController
include API::Helpers::RelatedResourcesHelpers
include IssuesAction

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class HealthCheckController < HealthCheck::HealthCheckController
include RequiresWhitelistedMonitoringClient
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class HealthController < ActionController::Base
protect_from_forgery with: :exception, except: :storage_check, prepend: true
include RequiresWhitelistedMonitoringClient

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class HelpController < ApplicationController
skip_before_action :authenticate_user!

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class IdeController < ApplicationController
layout 'fullscreen'

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class JwtController < ApplicationController
skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class KodingController < ApplicationController
before_action :check_integration!
layout 'koding'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MetricsController < ActionController::Base
include RequiresWhitelistedMonitoringClient

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NotificationSettingsController < ApplicationController
before_action :authenticate_user!

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PasswordsController < Devise::PasswordsController
skip_before_action :require_no_authentication, only: [:edit, :update]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProfilesController < Profiles::ApplicationController
include ActionView::Helpers::SanitizeHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectsController < Projects::ApplicationController
include API::Helpers::RelatedResourcesHelpers
include IssuableCollections

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController
include Recaptcha::Verify
include AcceptsPendingInvitations

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# RootController
#
# This controller exists solely to handle requests to `root_url`. When a user is

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SearchController < ApplicationController
include ControllerWithCrossProjectAccessCheck
include SearchHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SentNotificationsController < ApplicationController
skip_before_action :authenticate_user!

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SessionsController < Devise::SessionsController
include InternalRedirect
include AuthenticatesWithTwoFactor

Some files were not shown because too many files have changed in this diff Show more