diff options
author | gfyoung <gfyoung17@gmail.com> | 2018-10-06 16:10:08 -0700 |
---|---|---|
committer | gfyoung <gfyoung17@gmail.com> | 2018-10-06 17:02:50 -0700 |
commit | d598e4fd937797a7f7778f5b4158ebf73139ce7f (patch) | |
tree | aaf16bddfbd7b9aeba06b15e893c474b4f125506 | |
parent | c3389c8006443e2b4d994eb15e60bd249fc4732f (diff) | |
download | gitlab-ce-d598e4fd937797a7f7778f5b4158ebf73139ce7f.tar.gz |
Enable more frozen string in lib/**/*.rb
Enables frozen for the following:
* lib/*.rb
* lib/banzai/**/*.rb
* lib/bitbucket/**/*.rb
* lib/constraints/**/*.rb
* lib/container_registry/**/*.rb
* lib/declarative_policy/**/*.rb
Partially addresses #47424.
103 files changed, 217 insertions, 5 deletions
diff --git a/changelogs/unreleased/more-frozen-string-enable-lib.yml b/changelogs/unreleased/more-frozen-string-enable-lib.yml new file mode 100644 index 00000000000..9598c53b7fd --- /dev/null +++ b/changelogs/unreleased/more-frozen-string-enable-lib.yml @@ -0,0 +1,5 @@ +--- +title: Enable more frozen string in lib/**/*.rb +merge_request: +author: gfyoung +type: performance diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb index a4d8507960e..6fb7985f955 100644 --- a/lib/after_commit_queue.rb +++ b/lib/after_commit_queue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module AfterCommitQueue extend ActiveSupport::Concern diff --git a/lib/backup.rb b/lib/backup.rb index e2c62af23ae..2712b33b4b4 100644 --- a/lib/backup.rb +++ b/lib/backup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Backup Error = Class.new(StandardError) end diff --git a/lib/banzai.rb b/lib/banzai.rb index 788f29a6c08..1eb41ff7133 100644 --- a/lib/banzai.rb +++ b/lib/banzai.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai # if you need to render markdown, then you probably need to post_process as well, # such as removing references that the current user doesn't have diff --git a/lib/banzai/color_parser.rb b/lib/banzai/color_parser.rb index 355c364b07b..6d01d51955c 100644 --- a/lib/banzai/color_parser.rb +++ b/lib/banzai/color_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ColorParser ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/ # 0.0..1.0 diff --git a/lib/banzai/commit_renderer.rb b/lib/banzai/commit_renderer.rb index c351a155ae5..f346151a3c1 100644 --- a/lib/banzai/commit_renderer.rb +++ b/lib/banzai/commit_renderer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module CommitRenderer ATTRIBUTES = [:description, :title].freeze diff --git a/lib/banzai/cross_project_reference.rb b/lib/banzai/cross_project_reference.rb index 43f913a8859..b7344808989 100644 --- a/lib/banzai/cross_project_reference.rb +++ b/lib/banzai/cross_project_reference.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai # Common methods for ReferenceFilters that support an optional cross-project # reference. diff --git a/lib/banzai/filter.rb b/lib/banzai/filter.rb index 3eb544dfef9..7d9766c906c 100644 --- a/lib/banzai/filter.rb +++ b/lib/banzai/filter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Filter def self.[](name) diff --git a/lib/banzai/filter/markdown_engines/common_mark.rb b/lib/banzai/filter/markdown_engines/common_mark.rb index dbb25280849..e52c0d15b31 100644 --- a/lib/banzai/filter/markdown_engines/common_mark.rb +++ b/lib/banzai/filter/markdown_engines/common_mark.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # `CommonMark` markdown engine for GitLab's Banzai markdown filter. # This module is used in Banzai::Filter::MarkdownFilter. # Used gem is `commonmarker` which is a ruby wrapper for libcmark (CommonMark parser) diff --git a/lib/banzai/filter/markdown_engines/redcarpet.rb b/lib/banzai/filter/markdown_engines/redcarpet.rb index ac99941fefa..ec150d041ff 100644 --- a/lib/banzai/filter/markdown_engines/redcarpet.rb +++ b/lib/banzai/filter/markdown_engines/redcarpet.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # `Redcarpet` markdown engine for GitLab's Banzai markdown filter. # This module is used in Banzai::Filter::MarkdownFilter. # Used gem is `redcarpet` which is a ruby library for markdown processing. diff --git a/lib/banzai/filter/wiki_link_filter/rewriter.rb b/lib/banzai/filter/wiki_link_filter/rewriter.rb index 4bf80aff418..f4cc8beeb52 100644 --- a/lib/banzai/filter/wiki_link_filter/rewriter.rb +++ b/lib/banzai/filter/wiki_link_filter/rewriter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Filter class WikiLinkFilter < HTML::Pipeline::Filter diff --git a/lib/banzai/filter_array.rb b/lib/banzai/filter_array.rb index 77835a14027..818af4643a7 100644 --- a/lib/banzai/filter_array.rb +++ b/lib/banzai/filter_array.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai class FilterArray < Array # Insert a value immediately after another value diff --git a/lib/banzai/issuable_extractor.rb b/lib/banzai/issuable_extractor.rb index ae7dc71e7eb..0a05d46db4c 100644 --- a/lib/banzai/issuable_extractor.rb +++ b/lib/banzai/issuable_extractor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai # Extract references to issuables from multiple documents diff --git a/lib/banzai/object_renderer.rb b/lib/banzai/object_renderer.rb index 7137c1da57d..75661ffa233 100644 --- a/lib/banzai/object_renderer.rb +++ b/lib/banzai/object_renderer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai # Class for rendering multiple objects (e.g. Note instances) in a single pass, # using +render_field+ to benefit from caching in the database. Rendering and diff --git a/lib/banzai/pipeline.rb b/lib/banzai/pipeline.rb index 142a9962eb1..e8a81bebaa9 100644 --- a/lib/banzai/pipeline.rb +++ b/lib/banzai/pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline def self.[](name) diff --git a/lib/banzai/pipeline/ascii_doc_pipeline.rb b/lib/banzai/pipeline/ascii_doc_pipeline.rb index 1048b927cd3..cc4af280872 100644 --- a/lib/banzai/pipeline/ascii_doc_pipeline.rb +++ b/lib/banzai/pipeline/ascii_doc_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class AsciiDocPipeline < BasePipeline diff --git a/lib/banzai/pipeline/atom_pipeline.rb b/lib/banzai/pipeline/atom_pipeline.rb index 9694e4bc23f..13a342351b6 100644 --- a/lib/banzai/pipeline/atom_pipeline.rb +++ b/lib/banzai/pipeline/atom_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class AtomPipeline < FullPipeline diff --git a/lib/banzai/pipeline/base_pipeline.rb b/lib/banzai/pipeline/base_pipeline.rb index 3ae3bed570d..87d1cf9912f 100644 --- a/lib/banzai/pipeline/base_pipeline.rb +++ b/lib/banzai/pipeline/base_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class BasePipeline diff --git a/lib/banzai/pipeline/broadcast_message_pipeline.rb b/lib/banzai/pipeline/broadcast_message_pipeline.rb index 5dd572de3a1..a3d63e0aaf5 100644 --- a/lib/banzai/pipeline/broadcast_message_pipeline.rb +++ b/lib/banzai/pipeline/broadcast_message_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class BroadcastMessagePipeline < DescriptionPipeline diff --git a/lib/banzai/pipeline/combined_pipeline.rb b/lib/banzai/pipeline/combined_pipeline.rb index 60190f8d9dd..56b424dc8e0 100644 --- a/lib/banzai/pipeline/combined_pipeline.rb +++ b/lib/banzai/pipeline/combined_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline module CombinedPipeline diff --git a/lib/banzai/pipeline/commit_description_pipeline.rb b/lib/banzai/pipeline/commit_description_pipeline.rb index 607c2731ed3..e8ec7453f0f 100644 --- a/lib/banzai/pipeline/commit_description_pipeline.rb +++ b/lib/banzai/pipeline/commit_description_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class CommitDescriptionPipeline < SingleLinePipeline diff --git a/lib/banzai/pipeline/description_pipeline.rb b/lib/banzai/pipeline/description_pipeline.rb index 042fb2e6e14..d5ff9b025cc 100644 --- a/lib/banzai/pipeline/description_pipeline.rb +++ b/lib/banzai/pipeline/description_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class DescriptionPipeline < FullPipeline diff --git a/lib/banzai/pipeline/email_pipeline.rb b/lib/banzai/pipeline/email_pipeline.rb index 8f5f144d582..2c08581ce0d 100644 --- a/lib/banzai/pipeline/email_pipeline.rb +++ b/lib/banzai/pipeline/email_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class EmailPipeline < FullPipeline diff --git a/lib/banzai/pipeline/full_pipeline.rb b/lib/banzai/pipeline/full_pipeline.rb index 3c974f73176..a5b1cbdd030 100644 --- a/lib/banzai/pipeline/full_pipeline.rb +++ b/lib/banzai/pipeline/full_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class FullPipeline < CombinedPipeline.new(PlainMarkdownPipeline, GfmPipeline) diff --git a/lib/banzai/pipeline/gfm_pipeline.rb b/lib/banzai/pipeline/gfm_pipeline.rb index bd34614f149..be75e34a673 100644 --- a/lib/banzai/pipeline/gfm_pipeline.rb +++ b/lib/banzai/pipeline/gfm_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class GfmPipeline < BasePipeline diff --git a/lib/banzai/pipeline/markup_pipeline.rb b/lib/banzai/pipeline/markup_pipeline.rb index c56d908009f..db79a22549c 100644 --- a/lib/banzai/pipeline/markup_pipeline.rb +++ b/lib/banzai/pipeline/markup_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class MarkupPipeline < BasePipeline diff --git a/lib/banzai/pipeline/note_pipeline.rb b/lib/banzai/pipeline/note_pipeline.rb index 7890f20f716..4480d7ede05 100644 --- a/lib/banzai/pipeline/note_pipeline.rb +++ b/lib/banzai/pipeline/note_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class NotePipeline < FullPipeline diff --git a/lib/banzai/pipeline/plain_markdown_pipeline.rb b/lib/banzai/pipeline/plain_markdown_pipeline.rb index 3f45db21869..b64f13cde47 100644 --- a/lib/banzai/pipeline/plain_markdown_pipeline.rb +++ b/lib/banzai/pipeline/plain_markdown_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class PlainMarkdownPipeline < BasePipeline diff --git a/lib/banzai/pipeline/post_process_pipeline.rb b/lib/banzai/pipeline/post_process_pipeline.rb index 0b2e584ef16..63a998a2c1f 100644 --- a/lib/banzai/pipeline/post_process_pipeline.rb +++ b/lib/banzai/pipeline/post_process_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class PostProcessPipeline < BasePipeline diff --git a/lib/banzai/pipeline/pre_process_pipeline.rb b/lib/banzai/pipeline/pre_process_pipeline.rb index 6cf219661d3..c937f783180 100644 --- a/lib/banzai/pipeline/pre_process_pipeline.rb +++ b/lib/banzai/pipeline/pre_process_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class PreProcessPipeline < BasePipeline diff --git a/lib/banzai/pipeline/relative_link_pipeline.rb b/lib/banzai/pipeline/relative_link_pipeline.rb index 270990e7ab4..88651892acc 100644 --- a/lib/banzai/pipeline/relative_link_pipeline.rb +++ b/lib/banzai/pipeline/relative_link_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class RelativeLinkPipeline < BasePipeline diff --git a/lib/banzai/pipeline/single_line_pipeline.rb b/lib/banzai/pipeline/single_line_pipeline.rb index cd5a6c8875c..61ff7b0bcce 100644 --- a/lib/banzai/pipeline/single_line_pipeline.rb +++ b/lib/banzai/pipeline/single_line_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class SingleLinePipeline < GfmPipeline diff --git a/lib/banzai/pipeline/wiki_pipeline.rb b/lib/banzai/pipeline/wiki_pipeline.rb index c37b8e71cb0..97a03895ff3 100644 --- a/lib/banzai/pipeline/wiki_pipeline.rb +++ b/lib/banzai/pipeline/wiki_pipeline.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Pipeline class WikiPipeline < FullPipeline diff --git a/lib/banzai/querying.rb b/lib/banzai/querying.rb index a19a05e8c0d..55aa5fa66c3 100644 --- a/lib/banzai/querying.rb +++ b/lib/banzai/querying.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Querying module_function diff --git a/lib/banzai/redactor.rb b/lib/banzai/redactor.rb index e77bee78496..7db5f5e1f7d 100644 --- a/lib/banzai/redactor.rb +++ b/lib/banzai/redactor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai # Class for removing Markdown references a certain user is not allowed to # view. diff --git a/lib/banzai/reference_extractor.rb b/lib/banzai/reference_extractor.rb index 78588299c18..3fc3ae02088 100644 --- a/lib/banzai/reference_extractor.rb +++ b/lib/banzai/reference_extractor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai # Extract possible GFM references from an arbitrary String for further processing. class ReferenceExtractor diff --git a/lib/banzai/reference_parser.rb b/lib/banzai/reference_parser.rb index 557bec4316e..efe15096f08 100644 --- a/lib/banzai/reference_parser.rb +++ b/lib/banzai/reference_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser # Returns the reference parser class for the given type diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb index 334ba97bfb3..8419769085a 100644 --- a/lib/banzai/reference_parser/base_parser.rb +++ b/lib/banzai/reference_parser/base_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser # Base class for reference parsing classes. diff --git a/lib/banzai/reference_parser/commit_parser.rb b/lib/banzai/reference_parser/commit_parser.rb index 30dc87248b4..0bfb6a92020 100644 --- a/lib/banzai/reference_parser/commit_parser.rb +++ b/lib/banzai/reference_parser/commit_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class CommitParser < BaseParser diff --git a/lib/banzai/reference_parser/commit_range_parser.rb b/lib/banzai/reference_parser/commit_range_parser.rb index 2920e886938..480eefd5c4d 100644 --- a/lib/banzai/reference_parser/commit_range_parser.rb +++ b/lib/banzai/reference_parser/commit_range_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class CommitRangeParser < BaseParser diff --git a/lib/banzai/reference_parser/directly_addressed_user_parser.rb b/lib/banzai/reference_parser/directly_addressed_user_parser.rb index 77df9bbd024..1f18f82b916 100644 --- a/lib/banzai/reference_parser/directly_addressed_user_parser.rb +++ b/lib/banzai/reference_parser/directly_addressed_user_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class DirectlyAddressedUserParser < UserParser diff --git a/lib/banzai/reference_parser/epic_parser.rb b/lib/banzai/reference_parser/epic_parser.rb index 08b8a4c9a0f..7f366f0f8ab 100644 --- a/lib/banzai/reference_parser/epic_parser.rb +++ b/lib/banzai/reference_parser/epic_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser # The actual parser is implemented in the EE mixin diff --git a/lib/banzai/reference_parser/external_issue_parser.rb b/lib/banzai/reference_parser/external_issue_parser.rb index 1802cd04854..029b09dcd25 100644 --- a/lib/banzai/reference_parser/external_issue_parser.rb +++ b/lib/banzai/reference_parser/external_issue_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class ExternalIssueParser < BaseParser diff --git a/lib/banzai/reference_parser/issuable_parser.rb b/lib/banzai/reference_parser/issuable_parser.rb index fad127d7e5b..f8c26288017 100644 --- a/lib/banzai/reference_parser/issuable_parser.rb +++ b/lib/banzai/reference_parser/issuable_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class IssuableParser < BaseParser diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb index 7b5915899cf..97c7173ac0f 100644 --- a/lib/banzai/reference_parser/issue_parser.rb +++ b/lib/banzai/reference_parser/issue_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class IssueParser < IssuableParser diff --git a/lib/banzai/reference_parser/label_parser.rb b/lib/banzai/reference_parser/label_parser.rb index 30e2a012f09..398cc45fea0 100644 --- a/lib/banzai/reference_parser/label_parser.rb +++ b/lib/banzai/reference_parser/label_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class LabelParser < BaseParser diff --git a/lib/banzai/reference_parser/merge_request_parser.rb b/lib/banzai/reference_parser/merge_request_parser.rb index 9e5d55f72bc..e8147ac591a 100644 --- a/lib/banzai/reference_parser/merge_request_parser.rb +++ b/lib/banzai/reference_parser/merge_request_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class MergeRequestParser < IssuableParser diff --git a/lib/banzai/reference_parser/milestone_parser.rb b/lib/banzai/reference_parser/milestone_parser.rb index 68675abe22a..925d736fb9a 100644 --- a/lib/banzai/reference_parser/milestone_parser.rb +++ b/lib/banzai/reference_parser/milestone_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class MilestoneParser < BaseParser diff --git a/lib/banzai/reference_parser/snippet_parser.rb b/lib/banzai/reference_parser/snippet_parser.rb index 3ade168b566..6f6ac08de04 100644 --- a/lib/banzai/reference_parser/snippet_parser.rb +++ b/lib/banzai/reference_parser/snippet_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class SnippetParser < BaseParser diff --git a/lib/banzai/reference_parser/user_parser.rb b/lib/banzai/reference_parser/user_parser.rb index ceb7f1d165c..067b06b7590 100644 --- a/lib/banzai/reference_parser/user_parser.rb +++ b/lib/banzai/reference_parser/user_parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module ReferenceParser class UserParser < BaseParser diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb index 0050295eeda..c7239a5eaa6 100644 --- a/lib/banzai/renderer.rb +++ b/lib/banzai/renderer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Renderer # Convert a Markdown String into an HTML-safe String of HTML diff --git a/lib/banzai/renderer/common_mark/html.rb b/lib/banzai/renderer/common_mark/html.rb index 0b27316da1b..837665451a1 100644 --- a/lib/banzai/renderer/common_mark/html.rb +++ b/lib/banzai/renderer/common_mark/html.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Renderer module CommonMark diff --git a/lib/banzai/renderer/redcarpet/html.rb b/lib/banzai/renderer/redcarpet/html.rb index 30e815f1224..84931fdc784 100644 --- a/lib/banzai/renderer/redcarpet/html.rb +++ b/lib/banzai/renderer/redcarpet/html.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module Renderer module Redcarpet diff --git a/lib/banzai/request_store_reference_cache.rb b/lib/banzai/request_store_reference_cache.rb index 9a9704f9837..91fb489b72d 100644 --- a/lib/banzai/request_store_reference_cache.rb +++ b/lib/banzai/request_store_reference_cache.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Banzai module RequestStoreReferenceCache def cached_call(request_store_key, cache_key, path: []) diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb index f8ee7e0f9ae..1343f424c51 100644 --- a/lib/bitbucket/client.rb +++ b/lib/bitbucket/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket class Client attr_reader :connection diff --git a/lib/bitbucket/collection.rb b/lib/bitbucket/collection.rb index a78495dbf5e..9c496daccaa 100644 --- a/lib/bitbucket/collection.rb +++ b/lib/bitbucket/collection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket class Collection < Enumerator def initialize(paginator) diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb index ba5a9e2f04c..0041634f9e3 100644 --- a/lib/bitbucket/connection.rb +++ b/lib/bitbucket/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket class Connection DEFAULT_API_VERSION = '2.0'.freeze diff --git a/lib/bitbucket/error/unauthorized.rb b/lib/bitbucket/error/unauthorized.rb index efe10542f19..3cde11babee 100644 --- a/lib/bitbucket/error/unauthorized.rb +++ b/lib/bitbucket/error/unauthorized.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Error Unauthorized = Class.new(StandardError) diff --git a/lib/bitbucket/page.rb b/lib/bitbucket/page.rb index 2b0a3fe7b1a..7cc1342ad65 100644 --- a/lib/bitbucket/page.rb +++ b/lib/bitbucket/page.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket class Page attr_reader :attrs, :items diff --git a/lib/bitbucket/paginator.rb b/lib/bitbucket/paginator.rb index 135d0d55674..0d004592e67 100644 --- a/lib/bitbucket/paginator.rb +++ b/lib/bitbucket/paginator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket class Paginator PAGE_LENGTH = 50 # The minimum length is 10 and the maximum is 100. diff --git a/lib/bitbucket/representation/base.rb b/lib/bitbucket/representation/base.rb index 800d5a075c6..bb8dcd91ad5 100644 --- a/lib/bitbucket/representation/base.rb +++ b/lib/bitbucket/representation/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class Base diff --git a/lib/bitbucket/representation/comment.rb b/lib/bitbucket/representation/comment.rb index 4937aa9728f..1b8dc27793a 100644 --- a/lib/bitbucket/representation/comment.rb +++ b/lib/bitbucket/representation/comment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class Comment < Representation::Base diff --git a/lib/bitbucket/representation/issue.rb b/lib/bitbucket/representation/issue.rb index 44bcbc250b3..a88797cdab9 100644 --- a/lib/bitbucket/representation/issue.rb +++ b/lib/bitbucket/representation/issue.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class Issue < Representation::Base diff --git a/lib/bitbucket/representation/pull_request.rb b/lib/bitbucket/representation/pull_request.rb index eebf8093380..6a0e8b354bf 100644 --- a/lib/bitbucket/representation/pull_request.rb +++ b/lib/bitbucket/representation/pull_request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class PullRequest < Representation::Base diff --git a/lib/bitbucket/representation/pull_request_comment.rb b/lib/bitbucket/representation/pull_request_comment.rb index c52acbc3ddc..34dbf9ad22d 100644 --- a/lib/bitbucket/representation/pull_request_comment.rb +++ b/lib/bitbucket/representation/pull_request_comment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class PullRequestComment < Comment diff --git a/lib/bitbucket/representation/repo.rb b/lib/bitbucket/representation/repo.rb index 59b0fda8e14..c5bfc91e43d 100644 --- a/lib/bitbucket/representation/repo.rb +++ b/lib/bitbucket/representation/repo.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class Repo < Representation::Base diff --git a/lib/bitbucket/representation/user.rb b/lib/bitbucket/representation/user.rb index ba6b7667b49..2b45d751e70 100644 --- a/lib/bitbucket/representation/user.rb +++ b/lib/bitbucket/representation/user.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Bitbucket module Representation class User < Representation::Base diff --git a/lib/carrier_wave_string_file.rb b/lib/carrier_wave_string_file.rb index 6c848902e4a..c9a64d9e631 100644 --- a/lib/carrier_wave_string_file.rb +++ b/lib/carrier_wave_string_file.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CarrierWaveStringFile < StringIO def original_filename "" diff --git a/lib/constraints/feature_constrainer.rb b/lib/constraints/feature_constrainer.rb index 05d48b0f25a..ca4376a9d38 100644 --- a/lib/constraints/feature_constrainer.rb +++ b/lib/constraints/feature_constrainer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Constraints class FeatureConstrainer attr_reader :feature diff --git a/lib/constraints/group_url_constrainer.rb b/lib/constraints/group_url_constrainer.rb index 87649c50424..8a3f8d2faaf 100644 --- a/lib/constraints/group_url_constrainer.rb +++ b/lib/constraints/group_url_constrainer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Constraints class GroupUrlConstrainer def matches?(request) diff --git a/lib/constraints/project_url_constrainer.rb b/lib/constraints/project_url_constrainer.rb index 32aea98f0f7..eadfbf7bc01 100644 --- a/lib/constraints/project_url_constrainer.rb +++ b/lib/constraints/project_url_constrainer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Constraints class ProjectUrlConstrainer def matches?(request) diff --git a/lib/constraints/user_url_constrainer.rb b/lib/constraints/user_url_constrainer.rb index 8afa04d29a4..e763569cb2e 100644 --- a/lib/constraints/user_url_constrainer.rb +++ b/lib/constraints/user_url_constrainer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Constraints class UserUrlConstrainer def matches?(request) diff --git a/lib/container_registry/blob.rb b/lib/container_registry/blob.rb index d5f85f9fcad..837b22c3082 100644 --- a/lib/container_registry/blob.rb +++ b/lib/container_registry/blob.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ContainerRegistry class Blob attr_reader :repository, :config diff --git a/lib/container_registry/client.rb b/lib/container_registry/client.rb index 010ca1ec27b..c80f49f5ae0 100644 --- a/lib/container_registry/client.rb +++ b/lib/container_registry/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'faraday' require 'faraday_middleware' diff --git a/lib/container_registry/config.rb b/lib/container_registry/config.rb index 589f9f4380a..740c0e13da0 100644 --- a/lib/container_registry/config.rb +++ b/lib/container_registry/config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ContainerRegistry class Config attr_reader :tag, :blob, :data diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb index 1ab14c1c155..9b2a61cdedc 100644 --- a/lib/container_registry/path.rb +++ b/lib/container_registry/path.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ContainerRegistry ## # Class responsible for extracting project and repository name from diff --git a/lib/container_registry/registry.rb b/lib/container_registry/registry.rb index f90d711474a..523364ac7c7 100644 --- a/lib/container_registry/registry.rb +++ b/lib/container_registry/registry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ContainerRegistry class Registry attr_reader :uri, :client, :path diff --git a/lib/container_registry/tag.rb b/lib/container_registry/tag.rb index c785bca4dad..8633e764f90 100644 --- a/lib/container_registry/tag.rb +++ b/lib/container_registry/tag.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ContainerRegistry class Tag attr_reader :repository, :name diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb index 10d34b0c6e7..5e22523e45a 100644 --- a/lib/declarative_policy.rb +++ b/lib/declarative_policy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_dependency 'declarative_policy/cache' require_dependency 'declarative_policy/condition' require_dependency 'declarative_policy/delegate_dsl' diff --git a/lib/declarative_policy/base.rb b/lib/declarative_policy/base.rb index da3fabba39b..cd6e1606f22 100644 --- a/lib/declarative_policy/base.rb +++ b/lib/declarative_policy/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy class Base # A map of ability => list of rules together with :enable diff --git a/lib/declarative_policy/cache.rb b/lib/declarative_policy/cache.rb index 780d8f707bd..13006e56454 100644 --- a/lib/declarative_policy/cache.rb +++ b/lib/declarative_policy/cache.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy module Cache class << self diff --git a/lib/declarative_policy/condition.rb b/lib/declarative_policy/condition.rb index 51c4a8b2bbe..b77f40b1093 100644 --- a/lib/declarative_policy/condition.rb +++ b/lib/declarative_policy/condition.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy # A Condition is the data structure that is created by the # `condition` declaration on DeclarativePolicy::Base. It is diff --git a/lib/declarative_policy/delegate_dsl.rb b/lib/declarative_policy/delegate_dsl.rb index ca2eb98e3e8..67e3429b696 100644 --- a/lib/declarative_policy/delegate_dsl.rb +++ b/lib/declarative_policy/delegate_dsl.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy # Used when the name of a delegate is mentioned in # the rule DSL. diff --git a/lib/declarative_policy/policy_dsl.rb b/lib/declarative_policy/policy_dsl.rb index c96049768a1..96741c0478e 100644 --- a/lib/declarative_policy/policy_dsl.rb +++ b/lib/declarative_policy/policy_dsl.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy # The return value of a rule { ... } declaration. # Can call back to register rules with the containing diff --git a/lib/declarative_policy/preferred_scope.rb b/lib/declarative_policy/preferred_scope.rb index c77784cb49d..239780d8626 100644 --- a/lib/declarative_policy/preferred_scope.rb +++ b/lib/declarative_policy/preferred_scope.rb @@ -1,4 +1,7 @@ -module DeclarativePolicy # rubocop:disable Naming/FileName +# rubocop:disable Naming/FileName +# frozen_string_literal: true + +module DeclarativePolicy PREFERRED_SCOPE_KEY = :"DeclarativePolicy.preferred_scope" class << self diff --git a/lib/declarative_policy/rule.rb b/lib/declarative_policy/rule.rb index 407398cc770..f38f4f0a50f 100644 --- a/lib/declarative_policy/rule.rb +++ b/lib/declarative_policy/rule.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy module Rule # A Rule is the object that results from the `rule` declaration, diff --git a/lib/declarative_policy/rule_dsl.rb b/lib/declarative_policy/rule_dsl.rb index 7254b08eda5..85da7f261fa 100644 --- a/lib/declarative_policy/rule_dsl.rb +++ b/lib/declarative_policy/rule_dsl.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy # The DSL evaluation context inside rule { ... } blocks. # Responsible for creating and combining Rule objects. diff --git a/lib/declarative_policy/runner.rb b/lib/declarative_policy/runner.rb index fec672f4b8c..f739fe5e16e 100644 --- a/lib/declarative_policy/runner.rb +++ b/lib/declarative_policy/runner.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy class Runner class State diff --git a/lib/declarative_policy/step.rb b/lib/declarative_policy/step.rb index 3469fe9f991..c289c17cc19 100644 --- a/lib/declarative_policy/step.rb +++ b/lib/declarative_policy/step.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DeclarativePolicy # This object represents one step in the runtime decision of whether # an ability is allowed. It contains a Rule and a context (instance diff --git a/lib/expand_variables.rb b/lib/expand_variables.rb index 7b1533d0d32..c83cec9dc4a 100644 --- a/lib/expand_variables.rb +++ b/lib/expand_variables.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ExpandVariables class << self def expand(value, variables) diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index e02d403f7b1..a340a276640 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Module providing methods for dealing with separating a tree-ish string and a # file path string when combined in a request parameter module ExtractsPath @@ -50,7 +52,9 @@ module ExtractsPath # branches and tags # Append a trailing slash if we only get a ref and no file path - id += '/' unless id.ends_with?('/') + unless id.ends_with?('/') + id = [id, '/'].join + end valid_refs = ref_names.select { |v| id.start_with?("#{v}/") } @@ -151,9 +155,9 @@ module ExtractsPath # overriden in subclasses, do not remove def get_id - id = params[:id] || params[:ref] - id += "/" + params[:path] unless params[:path].blank? - id + id = [params[:id] || params[:ref]] + id << "/" + params[:path] unless params[:path].blank? + id.join end def ref_names diff --git a/lib/feature.rb b/lib/feature.rb index a8324d99c10..e048a443abc 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'flipper/adapters/active_record' require 'flipper/adapters/active_support_cache_store' diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb index 53aa8d04e5c..70a145cd5bd 100644 --- a/lib/file_size_validator.rb +++ b/lib/file_size_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class FileSizeValidator < ActiveModel::EachValidator MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze diff --git a/lib/forever.rb b/lib/forever.rb index 7df17912544..0a37118fe68 100644 --- a/lib/forever.rb +++ b/lib/forever.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Forever POSTGRESQL_DATE = DateTime.new(3000, 1, 1) MYSQL_DATE = DateTime.new(2038, 01, 19) diff --git a/lib/gitlab.rb b/lib/gitlab.rb index 7790534d5d7..2bb09684441 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_dependency 'gitlab/popen' module Gitlab diff --git a/lib/gt_one_coercion.rb b/lib/gt_one_coercion.rb index ef2dc09767c..99be51bc8c6 100644 --- a/lib/gt_one_coercion.rb +++ b/lib/gt_one_coercion.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class GtOneCoercion < Virtus::Attribute def coerce(value) [1, value.to_i].max diff --git a/lib/milestone_array.rb b/lib/milestone_array.rb index 4ed8485b36a..461e73e9670 100644 --- a/lib/milestone_array.rb +++ b/lib/milestone_array.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MilestoneArray class << self def sort(array, sort_method) diff --git a/lib/mysql_zero_date.rb b/lib/mysql_zero_date.rb index 64634f789da..216560148fa 100644 --- a/lib/mysql_zero_date.rb +++ b/lib/mysql_zero_date.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Disable NO_ZERO_DATE mode for mysql in rails 5. # We use zero date as a default value # (config/initializers/active_record_mysql_timestamp.rb), in diff --git a/lib/static_model.rb b/lib/static_model.rb index 44673c2b5f6..86bf8d62f9a 100644 --- a/lib/static_model.rb +++ b/lib/static_model.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Provides an ActiveRecord-like interface to a model whose data is not persisted to a database. module StaticModel extend ActiveSupport::Concern diff --git a/lib/system_check.rb b/lib/system_check.rb index 466c39904fa..7ffd7c03c5b 100644 --- a/lib/system_check.rb +++ b/lib/system_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Library to perform System Checks # # Every Check is implemented as its own class inherited from SystemCheck::BaseCheck diff --git a/lib/unfold_form.rb b/lib/unfold_form.rb index fcd01503d1b..05bb3ed7f1c 100644 --- a/lib/unfold_form.rb +++ b/lib/unfold_form.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'gt_one_coercion' class UnfoldForm diff --git a/lib/uploaded_file.rb b/lib/uploaded_file.rb index 53e5ac02e42..aae542f02ac 100644 --- a/lib/uploaded_file.rb +++ b/lib/uploaded_file.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "tempfile" require "tmpdir" require "fileutils" diff --git a/lib/version_check.rb b/lib/version_check.rb index 91ad07feee5..ccf7bb493db 100644 --- a/lib/version_check.rb +++ b/lib/version_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "base64" # This class is used to build image URL to |