Commit c858f70d authored by gfyoung's avatar gfyoung 🤔 Committed by Rémy Coutable

Enable frozen string for lib/gitlab/*.rb

parent 173b1436
---
title: Enable frozen string for lib/gitlab/*.rb
merge_request:
author: gfyoung
type: performance
......@@ -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)
......
# frozen_string_literal: true
# Gitlab::Access module
#
# Define allowed roles that can be used
......
# 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
......
# frozen_string_literal: true
module Gitlab
module Allowable
def can?(*args)
......
# frozen_string_literal: true
module Gitlab
class AppLogger < Gitlab::Logger
def self.file_name_noext
......
# frozen_string_literal: true
require 'asciidoctor'
require 'asciidoctor/converter/html5'
require "asciidoctor-plantuml"
......
# frozen_string_literal: true
module Gitlab
module Auth
MissingPersonalAccessTokenError = Class.new(StandardError)
......
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
def self.queue
......
# frozen_string_literal: true
# This is a base controller for doorkeeper.
# It adds the `can?` helper used in the views.
module Gitlab
......
# frozen_string_literal: true
module Gitlab
class Blame
attr_accessor :blob, :commit
......
# 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
......
# frozen_string_literal: true
module Gitlab
class BuildAccess < UserAccess
attr_accessor :user, :project
......
# frozen_string_literal: true
module Gitlab
class ChangesList
include Enumerable
......
# frozen_string_literal: true
require 'json'
module Gitlab
......
# 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.
......
# frozen_string_literal: true
module Gitlab
class ClosingIssueExtractor
ISSUE_CLOSING_REGEX = begin
......
# frozen_string_literal: true
module Gitlab
# Module containing GitLab's syntax color scheme definitions and helper
# methods for accessing them.
......
# frozen_string_literal: true
module Gitlab::ConfigHelper
def gitlab_config_features
Gitlab.config.gitlab.default_projects_features
......
# frozen_string_literal: true
module Gitlab
class ContributionsCalendar
attr_reader :contributor
......
# frozen_string_literal: true
module Gitlab
class Contributor
attr_accessor :email, :name, :commits, :additions, :deletions
......
# frozen_string_literal: true
module Gitlab
class CrossProjectAccess
class << self
......
# frozen_string_literal: true
module Gitlab
module CurrentSettings
class << self
......
# frozen_string_literal: true
module Gitlab
class Daemon
def self.initialize_instance(*args)
......
# 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)
......
# frozen_string_literal: true
module Gitlab
module DependencyLinker
LINKERS = [
......
# frozen_string_literal: true
module Gitlab
# Checks if a set of migrations requires downtime or not.
class DowntimeCheck
......
# frozen_string_literal: true
# rubocop: disable Rails/Output
module Gitlab
# Checks if a set of migrations requires downtime or not.
......
# frozen_string_literal: true
module Gitlab
module Emoji
extend self
......
# frozen_string_literal: true
module Gitlab
module EncodingHelper
extend self
......
# frozen_string_literal: true
module Gitlab
module Environment
def self.hostname
......
# frozen_string_literal: true
module Gitlab
class EnvironmentLogger < Gitlab::Logger
def self.file_name_noext
......
# frozen_string_literal: true
require 'securerandom'
module Gitlab
......
# frozen_string_literal: true
module Gitlab
# This module provides helper methods which are intregrated with GitLab::ExclusiveLease
module ExclusiveLeaseHelpers
......
# 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
......
# frozen_string_literal: true
module Gitlab
class Favicon
class << self
......
# frozen_string_literal: true
require 'set'
module Gitlab
......
# 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
......
# 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
......
# frozen_string_literal: true
require_dependency 'gitlab/encoding_helper'
module Gitlab
......
# 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
......
# frozen_string_literal: true
module Gitlab
class GitAccessWiki < GitAccess
ERROR_MESSAGES = {
......
# frozen_string_literal: true
module Gitlab
class GitLogger < Gitlab::Logger
def self.file_name_noext
......
# frozen_string_literal: true
# Gitaly note: JV: does not need to be migrated, works without a repo.
module Gitlab
......
# 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
......
# frozen_string_literal: true
module Gitlab
module GithubImport
def self.refmap
......
# frozen_string_literal: true
module Gitlab
module GlId
def self.gl_id(user)
......
# frozen_string_literal: true
module Gitlab
module GlRepository
def self.gl_repository(project, is_wiki)
......
# frozen_string_literal: true
# rubocop:disable Metrics/AbcSize
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Gpg
extend self
......
# frozen_string_literal: true
module Gitlab
module Graphql
StandardGraphqlError = Class.new(StandardError)
......
# frozen_string_literal: true
module Gitlab
# Retrieving of parent or child groups based on a base ActiveRecord relation.
#
......
# frozen_string_literal: true
module Gitlab
class Highlight
TIMEOUT_BACKGROUND = 30.seconds
......
# 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
......
# 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)
......
# frozen_string_literal: true
module Gitlab
module I18n
extend self
......
# frozen_string_literal: true
# Detect user based on identifier like
# key-13 or user-36 or last commit
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module ImportExport
extend self
......
# frozen_string_literal: true
module Gitlab
class ImportFormatter
def comment(author, date, body)
......
# frozen_string_literal: true
# Gitlab::ImportSources module
#
# Define import sources that can be used
......
# frozen_string_literal: true
module Gitlab
module IncomingEmail
UNSUBSCRIBE_SUFFIX = '+unsubscribe'.freeze
......
# frozen_string_literal: true
module Gitlab
#
# Calculates the fingerprint of a given key without using
......
# frozen_string_literal: true
module Gitlab
module IssuableMetadata
def issuable_meta_data(issuable_collection, collection_type)
......
# frozen_string_literal: true
module Gitlab
module IssuableSorter
class << self
......
# frozen_string_literal: true
module Gitlab
# Class for counting and caching the number of issuables per state.
class IssuablesCountForState
......
# frozen_string_literal: true
module Gitlab
class IssuesLabels
class << self
......
# frozen_string_literal: true
module Gitlab
# JobWaiter can be used to wait for a number of Sidekiq jobs to complete.
#
......
# frozen_string_literal: true
module Gitlab
class JsonLogger < ::Gitlab::Logger
def self.file_name_noext
......
# frozen_string_literal: true
module Gitlab
# Helper methods to do with Kubernetes network services & resources
module Kubernetes
......
# frozen_string_literal: true
module Gitlab
class LanguageDetection
MAX_LANGUAGES = 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.
......
# frozen_string_literal: true
module Gitlab
class LfsToken
attr_accessor :actor
......
# frozen_string_literal: true
module Gitlab
class Logger < ::Logger
def self.file_name
......
# frozen_string_literal: true
require 'yaml'
require 'json'
require_relative 'redis/queues' unless defined?(Gitlab::Redis::Queues)
......
# frozen_string_literal: true
module Gitlab
module MarkupHelper
extend self
......
# frozen_string_literal: true
module Gitlab
module Metrics
include Gitlab::Metrics::InfluxDb
......
# frozen_string_literal: true
module Gitlab
class MultiCollectionPaginator
attr_reader :first_collection, :second_collection, :per_page
......
# frozen_string_literal: true
module Gitlab
class OmniauthInitializer
def initialize(devise_config)
......
# frozen_string_literal: true
module Gitlab
module OptimisticLocking
module_function
......
# frozen_string_literal: true
module Gitlab
# Parser/renderer for markups without other special support code.
module OtherMarkup
......
# frozen_string_literal: true
module Gitlab
# The +otp_key_base+ param is used to encrypt the User#otp_secret attribute.
#
......
# frozen_string_literal: true
module Gitlab
module Pages
VERSION = File.read(Rails.root.join("GITLAB_PAGES_VERSION")).strip.freeze
......
# frozen_string_literal: true
module Gitlab
class PagesClient
class << self
......
# frozen_string_literal: true
module Gitlab
class PagesTransfer < ProjectTransfer
def root_dir
......
# frozen_string_literal: true
module Gitlab
module PathRegex
extend self
......
# frozen_string_literal: true
module Gitlab
module PerformanceBar
ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids:v2'.freeze
......
# frozen_string_literal: true
module Gitlab
module Plugin
def self.files
......
# frozen_string_literal: true
module Gitlab
class PluginLogger < Gitlab::Logger
def self.file_name_noext
......
# frozen_string_literal: true
module Gitlab
class PollingInterval
HEADER_NAME = 'Poll-Interval'.freeze
......
# 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