diff options
author | gfyoung <gfyoung17@gmail.com> | 2018-07-24 03:00:56 -0700 |
---|---|---|
committer | gfyoung <gfyoung17@gmail.com> | 2018-07-24 13:18:25 -0700 |
commit | d5bf57a6afe1ed9ba419a34b352020a44960b48d (patch) | |
tree | b2b77911cf0e18f4cb1b3c1cfac38c7000f69eb0 /app/policies | |
parent | f5b45519dba89296cbd6f350f5c29b655d5aef8d (diff) | |
download | gitlab-ce-d5bf57a6afe1ed9ba419a34b352020a44960b48d.tar.gz |
Enable frozen string in presenters and policiesrepo-forks/gitlab-ce-frozen-string-enable-app-presenters
Enable frozen string in:
* app/presenters
* app/policies
Partially addresses #47424.
Diffstat (limited to 'app/policies')
32 files changed, 64 insertions, 0 deletions
diff --git a/app/policies/application_setting/term_policy.rb b/app/policies/application_setting/term_policy.rb index f03bf748c76..17f00f33d35 100644 --- a/app/policies/application_setting/term_policy.rb +++ b/app/policies/application_setting/term_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ApplicationSetting class TermPolicy < BasePolicy include Gitlab::Utils::StrongMemoize diff --git a/app/policies/base_policy.rb b/app/policies/base_policy.rb index 603218aa6df..0d0f1c28bad 100644 --- a/app/policies/base_policy.rb +++ b/app/policies/base_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_dependency 'declarative_policy' class BasePolicy < DeclarativePolicy::Base diff --git a/app/policies/ci/build_policy.rb b/app/policies/ci/build_policy.rb index 75c7e529902..3858b29c82c 100644 --- a/app/policies/ci/build_policy.rb +++ b/app/policies/ci/build_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class BuildPolicy < CommitStatusPolicy condition(:protected_ref) do diff --git a/app/policies/ci/pipeline_policy.rb b/app/policies/ci/pipeline_policy.rb index b81329d0625..f9623587957 100644 --- a/app/policies/ci/pipeline_policy.rb +++ b/app/policies/ci/pipeline_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class PipelinePolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/ci/pipeline_schedule_policy.rb b/app/policies/ci/pipeline_schedule_policy.rb index ecba0488d3c..cf3f784f851 100644 --- a/app/policies/ci/pipeline_schedule_policy.rb +++ b/app/policies/ci/pipeline_schedule_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class PipelineSchedulePolicy < PipelinePolicy alias_method :pipeline_schedule, :subject diff --git a/app/policies/ci/runner_policy.rb b/app/policies/ci/runner_policy.rb index 895abe87d86..c44f22b6ad3 100644 --- a/app/policies/ci/runner_policy.rb +++ b/app/policies/ci/runner_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class RunnerPolicy < BasePolicy with_options scope: :subject, score: 0 diff --git a/app/policies/ci/trigger_policy.rb b/app/policies/ci/trigger_policy.rb index 5592ac30812..209db44539c 100644 --- a/app/policies/ci/trigger_policy.rb +++ b/app/policies/ci/trigger_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class TriggerPolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/clusters/cluster_policy.rb b/app/policies/clusters/cluster_policy.rb index b5b24491655..147943a3d6c 100644 --- a/app/policies/clusters/cluster_policy.rb +++ b/app/policies/clusters/cluster_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Clusters class ClusterPolicy < BasePolicy alias_method :cluster, :subject diff --git a/app/policies/commit_status_policy.rb b/app/policies/commit_status_policy.rb index 24b2a4cc7fd..eea2a24fb2d 100644 --- a/app/policies/commit_status_policy.rb +++ b/app/policies/commit_status_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CommitStatusPolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/deploy_key_policy.rb b/app/policies/deploy_key_policy.rb index 62a22a59be6..204c54a5b20 100644 --- a/app/policies/deploy_key_policy.rb +++ b/app/policies/deploy_key_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DeployKeyPolicy < BasePolicy with_options scope: :subject, score: 0 condition(:private_deploy_key) { @subject.private? } diff --git a/app/policies/deploy_token_policy.rb b/app/policies/deploy_token_policy.rb index d1b459cfc90..e648df3edfc 100644 --- a/app/policies/deploy_token_policy.rb +++ b/app/policies/deploy_token_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DeployTokenPolicy < BasePolicy with_options scope: :subject, score: 0 condition(:maintainer) { @subject.project.team.maintainer?(@user) } diff --git a/app/policies/deployment_policy.rb b/app/policies/deployment_policy.rb index 62b63b9f87b..56ac898b6ab 100644 --- a/app/policies/deployment_policy.rb +++ b/app/policies/deployment_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class DeploymentPolicy < BasePolicy delegate { @subject.project } end diff --git a/app/policies/environment_policy.rb b/app/policies/environment_policy.rb index 2d07311db72..d1243491f5a 100644 --- a/app/policies/environment_policy.rb +++ b/app/policies/environment_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class EnvironmentPolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/external_issue_policy.rb b/app/policies/external_issue_policy.rb index e031b38078c..1106536e075 100644 --- a/app/policies/external_issue_policy.rb +++ b/app/policies/external_issue_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ExternalIssuePolicy < BasePolicy delegate { @subject.project } end diff --git a/app/policies/global_policy.rb b/app/policies/global_policy.rb index 1cf5515d9d7..6e3827736b2 100644 --- a/app/policies/global_policy.rb +++ b/app/policies/global_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GlobalPolicy < BasePolicy desc "User is blocked" with_options scope: :user, score: 0 diff --git a/app/policies/group_label_policy.rb b/app/policies/group_label_policy.rb index e3dd3296699..9f3acd44b23 100644 --- a/app/policies/group_label_policy.rb +++ b/app/policies/group_label_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GroupLabelPolicy < BasePolicy delegate { @subject.group } end diff --git a/app/policies/group_member_policy.rb b/app/policies/group_member_policy.rb index 23dd0d7cd23..6f1afb87c85 100644 --- a/app/policies/group_member_policy.rb +++ b/app/policies/group_member_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GroupMemberPolicy < BasePolicy delegate :group diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb index dc339b71ec7..a8d7a05f509 100644 --- a/app/policies/group_policy.rb +++ b/app/policies/group_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GroupPolicy < BasePolicy desc "Group is public" with_options scope: :subject, score: 0 diff --git a/app/policies/issuable_policy.rb b/app/policies/issuable_policy.rb index b431d376e3d..198bb168d85 100644 --- a/app/policies/issuable_policy.rb +++ b/app/policies/issuable_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class IssuablePolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/issue_policy.rb b/app/policies/issue_policy.rb index 263c6e3039c..94b5f37c682 100644 --- a/app/policies/issue_policy.rb +++ b/app/policies/issue_policy.rb @@ -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. diff --git a/app/policies/merge_request_policy.rb b/app/policies/merge_request_policy.rb index c3fe857f8a2..a2950951d03 100644 --- a/app/policies/merge_request_policy.rb +++ b/app/policies/merge_request_policy.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class MergeRequestPolicy < IssuablePolicy end diff --git a/app/policies/namespace_policy.rb b/app/policies/namespace_policy.rb index eb01218eb0a..2babcb0a2d9 100644 --- a/app/policies/namespace_policy.rb +++ b/app/policies/namespace_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class NamespacePolicy < BasePolicy rule { anonymous }.prevent_all diff --git a/app/policies/nil_policy.rb b/app/policies/nil_policy.rb index 13f46ba60f0..fc969f8cd05 100644 --- a/app/policies/nil_policy.rb +++ b/app/policies/nil_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class NilPolicy < BasePolicy rule { default }.prevent_all end diff --git a/app/policies/note_policy.rb b/app/policies/note_policy.rb index 077a6761ee6..bbc2b48b856 100644 --- a/app/policies/note_policy.rb +++ b/app/policies/note_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class NotePolicy < BasePolicy delegate { @subject.project } delegate { @subject.noteable if DeclarativePolicy.has_policy?(@subject.noteable) } diff --git a/app/policies/personal_snippet_policy.rb b/app/policies/personal_snippet_policy.rb index c1a84727cfa..777f933cdcd 100644 --- a/app/policies/personal_snippet_policy.rb +++ b/app/policies/personal_snippet_policy.rb @@ -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 } diff --git a/app/policies/project_label_policy.rb b/app/policies/project_label_policy.rb index 2d0f021118b..5ce896ecaf2 100644 --- a/app/policies/project_label_policy.rb +++ b/app/policies/project_label_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectLabelPolicy < BasePolicy delegate { @subject.project } end diff --git a/app/policies/project_member_policy.rb b/app/policies/project_member_policy.rb index 9aedb620be9..f2f18406bd3 100644 --- a/app/policies/project_member_policy.rb +++ b/app/policies/project_member_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectMemberPolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index bc49092633f..f52a3bad77d 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectPolicy < BasePolicy extend ClassMethods diff --git a/app/policies/project_policy/class_methods.rb b/app/policies/project_policy/class_methods.rb index 60e5aba00ba..42d993406a9 100644 --- a/app/policies/project_policy/class_methods.rb +++ b/app/policies/project_policy/class_methods.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectPolicy module ClassMethods def create_read_update_admin_destroy(name) diff --git a/app/policies/project_snippet_policy.rb b/app/policies/project_snippet_policy.rb index dd270643bbf..288bf070cfc 100644 --- a/app/policies/project_snippet_policy.rb +++ b/app/policies/project_snippet_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectSnippetPolicy < BasePolicy delegate :project diff --git a/app/policies/protected_branch_policy.rb b/app/policies/protected_branch_policy.rb index 1a7faa4db40..0e83d2e5834 100644 --- a/app/policies/protected_branch_policy.rb +++ b/app/policies/protected_branch_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProtectedBranchPolicy < BasePolicy delegate { @subject.project } diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 8499e45e846..b5717029354 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -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 } |