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 TermPolicy < BasePolicy
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
require_dependency 'declarative_policy'
class BasePolicy < DeclarativePolicy::Base
......
# frozen_string_literal: true
module Ci
class BuildPolicy < CommitStatusPolicy
condition(:protected_ref) do
......
# frozen_string_literal: true
module Ci
class PipelinePolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
module Ci
class PipelineSchedulePolicy < PipelinePolicy
alias_method :pipeline_schedule, :subject
......
# frozen_string_literal: true
module Ci
class RunnerPolicy < BasePolicy
with_options scope: :subject, score: 0
......
# frozen_string_literal: true
module Ci
class TriggerPolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
module Clusters
class ClusterPolicy < BasePolicy
alias_method :cluster, :subject
......
# frozen_string_literal: true
class CommitStatusPolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
class DeployKeyPolicy < BasePolicy
with_options scope: :subject, score: 0
condition(:private_deploy_key) { @subject.private? }
......
# frozen_string_literal: true
class DeployTokenPolicy < BasePolicy
with_options scope: :subject, score: 0
condition(:maintainer) { @subject.project.team.maintainer?(@user) }
......
# frozen_string_literal: true
class DeploymentPolicy < BasePolicy
delegate { @subject.project }
end
# frozen_string_literal: true
class EnvironmentPolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
class ExternalIssuePolicy < BasePolicy
delegate { @subject.project }
end
# frozen_string_literal: true
class GlobalPolicy < BasePolicy
desc "User is blocked"
with_options scope: :user, score: 0
......
# frozen_string_literal: true
class GroupLabelPolicy < BasePolicy
delegate { @subject.group }
end
# frozen_string_literal: true
class GroupMemberPolicy < BasePolicy
delegate :group
......
# frozen_string_literal: true
class GroupPolicy < BasePolicy
desc "Group is public"
with_options scope: :subject, score: 0
......
# frozen_string_literal: true
class IssuablePolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
class IssuePolicy < IssuablePolicy
# 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.
......
# frozen_string_literal: true
class MergeRequestPolicy < IssuablePolicy
end
# frozen_string_literal: true
class NamespacePolicy < BasePolicy
rule { anonymous }.prevent_all
......
# frozen_string_literal: true
class NilPolicy < BasePolicy
rule { default }.prevent_all
end
# frozen_string_literal: true
class NotePolicy < BasePolicy
delegate { @subject.project }
delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }
......
# frozen_string_literal: true
class PersonalSnippetPolicy < BasePolicy
condition(:public_snippet, scope: :subject) { @subject.public? }
condition(:is_author) { @user && @subject.author == @user }
......
# frozen_string_literal: true
class ProjectLabelPolicy < BasePolicy
delegate { @subject.project }
end
# frozen_string_literal: true
class ProjectMemberPolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
class ProjectPolicy < BasePolicy
extend ClassMethods
......
# frozen_string_literal: true
class ProjectPolicy
module ClassMethods
def create_read_update_admin_destroy(name)
......
# frozen_string_literal: true
class ProjectSnippetPolicy < BasePolicy
delegate :project
......
# frozen_string_literal: true
class ProtectedBranchPolicy < BasePolicy
delegate { @subject.project }
......
# frozen_string_literal: true
class UserPolicy < BasePolicy
desc "The current user is the user in question"
condition(:user_is_self, score: 0) { @subject == @user }
......
# frozen_string_literal: true
module Ci
class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated
TIMEOUT_SOURCES = {
......
# frozen_string_literal: true
module Ci
class BuildPresenter < CommitStatusPresenter
def erased_by_user?
......
# frozen_string_literal: true
module Ci
class GroupVariablePresenter < Gitlab::View::Presenter::Delegated
presents :variable
......
# frozen_string_literal: true
module Ci
class PipelinePresenter < Gitlab::View::Presenter::Delegated
include Gitlab::Utils::StrongMemoize
......
# frozen_string_literal: true
module Ci
class VariablePresenter < Gitlab::View::Presenter::Delegated
presents :variable
......
# frozen_string_literal: true
module Clusters
class ClusterPresenter < Gitlab::View::Presenter::Delegated
presents :cluster
......
# frozen_string_literal: true
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
CALLOUT_FAILURE_MESSAGES = {
unknown_failure: 'There is an unknown failure, please try again',
......
# frozen_string_literal: true
module ConversationalDevelopmentIndex
class MetricPresenter < Gitlab::View::Presenter::Simple
def cards
......
# frozen_string_literal: true
class GenericCommitStatusPresenter < CommitStatusPresenter
end
# frozen_string_literal: true
class GroupMemberPresenter < MemberPresenter
private
......
# frozen_string_literal: true
class MemberPresenter < Gitlab::View::Presenter::Delegated
presents :member
......
# frozen_string_literal: true
class MembersPresenter < Gitlab::View::Presenter::Delegated
include Enumerable
......
# frozen_string_literal: true
class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::UrlHelper
include GitlabRoutingHelper
......
# frozen_string_literal: true
class ProjectMemberPresenter < MemberPresenter
private
......
# frozen_string_literal: true
class ProjectPresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::UrlHelper
......
# frozen_string_literal: true
module Projects
module Settings
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