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 Ci
class Config
......
# frozen_string_literal: true
# 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
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Popen
class Runner
......
# frozen_string_literal: true
module Gitlab
module Profiler
class TotalTimeFlatPrinter < RubyProf::FlatPrinter
......
# frozen_string_literal: true
module Gitlab
module ProjectAuthorizations
# Calculating new project authorizations when supporting nested groups.
......
# frozen_string_literal: true
module Gitlab
module ProjectAuthorizations
# Calculating new project authorizations when not supporting nested groups.
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module AdditionalMetricsParser
......
# frozen_string_literal: true
module Gitlab
module Prometheus
class Metric
......
# frozen_string_literal: true
module Gitlab
module Prometheus
class MetricGroup
......
# frozen_string_literal: true
module Gitlab
module Prometheus
ParsingError = Class.new(StandardError)
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module Prometheus
module Queries
......
# frozen_string_literal: true
module Gitlab
module QueryLimiting
class ActiveSupportSubscriber < ActiveSupport::Subscriber
......
# frozen_string_literal: true
module Gitlab
module QueryLimiting
class Transaction
......@@ -68,7 +70,7 @@ module Gitlab
def error_message
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"
end
......
# frozen_string_literal: true
module Gitlab
module QuickActions
class CommandDefinition
......
# frozen_string_literal: true
module Gitlab
module QuickActions
module Dsl
......
# frozen_string_literal: true
module Gitlab
module QuickActions
# This class takes an array of commands that should be extracted from a
......
# frozen_string_literal: true
module Gitlab
module QuickActions
# This class takes spend command argument
......
# frozen_string_literal: true
module Gitlab
module QuickActions
class SubstitutionDefinition < CommandDefinition
......
# frozen_string_literal: true
# please require all dependencies below:
require_relative 'wrapper' unless defined?(::Rails) && ::Rails.root.present?
......
# frozen_string_literal: true
# please require all dependencies below:
require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper)
......
# frozen_string_literal: true
# please require all dependencies below:
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
# please require all dependencies below:
require 'active_support/core_ext/hash/keys'
......
# frozen_string_literal: true
require 'ruby-prof'
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module RequestProfiler
class Profile
......
# frozen_string_literal: true
module Gitlab
module Sanitizers
module SVG
......
# frozen_string_literal: true
# Generated from:
# SVG element list: https://www.w3.org/TR/SVG/eltindex.html
# SVG Attribute list: https://www.w3.org/TR/SVG/attindex.html
......
# frozen_string_literal: true
module Gitlab
module Search
class ParsedQuery
......
# frozen_string_literal: true
module Gitlab
module Search
class Query < SimpleDelegator
......
# frozen_string_literal: true
module Gitlab
module Serializer
module Ci
......
# frozen_string_literal: true
module Gitlab
module Serializer
class Pagination
......
# frozen_string_literal: true
module Gitlab
module Sherlock
# A collection of transactions recorded by Sherlock.
......
# frozen_string_literal: true
module Gitlab
module Sherlock
class FileSample
......
# frozen_string_literal: true
module Gitlab
module Sherlock
# Class for profiling code on a per line basis.
......
# frozen_string_literal: true
module Gitlab
module Sherlock
class LineSample
......
# frozen_string_literal: true
module Gitlab
module Sherlock
class Location
......
# frozen_string_literal: true
module Gitlab
module Sherlock
# Rack middleware used for tracking request metrics.
......
# frozen_string_literal: true
module Gitlab
module Sherlock
class Query
......@@ -48,7 +50,7 @@ module Gitlab
end
unless @query.end_with?(';')
@query += ';'
@query = "#{@query};"
end
end
......
# frozen_string_literal: true
module Gitlab
module Sherlock
class Transaction
......
# frozen_string_literal: true
module Gitlab
module SidekiqLogging
class JSONFormatter
......
# frozen_string_literal: true
module Gitlab
module SidekiqLogging
class StructuredLogger
......
# frozen_string_literal: true
module Gitlab
module SidekiqMiddleware
class ArgumentsLogger
......
# frozen_string_literal: true
module Gitlab
module SidekiqMiddleware
class RequestStoreMiddleware
......
# frozen_string_literal: true
require 'mutex_m'
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module SidekiqStatus
class ClientMiddleware
......
# frozen_string_literal: true
module Gitlab
module SidekiqStatus
class ServerMiddleware
......
# frozen_string_literal: true
module Gitlab
module SidekiqVersioning
module Manager
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class BaseCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class Command < BaseCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class Deploy < BaseCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class Help < BaseCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class IssueCommand < BaseCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class IssueMove < IssueCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class IssueNew < IssueCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class IssueSearch < IssueCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
class IssueShow < IssueCommand
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# coding: utf-8
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......
# frozen_string_literal: true
module Gitlab
module SlashCommands
module Presenters
......@@ -38,10 +40,10 @@ module Gitlab
end
def text
message = "**#{status_text(@resource)}**"
message = ["**#{status_text(@resource)}**"]
if @resource.upvotes.zero? && @resource.downvotes.zero? && @resource.user_notes_count.zero?
return message
return message.join
end
message << " · "
......@@ -49,7 +51,7 @@ module Gitlab
message << ":-1: #{@resource.downvotes} " unless @resource.downvotes.zero?
message << ":speech_balloon: #{@resource.user_notes_count}" unless @resource.user_notes_count.zero?
message
message.join
end
def pretext
......
module Gitlab # rubocop:disable Naming/FileName
# rubocop:disable Naming/FileName
# frozen_string_literal: true
module Gitlab
module SlashCommands
Result = Struct.new(:type, :message)
end
......
# frozen_string_literal: true
module Gitlab
module SQL
# Class for easily building CTE statements.
......
# frozen_string_literal: true
module Gitlab
module SQL
module Glob
......
# frozen_string_literal: true
module Gitlab
module SQL
module Pattern
......
# frozen_string_literal: true
module Gitlab
module SQL
# Class for easily building recursive CTE statements.
......
# frozen_string_literal: true
module Gitlab
module SQL
# Class for building SQL UNION statements.
......
# frozen_string_literal: true
module Gitlab
module Template
class BaseTemplate
......
# frozen_string_literal: true
module Gitlab
module Template
class DockerfileTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab
module Template
module Finders
......
# frozen_string_literal: true
# Searches and reads file present on GitLab installation directory
module Gitlab
module Template
......@@ -21,7 +23,7 @@ module Gitlab
end
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) }
end
......
# frozen_string_literal: true
# Searches and reads files present on each GitLab project repository
module Gitlab
module Template
......@@ -33,7 +35,7 @@ module Gitlab
def list_files_for(dir)
return [] unless @commit
dir << '/' unless dir.end_with?('/')
dir = "#{dir}/" unless dir.end_with?('/')
entries = @repository.tree(:head, dir).entries
......
# frozen_string_literal: true
module Gitlab
module Template
class GitignoreTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab
module Template
class GitlabCiYmlTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab
module Template
class IssueTemplate < BaseTemplate
......
# frozen_string_literal: true
module Gitlab
module Template
class MergeRequestTemplate < BaseTemplate
......
# frozen_string_literal: true
# rubocop:disable Style/ClassVars
# This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
......
# frozen_string_literal: true
# rubocop:disable Style/ClassVars
module Gitlab
......@@ -35,7 +37,7 @@ module Gitlab
request_headers = env_http_headers(env)
status, headers, body = @app.call(env)
full_body = ''
full_body = +''
body.each { |b| full_body << b }
request = OpenStruct.new(
......
# frozen_string_literal: true
module Gitlab
module Utils
module MergeHash
......
# frozen_string_literal: true
module Gitlab
module Utils
module Override
......
# frozen_string_literal: true
module Gitlab
module Utils
module StrongMemoize
......
# frozen_string_literal: true
module Gitlab
module Verify
class BatchVerifier
......
# frozen_string_literal: true
module Gitlab
module Verify
class JobArtifacts < BatchVerifier
......
# frozen_string_literal: true
module Gitlab
module Verify
class LfsObjects < BatchVerifier
......
# frozen_string_literal: true
module Gitlab
module Verify
class RakeTask
......
# frozen_string_literal: true
module Gitlab
module Verify
class Uploads < BatchVerifier
......
# frozen_string_literal: true
module Gitlab
module View
module Presenter
......
# frozen_string_literal: true
module Gitlab
module View
module Presenter
......
# frozen_string_literal: true
module Gitlab
module View
module Presenter
......
# frozen_string_literal: true
module Gitlab
module View
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