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

Enable frozen string in presenters and policies

See merge request gitlab-org/gitlab-ce!20819
This commit is contained in:
Rémy Coutable 2018-07-25 08:44:18 +00:00
commit 891cb10fc9
49 changed files with 101 additions and 0 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationSetting
class TermPolicy < BasePolicy
include Gitlab::Utils::StrongMemoize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'declarative_policy'
class BasePolicy < DeclarativePolicy::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class BuildPolicy < CommitStatusPolicy
condition(:protected_ref) do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class PipelinePolicy < BasePolicy
delegate { @subject.project }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class PipelineSchedulePolicy < PipelinePolicy
alias_method :pipeline_schedule, :subject

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class RunnerPolicy < BasePolicy
with_options scope: :subject, score: 0

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class TriggerPolicy < BasePolicy
delegate { @subject.project }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Clusters
class ClusterPolicy < BasePolicy
alias_method :cluster, :subject

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CommitStatusPolicy < BasePolicy
delegate { @subject.project }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeployKeyPolicy < BasePolicy
with_options scope: :subject, score: 0
condition(:private_deploy_key) { @subject.private? }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeployTokenPolicy < BasePolicy
with_options scope: :subject, score: 0
condition(:maintainer) { @subject.project.team.maintainer?(@user) }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class DeploymentPolicy < BasePolicy
delegate { @subject.project }
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class EnvironmentPolicy < BasePolicy
delegate { @subject.project }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ExternalIssuePolicy < BasePolicy
delegate { @subject.project }
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GlobalPolicy < BasePolicy
desc "User is blocked"
with_options scope: :user, score: 0

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupLabelPolicy < BasePolicy
delegate { @subject.group }
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupMemberPolicy < BasePolicy
delegate :group

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupPolicy < BasePolicy
desc "Group is public"
with_options scope: :subject, score: 0

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class IssuablePolicy < BasePolicy
delegate { @subject.project }

View file

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

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
class MergeRequestPolicy < IssuablePolicy
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NamespacePolicy < BasePolicy
rule { anonymous }.prevent_all

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NilPolicy < BasePolicy
rule { default }.prevent_all
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class NotePolicy < BasePolicy
delegate { @subject.project }
delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PersonalSnippetPolicy < BasePolicy
condition(:public_snippet, scope: :subject) { @subject.public? }
condition(:is_author) { @user && @subject.author == @user }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectLabelPolicy < BasePolicy
delegate { @subject.project }
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectMemberPolicy < BasePolicy
delegate { @subject.project }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectPolicy < BasePolicy
extend ClassMethods

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectPolicy
module ClassMethods
def create_read_update_admin_destroy(name)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectSnippetPolicy < BasePolicy
delegate :project

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProtectedBranchPolicy < BasePolicy
delegate { @subject.project }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserPolicy < BasePolicy
desc "The current user is the user in question"
condition(:user_is_self, score: 0) { @subject == @user }

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated
TIMEOUT_SOURCES = {

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class BuildPresenter < CommitStatusPresenter
def erased_by_user?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class GroupVariablePresenter < Gitlab::View::Presenter::Delegated
presents :variable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class PipelinePresenter < Gitlab::View::Presenter::Delegated
include Gitlab::Utils::StrongMemoize

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Ci
class VariablePresenter < Gitlab::View::Presenter::Delegated
presents :variable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Clusters
class ClusterPresenter < Gitlab::View::Presenter::Delegated
presents :cluster

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
CALLOUT_FAILURE_MESSAGES = {
unknown_failure: 'There is an unknown failure, please try again',

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ConversationalDevelopmentIndex
class MetricPresenter < Gitlab::View::Presenter::Simple
def cards

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
class GenericCommitStatusPresenter < CommitStatusPresenter
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GroupMemberPresenter < MemberPresenter
private

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MemberPresenter < Gitlab::View::Presenter::Delegated
presents :member

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MembersPresenter < Gitlab::View::Presenter::Delegated
include Enumerable

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::UrlHelper
include GitlabRoutingHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectMemberPresenter < MemberPresenter
private

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ProjectPresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::UrlHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Projects
module Settings
class DeployKeysPresenter < Gitlab::View::Presenter::Simple

View file

@ -0,0 +1,5 @@
---
title: Enable frozen string in app/presenters and app/policies
merge_request: 20819
author: gfyoung
type: performance