diff options
author | gfyoung <gfyoung17+gitlab@gmail.com> | 2018-10-22 07:00:50 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-10-22 07:00:50 +0000 |
commit | c858f70d076dc44f6bf1ab1f7acb1fc13a12ab1b (patch) | |
tree | 40fa82826cf182f47b1c905e738c8ee955ad14c2 | |
parent | 173b1436b1622b85d4a81e3577c6492cbb93a8b8 (diff) | |
download | gitlab-ce-c858f70d076dc44f6bf1ab1f7acb1fc13a12ab1b.tar.gz |
Enable frozen string for lib/gitlab/*.rb
151 files changed, 327 insertions, 22 deletions
diff --git a/changelogs/unreleased/frozen-string-enable-lib-gitlab.yml b/changelogs/unreleased/frozen-string-enable-lib-gitlab.yml new file mode 100644 index 00000000000..d64278eb626 --- /dev/null +++ b/changelogs/unreleased/frozen-string-enable-lib-gitlab.yml @@ -0,0 +1,5 @@ +--- +title: Enable frozen string for lib/gitlab/*.rb +merge_request: +author: gfyoung +type: performance diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index afdc6f383c1..a0434a66ef1 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -164,7 +164,7 @@ module Backup def tar_version tar_version, _ = Gitlab::Popen.popen(%w(tar --version)) - tar_version.force_encoding('locale').split("\n").first + tar_version.dup.force_encoding('locale').split("\n").first end def skipped?(item) diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb index b170145f013..ec090aea784 100644 --- a/lib/gitlab/access.rb +++ b/lib/gitlab/access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Gitlab::Access module # # Define allowed roles that can be used diff --git a/lib/gitlab/action_rate_limiter.rb b/lib/gitlab/action_rate_limiter.rb index 4cd3bdefda3..c442211e073 100644 --- a/lib/gitlab/action_rate_limiter.rb +++ b/lib/gitlab/action_rate_limiter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # This class implements a simple rate limiter that can be used to throttle # certain actions. Unlike Rack Attack and Rack::Throttle, which operate at diff --git a/lib/gitlab/allowable.rb b/lib/gitlab/allowable.rb index 45c2b01dd8f..4518c8a862c 100644 --- a/lib/gitlab/allowable.rb +++ b/lib/gitlab/allowable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Allowable def can?(*args) diff --git a/lib/gitlab/app_logger.rb b/lib/gitlab/app_logger.rb index dddcb2538f9..5edec8b3efe 100644 --- a/lib/gitlab/app_logger.rb +++ b/lib/gitlab/app_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class AppLogger < Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb index 62c41801d75..df8f0470063 100644 --- a/lib/gitlab/asciidoc.rb +++ b/lib/gitlab/asciidoc.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'asciidoctor' require 'asciidoctor/converter/html5' require "asciidoctor-plantuml" diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index a36d551d1d7..d2029a141e7 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Auth MissingPersonalAccessTokenError = Class.new(StandardError) diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb index 36c85dec544..d72befce571 100644 --- a/lib/gitlab/background_migration.rb +++ b/lib/gitlab/background_migration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module BackgroundMigration def self.queue diff --git a/lib/gitlab/base_doorkeeper_controller.rb b/lib/gitlab/base_doorkeeper_controller.rb index e4227af25d2..b78993aba30 100644 --- a/lib/gitlab/base_doorkeeper_controller.rb +++ b/lib/gitlab/base_doorkeeper_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This is a base controller for doorkeeper. # It adds the `can?` helper used in the views. module Gitlab diff --git a/lib/gitlab/blame.rb b/lib/gitlab/blame.rb index 169aac79854..0d79594363e 100644 --- a/lib/gitlab/blame.rb +++ b/lib/gitlab/blame.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Blame attr_accessor :blob, :commit diff --git a/lib/gitlab/blob_helper.rb b/lib/gitlab/blob_helper.rb index 9b3b383b0c8..488c1d85387 100644 --- a/lib/gitlab/blob_helper.rb +++ b/lib/gitlab/blob_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This has been extracted from https://github.com/github/linguist/blob/master/lib/linguist/blob_helper.rb module Gitlab module BlobHelper diff --git a/lib/gitlab/build_access.rb b/lib/gitlab/build_access.rb index 08a8f846ca5..37e79413541 100644 --- a/lib/gitlab/build_access.rb +++ b/lib/gitlab/build_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class BuildAccess < UserAccess attr_accessor :user, :project diff --git a/lib/gitlab/changes_list.rb b/lib/gitlab/changes_list.rb index 9c9e6668e6f..fb75a78a978 100644 --- a/lib/gitlab/changes_list.rb +++ b/lib/gitlab/changes_list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ChangesList include Enumerable diff --git a/lib/gitlab/chat_name_token.rb b/lib/gitlab/chat_name_token.rb index e63e5437331..8b3c5dc9e8b 100644 --- a/lib/gitlab/chat_name_token.rb +++ b/lib/gitlab/chat_name_token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'json' module Gitlab diff --git a/lib/gitlab/ci_access.rb b/lib/gitlab/ci_access.rb index def1373d8cf..d5d3eb804ae 100644 --- a/lib/gitlab/ci_access.rb +++ b/lib/gitlab/ci_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # For backwards compatibility, generic CI (which is a build without a user) is # allowed to :build_download_code without any other checks. diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb index 7e7aaeeaa17..4ba921569ad 100644 --- a/lib/gitlab/closing_issue_extractor.rb +++ b/lib/gitlab/closing_issue_extractor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ClosingIssueExtractor ISSUE_CLOSING_REGEX = begin diff --git a/lib/gitlab/color_schemes.rb b/lib/gitlab/color_schemes.rb index 9c4664df903..a5e4065cf09 100644 --- a/lib/gitlab/color_schemes.rb +++ b/lib/gitlab/color_schemes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Module containing GitLab's syntax color scheme definitions and helper # methods for accessing them. diff --git a/lib/gitlab/config_helper.rb b/lib/gitlab/config_helper.rb index 41880069e4c..b7aa03384b7 100644 --- a/lib/gitlab/config_helper.rb +++ b/lib/gitlab/config_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab::ConfigHelper def gitlab_config_features Gitlab.config.gitlab.default_projects_features diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index 1ffc2639237..c819bffdfd6 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ContributionsCalendar attr_reader :contributor diff --git a/lib/gitlab/contributor.rb b/lib/gitlab/contributor.rb index c41e92b620f..d74d5a86aa0 100644 --- a/lib/gitlab/contributor.rb +++ b/lib/gitlab/contributor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Contributor attr_accessor :email, :name, :commits, :additions, :deletions diff --git a/lib/gitlab/cross_project_access.rb b/lib/gitlab/cross_project_access.rb index 6eaed51b64c..4ddc7e02d1b 100644 --- a/lib/gitlab/cross_project_access.rb +++ b/lib/gitlab/cross_project_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class CrossProjectAccess class << self diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index de7c959e706..477f9101e98 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module CurrentSettings class << self diff --git a/lib/gitlab/daemon.rb b/lib/gitlab/daemon.rb index bd14c7eece3..6d5fc4219fb 100644 --- a/lib/gitlab/daemon.rb +++ b/lib/gitlab/daemon.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Daemon def self.initialize_instance(*args) diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index 42f9605f5ac..68ed53cf64a 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Database # The max value of INTEGER type is the same between MySQL and PostgreSQL: @@ -99,11 +101,11 @@ module Gitlab order = "#{field} #{direction}" if postgresql? - order << ' NULLS LAST' + order = "#{order} NULLS LAST" else # `field IS NULL` will be `0` for non-NULL columns and `1` for NULL # columns. In the (default) ascending order, `0` comes first. - order.prepend("#{field} IS NULL, ") if direction == 'ASC' + order = "#{field} IS NULL, #{order}" if direction == 'ASC' end order @@ -113,11 +115,11 @@ module Gitlab order = "#{field} #{direction}" if postgresql? - order << ' NULLS FIRST' + order = "#{order} NULLS FIRST" else # `field IS NULL` will be `0` for non-NULL columns and `1` for NULL # columns. In the (default) ascending order, `0` comes first. - order.prepend("#{field} IS NULL, ") if direction == 'DESC' + order = "#{field} IS NULL, #{order}" if direction == 'DESC' end order @@ -184,7 +186,7 @@ module Gitlab EOF if return_ids - sql << 'RETURNING id' + sql = "#{sql}RETURNING id" end result = connection.execute(sql) diff --git a/lib/gitlab/dependency_linker.rb b/lib/gitlab/dependency_linker.rb index 3192bf6f667..c63d9e5bb71 100644 --- a/lib/gitlab/dependency_linker.rb +++ b/lib/gitlab/dependency_linker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module DependencyLinker LINKERS = [ diff --git a/lib/gitlab/downtime_check.rb b/lib/gitlab/downtime_check.rb index 941244694e2..31bb6810391 100644 --- a/lib/gitlab/downtime_check.rb +++ b/lib/gitlab/downtime_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Checks if a set of migrations requires downtime or not. class DowntimeCheck diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb index ee604e66154..6fc86925f81 100644 --- a/lib/gitlab/ee_compat_check.rb +++ b/lib/gitlab/ee_compat_check.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # rubocop: disable Rails/Output module Gitlab # Checks if a set of migrations requires downtime or not. diff --git a/lib/gitlab/emoji.rb b/lib/gitlab/emoji.rb index 89cf659bce4..ce1dfb0753c 100644 --- a/lib/gitlab/emoji.rb +++ b/lib/gitlab/emoji.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Emoji extend self diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb index 0f336fbaa10..a4a154c80f7 100644 --- a/lib/gitlab/encoding_helper.rb +++ b/lib/gitlab/encoding_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module EncodingHelper extend self diff --git a/lib/gitlab/environment.rb b/lib/gitlab/environment.rb index 5e0dd6e7859..b1a9603d3a5 100644 --- a/lib/gitlab/environment.rb +++ b/lib/gitlab/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Environment def self.hostname diff --git a/lib/gitlab/environment_logger.rb b/lib/gitlab/environment_logger.rb index 407cc572656..862a516ca71 100644 --- a/lib/gitlab/environment_logger.rb +++ b/lib/gitlab/environment_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class EnvironmentLogger < Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/exclusive_lease.rb b/lib/gitlab/exclusive_lease.rb index 12b5e240962..d466d2a514c 100644 --- a/lib/gitlab/exclusive_lease.rb +++ b/lib/gitlab/exclusive_lease.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'securerandom' module Gitlab diff --git a/lib/gitlab/exclusive_lease_helpers.rb b/lib/gitlab/exclusive_lease_helpers.rb index e998548cff9..4aaf2474763 100644 --- a/lib/gitlab/exclusive_lease_helpers.rb +++ b/lib/gitlab/exclusive_lease_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # This module provides helper methods which are intregrated with GitLab::ExclusiveLease module ExclusiveLeaseHelpers diff --git a/lib/gitlab/fake_application_settings.rb b/lib/gitlab/fake_application_settings.rb index 2c827265d8c..db1aeeea8d3 100644 --- a/lib/gitlab/fake_application_settings.rb +++ b/lib/gitlab/fake_application_settings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class extends an OpenStruct object by adding predicate methods to mimic # ActiveRecord access. We rely on the initial values being true or false to # determine whether to define a predicate method because for a newly-added diff --git a/lib/gitlab/favicon.rb b/lib/gitlab/favicon.rb index 050a1ad3a0b..1ae2f9dfd93 100644 --- a/lib/gitlab/favicon.rb +++ b/lib/gitlab/favicon.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Favicon class << self diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb index da62ed2fb16..4d89ee5a669 100644 --- a/lib/gitlab/file_detector.rb +++ b/lib/gitlab/file_detector.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'set' module Gitlab diff --git a/lib/gitlab/file_finder.rb b/lib/gitlab/file_finder.rb index af8270c8db8..b4db3f93c9c 100644 --- a/lib/gitlab/file_finder.rb +++ b/lib/gitlab/file_finder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class finds files in a repository by name and content # the result is joined and sorted by file name module Gitlab diff --git a/lib/gitlab/file_markdown_link_builder.rb b/lib/gitlab/file_markdown_link_builder.rb index 5386656efe7..180140e7da2 100644 --- a/lib/gitlab/file_markdown_link_builder.rb +++ b/lib/gitlab/file_markdown_link_builder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Builds the markdown link of a file # It needs the methods filename and secure_url (final destination url) to be defined. module Gitlab @@ -8,7 +10,7 @@ module Gitlab return unless name = markdown_name markdown = "[#{name.gsub(']', '\\]')}](#{secure_url})" - markdown.prepend("!") if image_or_video? || dangerous? + markdown = "!#{markdown}" if image_or_video? || dangerous? markdown end diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb index 2913a3e416d..c4aac228b2f 100644 --- a/lib/gitlab/git.rb +++ b/lib/gitlab/git.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_dependency 'gitlab/encoding_helper' module Gitlab diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 240a0d7d1b8..827c04ae035 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Check a user's access to perform a git action. All public methods in this # class return an instance of `GitlabAccessStatus` module Gitlab diff --git a/lib/gitlab/git_access_wiki.rb b/lib/gitlab/git_access_wiki.rb index a5b3902ebf4..3f24001e4ee 100644 --- a/lib/gitlab/git_access_wiki.rb +++ b/lib/gitlab/git_access_wiki.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class GitAccessWiki < GitAccess ERROR_MESSAGES = { diff --git a/lib/gitlab/git_logger.rb b/lib/gitlab/git_logger.rb index 9e02ccc0f44..dac4ddd320f 100644 --- a/lib/gitlab/git_logger.rb +++ b/lib/gitlab/git_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class GitLogger < Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb index 40636fb204e..a90b69ff42b 100644 --- a/lib/gitlab/git_ref_validator.rb +++ b/lib/gitlab/git_ref_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Gitaly note: JV: does not need to be migrated, works without a repo. module Gitlab diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 4ec87f6a3e7..d99a9f15371 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'base64' require 'gitaly' @@ -23,7 +25,7 @@ module Gitlab stacks = most_invoked_stack.join('\n') if most_invoked_stack msg = "GitalyClient##{call_site} called #{invocation_count} times from single request. Potential n+1?" - msg << "\nThe following call site called into Gitaly #{max_call_stack} times:\n#{stacks}\n" if stacks + msg = "#{msg}\nThe following call site called into Gitaly #{max_call_stack} times:\n#{stacks}\n" if stacks super(msg) end diff --git a/lib/gitlab/github_import.rb b/lib/gitlab/github_import.rb index d40b06f969f..14a6d6443ec 100644 --- a/lib/gitlab/github_import.rb +++ b/lib/gitlab/github_import.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module GithubImport def self.refmap diff --git a/lib/gitlab/gl_id.rb b/lib/gitlab/gl_id.rb index a53d156b41f..1ed842c2264 100644 --- a/lib/gitlab/gl_id.rb +++ b/lib/gitlab/gl_id.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module GlId def self.gl_id(user) diff --git a/lib/gitlab/gl_repository.rb b/lib/gitlab/gl_repository.rb index b54e45de4fe..435b74806e7 100644 --- a/lib/gitlab/gl_repository.rb +++ b/lib/gitlab/gl_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module GlRepository def self.gl_repository(project, is_wiki) diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb index c1726659a90..860c39feb64 100644 --- a/lib/gitlab/gon_helper.rb +++ b/lib/gitlab/gon_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # rubocop:disable Metrics/AbcSize module Gitlab diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb index 8a91e034377..e53c2d00743 100644 --- a/lib/gitlab/gpg.rb +++ b/lib/gitlab/gpg.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Gpg extend self diff --git a/lib/gitlab/graphql.rb b/lib/gitlab/graphql.rb index 04a89432230..74c04e5380e 100644 --- a/lib/gitlab/graphql.rb +++ b/lib/gitlab/graphql.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Graphql StandardGraphqlError = Class.new(StandardError) diff --git a/lib/gitlab/group_hierarchy.rb b/lib/gitlab/group_hierarchy.rb index 8fbfa1a86bf..c940ea7305e 100644 --- a/lib/gitlab/group_hierarchy.rb +++ b/lib/gitlab/group_hierarchy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Retrieving of parent or child groups based on a base ActiveRecord relation. # diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index 0b6cc893db1..83095acc528 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Highlight TIMEOUT_BACKGROUND = 30.seconds diff --git a/lib/gitlab/http.rb b/lib/gitlab/http.rb index 538b51c0008..bcd9e2be35f 100644 --- a/lib/gitlab/http.rb +++ b/lib/gitlab/http.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class is used as a proxy for all outbounding http connection # coming from callbacks, services and hooks. The direct use of the HTTParty # is discouraged because it can lead to several security problems, like SSRF diff --git a/lib/gitlab/http_io.rb b/lib/gitlab/http_io.rb index ce24817db54..9d7763fc5ac 100644 --- a/lib/gitlab/http_io.rb +++ b/lib/gitlab/http_io.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ## # This class is compatible with IO class (https://ruby-doc.org/core-2.3.1/IO.html) # source: https://gitlab.com/snippets/1685610 @@ -73,8 +75,8 @@ module Gitlab end end - def read(length = nil, outbuf = "") - out = "" + def read(length = nil, outbuf = nil) + out = [] length ||= size - tell @@ -90,17 +92,18 @@ module Gitlab length -= chunk_data.bytesize end + out = out.join + # If outbuf is passed, we put the output into the buffer. This supports IO.copy_stream functionality if outbuf - outbuf.slice!(0, outbuf.bytesize) - outbuf << out + outbuf.replace(out) end out end def readline - out = "" + out = [] until eof? data = get_chunk @@ -116,7 +119,7 @@ module Gitlab end end - out + out.join end def write(data) diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb index 7346eab9e76..7e0398f09af 100644 --- a/lib/gitlab/i18n.rb +++ b/lib/gitlab/i18n.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module I18n extend self diff --git a/lib/gitlab/identifier.rb b/lib/gitlab/identifier.rb index a8b93f1d4b2..28a9fe29465 100644 --- a/lib/gitlab/identifier.rb +++ b/lib/gitlab/identifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Detect user based on identifier like # key-13 or user-36 or last commit module Gitlab diff --git a/lib/gitlab/import_export.rb b/lib/gitlab/import_export.rb index 53fe2f8e436..f63a5ece71e 100644 --- a/lib/gitlab/import_export.rb +++ b/lib/gitlab/import_export.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module ImportExport extend self diff --git a/lib/gitlab/import_formatter.rb b/lib/gitlab/import_formatter.rb index 4e611e7f16c..d4ba4d1181d 100644 --- a/lib/gitlab/import_formatter.rb +++ b/lib/gitlab/import_formatter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ImportFormatter def comment(author, date, body) diff --git a/lib/gitlab/import_sources.rb b/lib/gitlab/import_sources.rb index f7f5c5787f6..f46bb837cf7 100644 --- a/lib/gitlab/import_sources.rb +++ b/lib/gitlab/import_sources.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Gitlab::ImportSources module # # Define import sources that can be used diff --git a/lib/gitlab/incoming_email.rb b/lib/gitlab/incoming_email.rb index d323cb9dadf..20fc8226611 100644 --- a/lib/gitlab/incoming_email.rb +++ b/lib/gitlab/incoming_email.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module IncomingEmail UNSUBSCRIBE_SUFFIX = '+unsubscribe'.freeze diff --git a/lib/gitlab/insecure_key_fingerprint.rb b/lib/gitlab/insecure_key_fingerprint.rb index f85b6e9197f..e4f0e9d2c73 100644 --- a/lib/gitlab/insecure_key_fingerprint.rb +++ b/lib/gitlab/insecure_key_fingerprint.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # # Calculates the fingerprint of a given key without using diff --git a/lib/gitlab/issuable_metadata.rb b/lib/gitlab/issuable_metadata.rb index 0c9de72329c..351d15605e0 100644 --- a/lib/gitlab/issuable_metadata.rb +++ b/lib/gitlab/issuable_metadata.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module IssuableMetadata def issuable_meta_data(issuable_collection, collection_type) diff --git a/lib/gitlab/issuable_sorter.rb b/lib/gitlab/issuable_sorter.rb index d392214867a..42bbfb32d0b 100644 --- a/lib/gitlab/issuable_sorter.rb +++ b/lib/gitlab/issuable_sorter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module IssuableSorter class << self diff --git a/lib/gitlab/issuables_count_for_state.rb b/lib/gitlab/issuables_count_for_state.rb index b5657a36998..659fb1472d2 100644 --- a/lib/gitlab/issuables_count_for_state.rb +++ b/lib/gitlab/issuables_count_for_state.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Class for counting and caching the number of issuables per state. class IssuablesCountForState diff --git a/lib/gitlab/issues_labels.rb b/lib/gitlab/issues_labels.rb index b8ca7f2f55f..17c9cb969df 100644 --- a/lib/gitlab/issues_labels.rb +++ b/lib/gitlab/issues_labels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class IssuesLabels class << self diff --git a/lib/gitlab/job_waiter.rb b/lib/gitlab/job_waiter.rb index f7a8eae0be4..e97e961771c 100644 --- a/lib/gitlab/job_waiter.rb +++ b/lib/gitlab/job_waiter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # JobWaiter can be used to wait for a number of Sidekiq jobs to complete. # diff --git a/lib/gitlab/json_logger.rb b/lib/gitlab/json_logger.rb index 28e258196ca..3bff77731f6 100644 --- a/lib/gitlab/json_logger.rb +++ b/lib/gitlab/json_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class JsonLogger < ::Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb index 15c5ece2350..3748fd6b5ef 100644 --- a/lib/gitlab/kubernetes.rb +++ b/lib/gitlab/kubernetes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Helper methods to do with Kubernetes network services & resources module Kubernetes diff --git a/lib/gitlab/language_detection.rb b/lib/gitlab/language_detection.rb index a41435fdb79..7600e60b904 100644 --- a/lib/gitlab/language_detection.rb +++ b/lib/gitlab/language_detection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class LanguageDetection MAX_LANGUAGES = 5 diff --git a/lib/gitlab/lazy.rb b/lib/gitlab/lazy.rb index 99594577141..d7a22aa339e 100644 --- a/lib/gitlab/lazy.rb +++ b/lib/gitlab/lazy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # A class that can be wrapped around an expensive method call so it's only # executed when actually needed. diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb index ead5d566871..fa44bd842b2 100644 --- a/lib/gitlab/lfs_token.rb +++ b/lib/gitlab/lfs_token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class LfsToken attr_accessor :actor diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 3d7c049c17f..128a5dd8936 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Logger < ::Logger def self.file_name diff --git a/lib/gitlab/mail_room.rb b/lib/gitlab/mail_room.rb index db04356a5e9..78f2d83c1af 100644 --- a/lib/gitlab/mail_room.rb +++ b/lib/gitlab/mail_room.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'yaml' require 'json' require_relative 'redis/queues' unless defined?(Gitlab::Redis::Queues) diff --git a/lib/gitlab/markup_helper.rb b/lib/gitlab/markup_helper.rb index 49285e35251..142b7d1a472 100644 --- a/lib/gitlab/markup_helper.rb +++ b/lib/gitlab/markup_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module MarkupHelper extend self diff --git a/lib/gitlab/metrics.rb b/lib/gitlab/metrics.rb index 7d63ca5627d..61ed20ad623 100644 --- a/lib/gitlab/metrics.rb +++ b/lib/gitlab/metrics.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Metrics include Gitlab::Metrics::InfluxDb diff --git a/lib/gitlab/multi_collection_paginator.rb b/lib/gitlab/multi_collection_paginator.rb index fab7a43dd30..5375077d7dc 100644 --- a/lib/gitlab/multi_collection_paginator.rb +++ b/lib/gitlab/multi_collection_paginator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class MultiCollectionPaginator attr_reader :first_collection, :second_collection, :per_page diff --git a/lib/gitlab/omniauth_initializer.rb b/lib/gitlab/omniauth_initializer.rb index f33ea0880df..e0ac9eec1f2 100644 --- a/lib/gitlab/omniauth_initializer.rb +++ b/lib/gitlab/omniauth_initializer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class OmniauthInitializer def initialize(devise_config) diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb index d09bce642b0..ce4ba9f752b 100644 --- a/lib/gitlab/optimistic_locking.rb +++ b/lib/gitlab/optimistic_locking.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module OptimisticLocking module_function diff --git a/lib/gitlab/other_markup.rb b/lib/gitlab/other_markup.rb index fc3f21233dd..bc467486eee 100644 --- a/lib/gitlab/other_markup.rb +++ b/lib/gitlab/other_markup.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Parser/renderer for markups without other special support code. module OtherMarkup diff --git a/lib/gitlab/otp_key_rotator.rb b/lib/gitlab/otp_key_rotator.rb index ca5d49eedb9..1d3200aa099 100644 --- a/lib/gitlab/otp_key_rotator.rb +++ b/lib/gitlab/otp_key_rotator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # The +otp_key_base+ param is used to encrypt the User#otp_secret attribute. # diff --git a/lib/gitlab/pages.rb b/lib/gitlab/pages.rb index 981ef8faa9a..16df0700b08 100644 --- a/lib/gitlab/pages.rb +++ b/lib/gitlab/pages.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Pages VERSION = File.read(Rails.root.join("GITLAB_PAGES_VERSION")).strip.freeze diff --git a/lib/gitlab/pages_client.rb b/lib/gitlab/pages_client.rb index 7b358a3bd1b..3626e53f84c 100644 --- a/lib/gitlab/pages_client.rb +++ b/lib/gitlab/pages_client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class PagesClient class << self diff --git a/lib/gitlab/pages_transfer.rb b/lib/gitlab/pages_transfer.rb index fb215f27cbd..a70dc826f97 100644 --- a/lib/gitlab/pages_transfer.rb +++ b/lib/gitlab/pages_transfer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class PagesTransfer < ProjectTransfer def root_dir diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb index a78314afdb2..44025650de0 100644 --- a/lib/gitlab/path_regex.rb +++ b/lib/gitlab/path_regex.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module PathRegex extend self diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb index fda61000f6a..4b0c7b5c7f8 100644 --- a/lib/gitlab/performance_bar.rb +++ b/lib/gitlab/performance_bar.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module PerformanceBar ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids:v2'.freeze diff --git a/lib/gitlab/plugin.rb b/lib/gitlab/plugin.rb index 0d1cb16b378..23353f36025 100644 --- a/lib/gitlab/plugin.rb +++ b/lib/gitlab/plugin.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Plugin def self.files diff --git a/lib/gitlab/plugin_logger.rb b/lib/gitlab/plugin_logger.rb index c4f6ec3e21d..df3bd56fd2f 100644 --- a/lib/gitlab/plugin_logger.rb +++ b/lib/gitlab/plugin_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class PluginLogger < Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/polling_interval.rb b/lib/gitlab/polling_interval.rb index fe4bdfe3831..0f69990df63 100644 --- a/lib/gitlab/polling_interval.rb +++ b/lib/gitlab/polling_interval.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class PollingInterval HEADER_NAME = 'Poll-Interval'.freeze diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index d0cb7c1a7cf..7fa00d0c68c 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'fileutils' require 'open3' @@ -11,7 +13,7 @@ module Gitlab def popen(cmd, path = nil, vars = {}, &block) result = popen_with_detail(cmd, path, vars, &block) - [result.stdout << result.stderr, result.status&.exitstatus] + ["#{result.stdout}#{result.stderr}", result.status&.exitstatus] end # Returns Result diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index 15391b1330b..4a62f367835 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -1,4 +1,6 @@ # coding: utf-8 +# frozen_string_literal: true + module Gitlab module Profiler FILTERED_STRING = '[FILTERED]'.freeze diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb index 71e9cc7f238..3a202d915e3 100644 --- a/lib/gitlab/project_search_results.rb +++ b/lib/gitlab/project_search_results.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ProjectSearchResults < SearchResults attr_reader :project, :repository_ref @@ -57,7 +59,8 @@ module Gitlab ref = nil filename = nil basename = nil - data = "" + + data = [] startline = 0 result.each_line.each_with_index do |line, index| @@ -78,7 +81,7 @@ module Gitlab basename: basename, ref: ref, startline: startline, - data: data, + data: data.join, project_id: project ? project.id : nil ) end diff --git a/lib/gitlab/project_service_logger.rb b/lib/gitlab/project_service_logger.rb index e84dca97962..9b0357d3161 100644 --- a/lib/gitlab/project_service_logger.rb +++ b/lib/gitlab/project_service_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ProjectServiceLogger < Gitlab::JsonLogger def self.file_name_noext diff --git a/lib/gitlab/project_template.rb b/lib/gitlab/project_template.rb index 08f6a54776f..3bfd6ee892c 100644 --- a/lib/gitlab/project_template.rb +++ b/lib/gitlab/project_template.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ProjectTemplate attr_reader :title, :name, :description, :preview diff --git a/lib/gitlab/project_transfer.rb b/lib/gitlab/project_transfer.rb index 690c38737c0..d8f1d1e2316 100644 --- a/lib/gitlab/project_transfer.rb +++ b/lib/gitlab/project_transfer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # This class is used to move local, unhashed files owned by projects to their new location class ProjectTransfer diff --git a/lib/gitlab/prometheus_client.rb b/lib/gitlab/prometheus_client.rb index b66253a10e0..45828c77a33 100644 --- a/lib/gitlab/prometheus_client.rb +++ b/lib/gitlab/prometheus_client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Helper methods to interact with Prometheus network services & resources class PrometheusClient diff --git a/lib/gitlab/protocol_access.rb b/lib/gitlab/protocol_access.rb index 2819c7d062c..efeb1e07d49 100644 --- a/lib/gitlab/protocol_access.rb +++ b/lib/gitlab/protocol_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module ProtocolAccess def self.allowed?(protocol) diff --git a/lib/gitlab/proxy_http_connection_adapter.rb b/lib/gitlab/proxy_http_connection_adapter.rb index d682289b632..82213098672 100644 --- a/lib/gitlab/proxy_http_connection_adapter.rb +++ b/lib/gitlab/proxy_http_connection_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class is part of the Gitlab::HTTP wrapper. Depending on the value # of the global setting allow_local_requests_from_hooks_and_services this adapter # will allow/block connection to internal IPs and/or urls. diff --git a/lib/gitlab/query_limiting.rb b/lib/gitlab/query_limiting.rb index 9f69a9e4a39..31e6b120e45 100644 --- a/lib/gitlab/query_limiting.rb +++ b/lib/gitlab/query_limiting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module QueryLimiting # Returns true if we should enable tracking of query counts. diff --git a/lib/gitlab/recaptcha.rb b/lib/gitlab/recaptcha.rb index c9efa28d7e7..6559c3e3c57 100644 --- a/lib/gitlab/recaptcha.rb +++ b/lib/gitlab/recaptcha.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Recaptcha def self.load_configurations! diff --git a/lib/gitlab/reference_counter.rb b/lib/gitlab/reference_counter.rb index bb26f1b610a..d2dbc6f5ef5 100644 --- a/lib/gitlab/reference_counter.rb +++ b/lib/gitlab/reference_counter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ReferenceCounter REFERENCE_EXPIRE_TIME = 600 diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb index 9ff82d628c0..00f817c2399 100644 --- a/lib/gitlab/reference_extractor.rb +++ b/lib/gitlab/reference_extractor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Extract possible GFM references from an arbitrary String for further processing. class ReferenceExtractor < Banzai::ReferenceExtractor diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 0f26fcfe8cb..7a1a2eaf6c0 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Regex extend self diff --git a/lib/gitlab/repo_path.rb b/lib/gitlab/repo_path.rb index 4888184403c..202d310e237 100644 --- a/lib/gitlab/repo_path.rb +++ b/lib/gitlab/repo_path.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module RepoPath NotFoundError = Class.new(StandardError) diff --git a/lib/gitlab/repository_cache.rb b/lib/gitlab/repository_cache.rb index a03ce07b6a1..56007574b1b 100644 --- a/lib/gitlab/repository_cache.rb +++ b/lib/gitlab/repository_cache.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Interface to the Redis-backed cache store module Gitlab class RepositoryCache @@ -6,7 +8,7 @@ module Gitlab def initialize(repository, extra_namespace: nil, backend: Rails.cache) @repository = repository @namespace = "#{repository.full_path}:#{repository.project.id}" - @namespace += ":#{extra_namespace}" if extra_namespace + @namespace = "#{@namespace}:#{extra_namespace}" if extra_namespace @backend = backend end diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb index d95024fccf7..931298b5117 100644 --- a/lib/gitlab/repository_cache_adapter.rb +++ b/lib/gitlab/repository_cache_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module RepositoryCacheAdapter extend ActiveSupport::Concern diff --git a/lib/gitlab/repository_check_logger.rb b/lib/gitlab/repository_check_logger.rb index 485b596ca57..e90b0a002af 100644 --- a/lib/gitlab/repository_check_logger.rb +++ b/lib/gitlab/repository_check_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class RepositoryCheckLogger < Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/request_context.rb b/lib/gitlab/request_context.rb index 8562d4515aa..f8f8ec789ce 100644 --- a/lib/gitlab/request_context.rb +++ b/lib/gitlab/request_context.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class RequestContext class << self diff --git a/lib/gitlab/request_forgery_protection.rb b/lib/gitlab/request_forgery_protection.rb index a502ad8a541..b1e478093d3 100644 --- a/lib/gitlab/request_forgery_protection.rb +++ b/lib/gitlab/request_forgery_protection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # A module to check CSRF tokens in requests. # It's used in API helpers and OmniAuth. # Usage: GitLab::RequestForgeryProtection.call(env) diff --git a/lib/gitlab/request_profiler.rb b/lib/gitlab/request_profiler.rb index 0c9ab759e81..64593153686 100644 --- a/lib/gitlab/request_profiler.rb +++ b/lib/gitlab/request_profiler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'fileutils' module Gitlab diff --git a/lib/gitlab/route_map.rb b/lib/gitlab/route_map.rb index f3952657983..a555bf1d812 100644 --- a/lib/gitlab/route_map.rb +++ b/lib/gitlab/route_map.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class RouteMap FormatError = Class.new(StandardError) diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb index 2c994536060..3b05f181ed2 100644 --- a/lib/gitlab/routing.rb +++ b/lib/gitlab/routing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Routing extend ActiveSupport::Concern @@ -47,7 +49,7 @@ module Gitlab # # `request.fullpath` includes the querystring new_path = request.path.sub(%r{/#{path}(/*)(?!.*#{path})}, "/-/#{path}\\1") - new_path << "?#{request.query_string}" if request.query_string.present? + new_path = "#{new_path}?#{request.query_string}" if request.query_string.present? new_path end diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb index d1cf8e10228..5ce3eda2ccb 100644 --- a/lib/gitlab/search_results.rb +++ b/lib/gitlab/search_results.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class SearchResults class FoundBlob diff --git a/lib/gitlab/seeder.rb b/lib/gitlab/seeder.rb index 98f005cb61b..84a51773276 100644 --- a/lib/gitlab/seeder.rb +++ b/lib/gitlab/seeder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # :nocov: module DeliverNever def deliver_later diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb index 6381e94c1d2..24e3866128b 100644 --- a/lib/gitlab/sentry.rb +++ b/lib/gitlab/sentry.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Sentry def self.enabled? diff --git a/lib/gitlab/setup_helper.rb b/lib/gitlab/setup_helper.rb index 5b68e4470cd..4a745147858 100644 --- a/lib/gitlab/setup_helper.rb +++ b/lib/gitlab/setup_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'toml-rb' module Gitlab diff --git a/lib/gitlab/shard_health_cache.rb b/lib/gitlab/shard_health_cache.rb index 3f03f46d4b1..6612347438e 100644 --- a/lib/gitlab/shard_health_cache.rb +++ b/lib/gitlab/shard_health_cache.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class ShardHealthCache HEALTHY_SHARDS_KEY = 'gitlab-healthy-shards'.freeze diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index 89d2028d7b0..16c1edb2f11 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Gitaly note: SSH key operations are not part of Gitaly so will never be migrated. require 'securerandom' diff --git a/lib/gitlab/shell_adapter.rb b/lib/gitlab/shell_adapter.rb index 053dd4ab9e0..59fc6ee8dc8 100644 --- a/lib/gitlab/shell_adapter.rb +++ b/lib/gitlab/shell_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # == GitLab Shell mixin # # Provide a shortcut to Gitlab::Shell instance by gitlab_shell diff --git a/lib/gitlab/sherlock.rb b/lib/gitlab/sherlock.rb index 6360527a7aa..a1471c9de47 100644 --- a/lib/gitlab/sherlock.rb +++ b/lib/gitlab/sherlock.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'securerandom' module Gitlab diff --git a/lib/gitlab/sidekiq_config.rb b/lib/gitlab/sidekiq_config.rb index c3d7814551c..01f60a98ad8 100644 --- a/lib/gitlab/sidekiq_config.rb +++ b/lib/gitlab/sidekiq_config.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'yaml' require 'set' diff --git a/lib/gitlab/sidekiq_logger.rb b/lib/gitlab/sidekiq_logger.rb index c1dab87a432..ce82a6f04bb 100644 --- a/lib/gitlab/sidekiq_logger.rb +++ b/lib/gitlab/sidekiq_logger.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class SidekiqLogger < Gitlab::Logger def self.file_name_noext diff --git a/lib/gitlab/sidekiq_status.rb b/lib/gitlab/sidekiq_status.rb index a1f689d94d9..583a970bf4e 100644 --- a/lib/gitlab/sidekiq_status.rb +++ b/lib/gitlab/sidekiq_status.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # The SidekiqStatus module and its child classes can be used for checking if a # Sidekiq job has been processed or not. diff --git a/lib/gitlab/sidekiq_versioning.rb b/lib/gitlab/sidekiq_versioning.rb index 9683214ec18..8164a5a9d7a 100644 --- a/lib/gitlab/sidekiq_versioning.rb +++ b/lib/gitlab/sidekiq_versioning.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module SidekiqVersioning def self.install! diff --git a/lib/gitlab/snippet_search_results.rb b/lib/gitlab/snippet_search_results.rb index 95e37dfbdab..e360b552f89 100644 --- a/lib/gitlab/snippet_search_results.rb +++ b/lib/gitlab/snippet_search_results.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class SnippetSearchResults < SearchResults include SnippetsHelper diff --git a/lib/gitlab/ssh_public_key.rb b/lib/gitlab/ssh_public_key.rb index 6f63ea91ae8..47571239b5c 100644 --- a/lib/gitlab/ssh_public_key.rb +++ b/lib/gitlab/ssh_public_key.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class SSHPublicKey Technology = Struct.new(:name, :key_class, :supported_sizes) @@ -26,7 +28,7 @@ module Gitlab return key_content if parts.empty? - parts.each_with_object("#{ssh_type} ").with_index do |(part, content), index| + parts.each_with_object(+"#{ssh_type} ").with_index do |(part, content), index| content << part if Gitlab::SSHPublicKey.new(content).valid? diff --git a/lib/gitlab/string_placeholder_replacer.rb b/lib/gitlab/string_placeholder_replacer.rb index 9a2219b7d77..62621255a53 100644 --- a/lib/gitlab/string_placeholder_replacer.rb +++ b/lib/gitlab/string_placeholder_replacer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class StringPlaceholderReplacer # This method accepts the following paras diff --git a/lib/gitlab/string_range_marker.rb b/lib/gitlab/string_range_marker.rb index c6ad997a4d4..780fe4c7725 100644 --- a/lib/gitlab/string_range_marker.rb +++ b/lib/gitlab/string_range_marker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class StringRangeMarker attr_accessor :raw_line, :rich_line, :html_escaped diff --git a/lib/gitlab/string_regex_marker.rb b/lib/gitlab/string_regex_marker.rb index 1c87c56c45e..f1982ff914c 100644 --- a/lib/gitlab/string_regex_marker.rb +++ b/lib/gitlab/string_regex_marker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class StringRegexMarker < StringRangeMarker # rubocop: disable CodeReuse/ActiveRecord diff --git a/lib/gitlab/task_helpers.rb b/lib/gitlab/task_helpers.rb index 922418966e9..224bb648d8f 100644 --- a/lib/gitlab/task_helpers.rb +++ b/lib/gitlab/task_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rainbow/ext/string' require 'gitlab/utils/strong_memoize' @@ -39,7 +41,7 @@ module Gitlab File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1] end - os_name.try(:squish!) + os_name.try(:squish) end # Prompt the user to input something diff --git a/lib/gitlab/tcp_checker.rb b/lib/gitlab/tcp_checker.rb index 6e24e46d0ea..f37a044b607 100644 --- a/lib/gitlab/tcp_checker.rb +++ b/lib/gitlab/tcp_checker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class TcpChecker attr_reader :remote_host, :remote_port, :local_host, :local_port, :error diff --git a/lib/gitlab/template_helper.rb b/lib/gitlab/template_helper.rb index fc498dde723..b0e01697a66 100644 --- a/lib/gitlab/template_helper.rb +++ b/lib/gitlab/template_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module TemplateHelper def prepare_template_environment(file) diff --git a/lib/gitlab/temporarily_allow.rb b/lib/gitlab/temporarily_allow.rb index 8d7dacc6c54..000f8ca699d 100644 --- a/lib/gitlab/temporarily_allow.rb +++ b/lib/gitlab/temporarily_allow.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module TemporarilyAllow TEMPORARILY_ALLOW_MUTEX = Mutex.new diff --git a/lib/gitlab/themes.rb b/lib/gitlab/themes.rb index 694b01b272c..63860b9cb26 100644 --- a/lib/gitlab/themes.rb +++ b/lib/gitlab/themes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # Module containing GitLab's application theme definitions and helper methods # for accessing them. diff --git a/lib/gitlab/time_tracking_formatter.rb b/lib/gitlab/time_tracking_formatter.rb index d615c24149a..cc206010e74 100644 --- a/lib/gitlab/time_tracking_formatter.rb +++ b/lib/gitlab/time_tracking_formatter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module TimeTrackingFormatter extend self diff --git a/lib/gitlab/timeless.rb b/lib/gitlab/timeless.rb index 76a1808c8ac..4f974c98c71 100644 --- a/lib/gitlab/timeless.rb +++ b/lib/gitlab/timeless.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Timeless def self.timeless(model, &block) diff --git a/lib/gitlab/tree_summary.rb b/lib/gitlab/tree_summary.rb index c2955cd374c..453d78e2f7b 100644 --- a/lib/gitlab/tree_summary.rb +++ b/lib/gitlab/tree_summary.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class TreeSummary include ::Gitlab::Utils::StrongMemoize diff --git a/lib/gitlab/untrusted_regexp.rb b/lib/gitlab/untrusted_regexp.rb index dc2d91dfa23..ba1137313d8 100644 --- a/lib/gitlab/untrusted_regexp.rb +++ b/lib/gitlab/untrusted_regexp.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab # An untrusted regular expression is any regexp containing patterns sourced # from user input. diff --git a/lib/gitlab/update_path_error.rb b/lib/gitlab/update_path_error.rb index 8947ecfb92e..bc066bf4143 100644 --- a/lib/gitlab/update_path_error.rb +++ b/lib/gitlab/update_path_error.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab UpdatePathError = Class.new(StandardError) end diff --git a/lib/gitlab/upgrader.rb b/lib/gitlab/upgrader.rb index 024be6aca44..ccab0e4dd73 100644 --- a/lib/gitlab/upgrader.rb +++ b/lib/gitlab/upgrader.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class Upgrader def execute diff --git a/lib/gitlab/uploads_transfer.rb b/lib/gitlab/uploads_transfer.rb index 7d7400bdabf..e0e7084e27e 100644 --- a/lib/gitlab/uploads_transfer.rb +++ b/lib/gitlab/uploads_transfer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class UploadsTransfer < ProjectTransfer def root_dir diff --git a/lib/gitlab/url_blocker.rb b/lib/gitlab/url_blocker.rb index 3b483f27e70..7735b736689 100644 --- a/lib/gitlab/url_blocker.rb +++ b/lib/gitlab/url_blocker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'resolv' module Gitlab diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb index e64033b0dba..f86d599e4cb 100644 --- a/lib/gitlab/url_builder.rb +++ b/lib/gitlab/url_builder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class UrlBuilder include Gitlab::Routing diff --git a/lib/gitlab/url_sanitizer.rb b/lib/gitlab/url_sanitizer.rb index 29672d68cad..035268bc4f2 100644 --- a/lib/gitlab/url_sanitizer.rb +++ b/lib/gitlab/url_sanitizer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class UrlSanitizer ALLOWED_SCHEMES = %w[http https ssh git].freeze diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 5097c3253c9..cc0817bdcd2 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class UsageData class << self diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb index 27560abfb96..980a8014409 100644 --- a/lib/gitlab/user_access.rb +++ b/lib/gitlab/user_access.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class UserAccess extend Gitlab::Cache::RequestCache diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index aeda66763e8..2c92458f777 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab module Utils extend self diff --git a/lib/gitlab/version_info.rb b/lib/gitlab/version_info.rb index 6ee41e85cc9..aa6d5310161 100644 --- a/lib/gitlab/version_info.rb +++ b/lib/gitlab/version_info.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class VersionInfo include Comparable diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb index 2612208a927..a3c7de87765 100644 --- a/lib/gitlab/visibility_level.rb +++ b/lib/gitlab/visibility_level.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Gitlab::VisibilityLevel module # # Define allowed public modes that can be used for diff --git a/lib/gitlab/wiki_file_finder.rb b/lib/gitlab/wiki_file_finder.rb index f97278f05cd..a00cd65594c 100644 --- a/lib/gitlab/wiki_file_finder.rb +++ b/lib/gitlab/wiki_file_finder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitlab class WikiFileFinder < FileFinder attr_reader :repository diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb index 30a8c3578d8..e1f777e9cd1 100644 --- a/lib/gitlab/workhorse.rb +++ b/lib/gitlab/workhorse.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'base64' require 'json' require 'securerandom' @@ -63,7 +65,7 @@ module Gitlab def send_git_archive(repository, ref:, format:, append_sha:) format ||= 'tar.gz' - format.downcase! + format = format.downcase params = repository.archive_metadata(ref, Gitlab.config.gitlab.repository_downloads_path, format, append_sha: append_sha) raise "Repository or ref not found" if params.empty? |