Commit f93f8f56 authored by gfyoung's avatar gfyoung

Enable even more frozen string for lib/gitlab

Enables frozen string for the following:

* lib/gitlab/patch/**/*.rb
* lib/gitlab/popen/**/*.rb
* lib/gitlab/profiler/**/*.rb
* lib/gitlab/project_authorizations/**/*.rb
* lib/gitlab/prometheus/**/*.rb
* lib/gitlab/query_limiting/**/*.rb
* lib/gitlab/quick_actions/**/*.rb
* lib/gitlab/redis/**/*.rb
* lib/gitlab/request_profiler/**/*.rb
* lib/gitlab/search/**/*.rb
* lib/gitlab/sherlock/**/*.rb
* lib/gitlab/sidekiq_middleware/**/*.rb
* lib/gitlab/slash_commands/**/*.rb
* lib/gitlab/sql/**/*.rb
* lib/gitlab/template/**/*.rb
* lib/gitlab/testing/**/*.rb
* lib/gitlab/utils/**/*.rb
* lib/gitlab/webpack/**/*.rb

Partially addresses gitlab-org/gitlab-ce#47424.
parent 60261d9d
---
title: Enable even more frozen string for lib/gitlab
merge_request:
author: gfyoung
type: performance
# frozen_string_literal: true
module Gitlab module Gitlab
module Ci module Ci
class Config class Config
......
# frozen_string_literal: true
# Inspired by https://github.com/peek/peek-pg/blob/master/lib/peek/views/pg.rb # Inspired by https://github.com/peek/peek-pg/blob/master/lib/peek/views/pg.rb
# PEEK_DB_CLIENT is a constant set in config/initializers/peek.rb # PEEK_DB_CLIENT is a constant set in config/initializers/peek.rb
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Popen module Popen
class Runner class Runner
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Profiler module Profiler
class TotalTimeFlatPrinter < RubyProf::FlatPrinter class TotalTimeFlatPrinter < RubyProf::FlatPrinter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ProjectAuthorizations module ProjectAuthorizations
# Calculating new project authorizations when supporting nested groups. # Calculating new project authorizations when supporting nested groups.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ProjectAuthorizations module ProjectAuthorizations
# Calculating new project authorizations when not supporting nested groups. # Calculating new project authorizations when not supporting nested groups.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module AdditionalMetricsParser module AdditionalMetricsParser
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
class Metric class Metric
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
class MetricGroup class MetricGroup
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
ParsingError = Class.new(StandardError) ParsingError = Class.new(StandardError)
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Prometheus module Prometheus
module Queries module Queries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QueryLimiting module QueryLimiting
class ActiveSupportSubscriber < ActiveSupport::Subscriber class ActiveSupportSubscriber < ActiveSupport::Subscriber
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QueryLimiting module QueryLimiting
class Transaction class Transaction
...@@ -68,7 +70,7 @@ module Gitlab ...@@ -68,7 +70,7 @@ module Gitlab
def error_message def error_message
header = 'Too many SQL queries were executed' header = 'Too many SQL queries were executed'
header += " in #{action}" if action header = "#{header} in #{action}" if action
"#{header}: a maximum of #{THRESHOLD} is allowed but #{count} SQL queries were executed" "#{header}: a maximum of #{THRESHOLD} is allowed but #{count} SQL queries were executed"
end end
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QuickActions module QuickActions
class CommandDefinition class CommandDefinition
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QuickActions module QuickActions
module Dsl module Dsl
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QuickActions module QuickActions
# This class takes an array of commands that should be extracted from a # This class takes an array of commands that should be extracted from a
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QuickActions module QuickActions
# This class takes spend command argument # This class takes spend command argument
......
# frozen_string_literal: true
module Gitlab module Gitlab
module QuickActions module QuickActions
class SubstitutionDefinition < CommandDefinition class SubstitutionDefinition < CommandDefinition
......
# frozen_string_literal: true
# please require all dependencies below: # please require all dependencies below:
require_relative 'wrapper' unless defined?(::Rails) && ::Rails.root.present? require_relative 'wrapper' unless defined?(::Rails) && ::Rails.root.present?
......
# frozen_string_literal: true
# please require all dependencies below: # please require all dependencies below:
require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper) require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper)
......
# frozen_string_literal: true
# please require all dependencies below: # please require all dependencies below:
require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper) require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper)
......
# frozen_string_literal: true
# This file should only be used by sub-classes, not directly by any clients of the sub-classes # This file should only be used by sub-classes, not directly by any clients of the sub-classes
# please require all dependencies below: # please require all dependencies below:
require 'active_support/core_ext/hash/keys' require 'active_support/core_ext/hash/keys'
......
# frozen_string_literal: true
require 'ruby-prof' require 'ruby-prof'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module RequestProfiler module RequestProfiler
class Profile class Profile
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sanitizers module Sanitizers
module SVG module SVG
......
# frozen_string_literal: true
# Generated from: # Generated from:
# SVG element list: https://www.w3.org/TR/SVG/eltindex.html # SVG element list: https://www.w3.org/TR/SVG/eltindex.html
# SVG Attribute list: https://www.w3.org/TR/SVG/attindex.html # SVG Attribute list: https://www.w3.org/TR/SVG/attindex.html
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Search module Search
class ParsedQuery class ParsedQuery
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Search module Search
class Query < SimpleDelegator class Query < SimpleDelegator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Serializer module Serializer
module Ci module Ci
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Serializer module Serializer
class Pagination class Pagination
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
# A collection of transactions recorded by Sherlock. # A collection of transactions recorded by Sherlock.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
class FileSample class FileSample
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
# Class for profiling code on a per line basis. # Class for profiling code on a per line basis.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
class LineSample class LineSample
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
class Location class Location
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
# Rack middleware used for tracking request metrics. # Rack middleware used for tracking request metrics.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
class Query class Query
...@@ -48,7 +50,7 @@ module Gitlab ...@@ -48,7 +50,7 @@ module Gitlab
end end
unless @query.end_with?(';') unless @query.end_with?(';')
@query += ';' @query = "#{@query};"
end end
end end
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Sherlock module Sherlock
class Transaction class Transaction
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqLogging module SidekiqLogging
class JSONFormatter class JSONFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqLogging module SidekiqLogging
class StructuredLogger class StructuredLogger
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqMiddleware module SidekiqMiddleware
class ArgumentsLogger class ArgumentsLogger
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqMiddleware module SidekiqMiddleware
class RequestStoreMiddleware class RequestStoreMiddleware
......
# frozen_string_literal: true
require 'mutex_m' require 'mutex_m'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqStatus module SidekiqStatus
class ClientMiddleware class ClientMiddleware
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqStatus module SidekiqStatus
class ServerMiddleware class ServerMiddleware
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SidekiqVersioning module SidekiqVersioning
module Manager module Manager
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class BaseCommand class BaseCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class Command < BaseCommand class Command < BaseCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class Deploy < BaseCommand class Deploy < BaseCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class Help < BaseCommand class Help < BaseCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class IssueCommand < BaseCommand class IssueCommand < BaseCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class IssueMove < IssueCommand class IssueMove < IssueCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class IssueNew < IssueCommand class IssueNew < IssueCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class IssueSearch < IssueCommand class IssueSearch < IssueCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
class IssueShow < IssueCommand class IssueShow < IssueCommand
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# coding: utf-8 # coding: utf-8
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SlashCommands module SlashCommands
module Presenters module Presenters
...@@ -38,10 +40,10 @@ module Gitlab ...@@ -38,10 +40,10 @@ module Gitlab
end end
def text def text
message = "**#{status_text(@resource)}**" message = ["**#{status_text(@resource)}**"]
if @resource.upvotes.zero? && @resource.downvotes.zero? && @resource.user_notes_count.zero? if @resource.upvotes.zero? && @resource.downvotes.zero? && @resource.user_notes_count.zero?
return message return message.join
end end
message << " · " message << " · "
...@@ -49,7 +51,7 @@ module Gitlab ...@@ -49,7 +51,7 @@ module Gitlab
message << ":-1: #{@resource.downvotes} " unless @resource.downvotes.zero? message << ":-1: #{@resource.downvotes} " unless @resource.downvotes.zero?
message << ":speech_balloon: #{@resource.user_notes_count}" unless @resource.user_notes_count.zero? message << ":speech_balloon: #{@resource.user_notes_count}" unless @resource.user_notes_count.zero?
message message.join
end end
def pretext def pretext
......
module Gitlab # rubocop:disable Naming/FileName # rubocop:disable Naming/FileName
# frozen_string_literal: true
module Gitlab
module SlashCommands module SlashCommands
Result = Struct.new(:type, :message) Result = Struct.new(:type, :message)
end end
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SQL module SQL
# Class for easily building CTE statements. # Class for easily building CTE statements.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SQL module SQL
module Glob module Glob
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SQL module SQL
module Pattern module Pattern
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SQL module SQL
# Class for easily building recursive CTE statements. # Class for easily building recursive CTE statements.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module SQL module SQL
# Class for building SQL UNION statements. # Class for building SQL UNION statements.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
class BaseTemplate class BaseTemplate
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
class DockerfileTemplate < BaseTemplate class DockerfileTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
module Finders module Finders
......
# frozen_string_literal: true
# Searches and reads file present on GitLab installation directory # Searches and reads file present on GitLab installation directory
module Gitlab module Gitlab
module Template module Template
...@@ -21,7 +23,7 @@ module Gitlab ...@@ -21,7 +23,7 @@ module Gitlab
end end
def list_files_for(dir) def list_files_for(dir)
dir << '/' unless dir.end_with?('/') dir = "#{dir}/" unless dir.end_with?('/')
Dir.glob(File.join(dir, "*#{@extension}")).select { |f| f =~ self.class.filter_regex(@extension) } Dir.glob(File.join(dir, "*#{@extension}")).select { |f| f =~ self.class.filter_regex(@extension) }
end end
......
# frozen_string_literal: true
# Searches and reads files present on each GitLab project repository # Searches and reads files present on each GitLab project repository
module Gitlab module Gitlab
module Template module Template
...@@ -33,7 +35,7 @@ module Gitlab ...@@ -33,7 +35,7 @@ module Gitlab
def list_files_for(dir) def list_files_for(dir)
return [] unless @commit return [] unless @commit
dir << '/' unless dir.end_with?('/') dir = "#{dir}/" unless dir.end_with?('/')
entries = @repository.tree(:head, dir).entries entries = @repository.tree(:head, dir).entries
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
class GitignoreTemplate < BaseTemplate class GitignoreTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
class GitlabCiYmlTemplate < BaseTemplate class GitlabCiYmlTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
class IssueTemplate < BaseTemplate class IssueTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Template module Template
class MergeRequestTemplate < BaseTemplate class MergeRequestTemplate < BaseTemplate
......
# frozen_string_literal: true
# rubocop:disable Style/ClassVars # rubocop:disable Style/ClassVars
# This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests # This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
......
# frozen_string_literal: true
# rubocop:disable Style/ClassVars # rubocop:disable Style/ClassVars
module Gitlab module Gitlab
...@@ -35,7 +37,7 @@ module Gitlab ...@@ -35,7 +37,7 @@ module Gitlab
request_headers = env_http_headers(env) request_headers = env_http_headers(env)
status, headers, body = @app.call(env) status, headers, body = @app.call(env)
full_body = '' full_body = +''
body.each { |b| full_body << b } body.each { |b| full_body << b }
request = OpenStruct.new( request = OpenStruct.new(
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Utils module Utils
module MergeHash module MergeHash
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Utils module Utils
module Override module Override
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Utils module Utils
module StrongMemoize module StrongMemoize
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Verify module Verify
class BatchVerifier class BatchVerifier
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Verify module Verify
class JobArtifacts < BatchVerifier class JobArtifacts < BatchVerifier
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Verify module Verify
class LfsObjects < BatchVerifier class LfsObjects < BatchVerifier
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Verify module Verify
class RakeTask class RakeTask
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Verify module Verify
class Uploads < BatchVerifier class Uploads < BatchVerifier
......
# frozen_string_literal: true
module Gitlab module Gitlab
module View module View
module Presenter module Presenter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module View module View
module Presenter module Presenter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module View module View
module Presenter module Presenter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module View module View
module Presenter module Presenter
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment