Commit 891cb10f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'frozen-string-enable-app-presenters' into 'master'

Enable frozen string in presenters and policies

See merge request gitlab-org/gitlab-ce!20819
parents 911d45b7 d5bf57a6
# frozen_string_literal: true
class ApplicationSetting class ApplicationSetting
class TermPolicy < BasePolicy class TermPolicy < BasePolicy
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
require_dependency 'declarative_policy' require_dependency 'declarative_policy'
class BasePolicy < DeclarativePolicy::Base class BasePolicy < DeclarativePolicy::Base
......
# frozen_string_literal: true
module Ci module Ci
class BuildPolicy < CommitStatusPolicy class BuildPolicy < CommitStatusPolicy
condition(:protected_ref) do condition(:protected_ref) do
......
# frozen_string_literal: true
module Ci module Ci
class PipelinePolicy < BasePolicy class PipelinePolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
module Ci module Ci
class PipelineSchedulePolicy < PipelinePolicy class PipelineSchedulePolicy < PipelinePolicy
alias_method :pipeline_schedule, :subject alias_method :pipeline_schedule, :subject
......
# frozen_string_literal: true
module Ci module Ci
class RunnerPolicy < BasePolicy class RunnerPolicy < BasePolicy
with_options scope: :subject, score: 0 with_options scope: :subject, score: 0
......
# frozen_string_literal: true
module Ci module Ci
class TriggerPolicy < BasePolicy class TriggerPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
module Clusters module Clusters
class ClusterPolicy < BasePolicy class ClusterPolicy < BasePolicy
alias_method :cluster, :subject alias_method :cluster, :subject
......
# frozen_string_literal: true
class CommitStatusPolicy < BasePolicy class CommitStatusPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
class DeployKeyPolicy < BasePolicy class DeployKeyPolicy < BasePolicy
with_options scope: :subject, score: 0 with_options scope: :subject, score: 0
condition(:private_deploy_key) { @subject.private? } condition(:private_deploy_key) { @subject.private? }
......
# frozen_string_literal: true
class DeployTokenPolicy < BasePolicy class DeployTokenPolicy < BasePolicy
with_options scope: :subject, score: 0 with_options scope: :subject, score: 0
condition(:maintainer) { @subject.project.team.maintainer?(@user) } condition(:maintainer) { @subject.project.team.maintainer?(@user) }
......
# frozen_string_literal: true
class DeploymentPolicy < BasePolicy class DeploymentPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
end end
# frozen_string_literal: true
class EnvironmentPolicy < BasePolicy class EnvironmentPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
class ExternalIssuePolicy < BasePolicy class ExternalIssuePolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
end end
# frozen_string_literal: true
class GlobalPolicy < BasePolicy class GlobalPolicy < BasePolicy
desc "User is blocked" desc "User is blocked"
with_options scope: :user, score: 0 with_options scope: :user, score: 0
......
# frozen_string_literal: true
class GroupLabelPolicy < BasePolicy class GroupLabelPolicy < BasePolicy
delegate { @subject.group } delegate { @subject.group }
end end
# frozen_string_literal: true
class GroupMemberPolicy < BasePolicy class GroupMemberPolicy < BasePolicy
delegate :group delegate :group
......
# frozen_string_literal: true
class GroupPolicy < BasePolicy class GroupPolicy < BasePolicy
desc "Group is public" desc "Group is public"
with_options scope: :subject, score: 0 with_options scope: :subject, score: 0
......
# frozen_string_literal: true
class IssuablePolicy < BasePolicy class IssuablePolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
class IssuePolicy < IssuablePolicy class IssuePolicy < IssuablePolicy
# This class duplicates the same check of Issue#readable_by? for performance reasons # This class duplicates the same check of Issue#readable_by? for performance reasons
# Make sure to sync this class checks with issue.rb to avoid security problems. # Make sure to sync this class checks with issue.rb to avoid security problems.
......
# frozen_string_literal: true
class MergeRequestPolicy < IssuablePolicy class MergeRequestPolicy < IssuablePolicy
end end
# frozen_string_literal: true
class NamespacePolicy < BasePolicy class NamespacePolicy < BasePolicy
rule { anonymous }.prevent_all rule { anonymous }.prevent_all
......
# frozen_string_literal: true
class NilPolicy < BasePolicy class NilPolicy < BasePolicy
rule { default }.prevent_all rule { default }.prevent_all
end end
# frozen_string_literal: true
class NotePolicy < BasePolicy class NotePolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) } delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }
......
# frozen_string_literal: true
class PersonalSnippetPolicy < BasePolicy class PersonalSnippetPolicy < BasePolicy
condition(:public_snippet, scope: :subject) { @subject.public? } condition(:public_snippet, scope: :subject) { @subject.public? }
condition(:is_author) { @user && @subject.author == @user } condition(:is_author) { @user && @subject.author == @user }
......
# frozen_string_literal: true
class ProjectLabelPolicy < BasePolicy class ProjectLabelPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
end end
# frozen_string_literal: true
class ProjectMemberPolicy < BasePolicy class ProjectMemberPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
class ProjectPolicy < BasePolicy class ProjectPolicy < BasePolicy
extend ClassMethods extend ClassMethods
......
# frozen_string_literal: true
class ProjectPolicy class ProjectPolicy
module ClassMethods module ClassMethods
def create_read_update_admin_destroy(name) def create_read_update_admin_destroy(name)
......
# frozen_string_literal: true
class ProjectSnippetPolicy < BasePolicy class ProjectSnippetPolicy < BasePolicy
delegate :project delegate :project
......
# frozen_string_literal: true
class ProtectedBranchPolicy < BasePolicy class ProtectedBranchPolicy < BasePolicy
delegate { @subject.project } delegate { @subject.project }
......
# frozen_string_literal: true
class UserPolicy < BasePolicy class UserPolicy < BasePolicy
desc "The current user is the user in question" desc "The current user is the user in question"
condition(:user_is_self, score: 0) { @subject == @user } condition(:user_is_self, score: 0) { @subject == @user }
......
# frozen_string_literal: true
module Ci module Ci
class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated
TIMEOUT_SOURCES = { TIMEOUT_SOURCES = {
......
# frozen_string_literal: true
module Ci module Ci
class BuildPresenter < CommitStatusPresenter class BuildPresenter < CommitStatusPresenter
def erased_by_user? def erased_by_user?
......
# frozen_string_literal: true
module Ci module Ci
class GroupVariablePresenter < Gitlab::View::Presenter::Delegated class GroupVariablePresenter < Gitlab::View::Presenter::Delegated
presents :variable presents :variable
......
# frozen_string_literal: true
module Ci module Ci
class PipelinePresenter < Gitlab::View::Presenter::Delegated class PipelinePresenter < Gitlab::View::Presenter::Delegated
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module Ci module Ci
class VariablePresenter < Gitlab::View::Presenter::Delegated class VariablePresenter < Gitlab::View::Presenter::Delegated
presents :variable presents :variable
......
# frozen_string_literal: true
module Clusters module Clusters
class ClusterPresenter < Gitlab::View::Presenter::Delegated class ClusterPresenter < Gitlab::View::Presenter::Delegated
presents :cluster presents :cluster
......
# frozen_string_literal: true
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
CALLOUT_FAILURE_MESSAGES = { CALLOUT_FAILURE_MESSAGES = {
unknown_failure: 'There is an unknown failure, please try again', unknown_failure: 'There is an unknown failure, please try again',
......
# frozen_string_literal: true
module ConversationalDevelopmentIndex module ConversationalDevelopmentIndex
class MetricPresenter < Gitlab::View::Presenter::Simple class MetricPresenter < Gitlab::View::Presenter::Simple
def cards def cards
......
# frozen_string_literal: true
class GenericCommitStatusPresenter < CommitStatusPresenter class GenericCommitStatusPresenter < CommitStatusPresenter
end end
# frozen_string_literal: true
class GroupMemberPresenter < MemberPresenter class GroupMemberPresenter < MemberPresenter
private private
......
# frozen_string_literal: true
class MemberPresenter < Gitlab::View::Presenter::Delegated class MemberPresenter < Gitlab::View::Presenter::Delegated
presents :member presents :member
......
# frozen_string_literal: true
class MembersPresenter < Gitlab::View::Presenter::Delegated class MembersPresenter < Gitlab::View::Presenter::Delegated
include Enumerable include Enumerable
......
# frozen_string_literal: true
class MergeRequestPresenter < Gitlab::View::Presenter::Delegated class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::UrlHelper include ActionView::Helpers::UrlHelper
include GitlabRoutingHelper include GitlabRoutingHelper
......
# frozen_string_literal: true
class ProjectMemberPresenter < MemberPresenter class ProjectMemberPresenter < MemberPresenter
private private
......
# frozen_string_literal: true
class ProjectPresenter < Gitlab::View::Presenter::Delegated class ProjectPresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
include ActionView::Helpers::UrlHelper include ActionView::Helpers::UrlHelper
......
# frozen_string_literal: true
module Projects module Projects
module Settings module Settings
class DeployKeysPresenter < Gitlab::View::Presenter::Simple class DeployKeysPresenter < Gitlab::View::Presenter::Simple
......
---
title: Enable frozen string in app/presenters and app/policies
merge_request: 20819
author: gfyoung
type: performance
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment