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 | |
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.
49 files changed, 101 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 } diff --git a/app/presenters/ci/build_metadata_presenter.rb b/app/presenters/ci/build_metadata_presenter.rb index 5048f967ea8..015b1f67db7 100644 --- a/app/presenters/ci/build_metadata_presenter.rb +++ b/app/presenters/ci/build_metadata_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated TIMEOUT_SOURCES = { diff --git a/app/presenters/ci/build_presenter.rb b/app/presenters/ci/build_presenter.rb index e0aaa5cb736..5331cdf632b 100644 --- a/app/presenters/ci/build_presenter.rb +++ b/app/presenters/ci/build_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class BuildPresenter < CommitStatusPresenter def erased_by_user? diff --git a/app/presenters/ci/group_variable_presenter.rb b/app/presenters/ci/group_variable_presenter.rb index 98d68bc7a83..99011150c84 100644 --- a/app/presenters/ci/group_variable_presenter.rb +++ b/app/presenters/ci/group_variable_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class GroupVariablePresenter < Gitlab::View::Presenter::Delegated presents :variable diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index cc2bce9862d..93a38f92073 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class PipelinePresenter < Gitlab::View::Presenter::Delegated include Gitlab::Utils::StrongMemoize diff --git a/app/presenters/ci/variable_presenter.rb b/app/presenters/ci/variable_presenter.rb index 96159f88c59..f027f3aa560 100644 --- a/app/presenters/ci/variable_presenter.rb +++ b/app/presenters/ci/variable_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Ci class VariablePresenter < Gitlab::View::Presenter::Delegated presents :variable diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb index a424da5ab24..dfdd8e82f97 100644 --- a/app/presenters/clusters/cluster_presenter.rb +++ b/app/presenters/clusters/cluster_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Clusters class ClusterPresenter < Gitlab::View::Presenter::Delegated presents :cluster diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb index 9a7aaf4ef32..3a9088cfcb8 100644 --- a/app/presenters/commit_status_presenter.rb +++ b/app/presenters/commit_status_presenter.rb @@ -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', diff --git a/app/presenters/conversational_development_index/metric_presenter.rb b/app/presenters/conversational_development_index/metric_presenter.rb index bb65ba2646b..e0312c6f431 100644 --- a/app/presenters/conversational_development_index/metric_presenter.rb +++ b/app/presenters/conversational_development_index/metric_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ConversationalDevelopmentIndex class MetricPresenter < Gitlab::View::Presenter::Simple def cards diff --git a/app/presenters/generic_commit_status_presenter.rb b/app/presenters/generic_commit_status_presenter.rb index da09df29a37..a1dc72d5b98 100644 --- a/app/presenters/generic_commit_status_presenter.rb +++ b/app/presenters/generic_commit_status_presenter.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class GenericCommitStatusPresenter < CommitStatusPresenter end diff --git a/app/presenters/group_member_presenter.rb b/app/presenters/group_member_presenter.rb index 8f53dfa105e..c4dcc9e60f9 100644 --- a/app/presenters/group_member_presenter.rb +++ b/app/presenters/group_member_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GroupMemberPresenter < MemberPresenter private diff --git a/app/presenters/member_presenter.rb b/app/presenters/member_presenter.rb index 7d2f9303b8f..2497bea4aff 100644 --- a/app/presenters/member_presenter.rb +++ b/app/presenters/member_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MemberPresenter < Gitlab::View::Presenter::Delegated presents :member diff --git a/app/presenters/members_presenter.rb b/app/presenters/members_presenter.rb index e4aba37b69e..03ebea36d49 100644 --- a/app/presenters/members_presenter.rb +++ b/app/presenters/members_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MembersPresenter < Gitlab::View::Presenter::Delegated include Enumerable diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb index f77b3541644..ffa238a63d5 100644 --- a/app/presenters/merge_request_presenter.rb +++ b/app/presenters/merge_request_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class MergeRequestPresenter < Gitlab::View::Presenter::Delegated include ActionView::Helpers::UrlHelper include GitlabRoutingHelper diff --git a/app/presenters/project_member_presenter.rb b/app/presenters/project_member_presenter.rb index 7f42d2b70df..e4731074e86 100644 --- a/app/presenters/project_member_presenter.rb +++ b/app/presenters/project_member_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectMemberPresenter < MemberPresenter private diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index d4d622d84ab..4c2f33213d6 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ProjectPresenter < Gitlab::View::Presenter::Delegated include ActionView::Helpers::NumberHelper include ActionView::Helpers::UrlHelper diff --git a/app/presenters/projects/settings/deploy_keys_presenter.rb b/app/presenters/projects/settings/deploy_keys_presenter.rb index c226586fba5..28eaef00a12 100644 --- a/app/presenters/projects/settings/deploy_keys_presenter.rb +++ b/app/presenters/projects/settings/deploy_keys_presenter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Projects module Settings class DeployKeysPresenter < Gitlab::View::Presenter::Simple diff --git a/changelogs/unreleased/frozen-string-enable-app-presenters-policies.yml b/changelogs/unreleased/frozen-string-enable-app-presenters-policies.yml new file mode 100644 index 00000000000..5c6b1b1a904 --- /dev/null +++ b/changelogs/unreleased/frozen-string-enable-app-presenters-policies.yml @@ -0,0 +1,5 @@ +--- +title: Enable frozen string in app/presenters and app/policies +merge_request: 20819 +author: gfyoung +type: performance |