Commit 7e6f6e16 authored by gfyoung's avatar gfyoung

Enable even more frozen string in lib/gitlab

Enables frozens string for the following:

* lib/gitlab/conflict/**/*.rb
* lib/gitlab/cross_project_access/**/*.rb
* lib/gitlab/cycle_analytics/**/*.rb
* lib/gitlab/data_builder/**/*.rb
* lib/gitlab/database/**/*.rb
* lib/gitlab/dependency_linker/**/*.rb
* lib/gitlab/diff/**/*.rb
* lib/gitlab/downtime_check/**/*.rb
* lib/gitlab/email/**/*.rb
* lib/gitlab/etag_caching/**/*.rb

Partially addresses gitlab-org/gitlab-ce#47424.
parent 68cb1e23
---
title: Enable even more frozen string in lib/gitlab/**/*.rb
merge_request:
author: gfyoung
type: performance
# frozen_string_literal: true
module Gitlab module Gitlab
module Conflict module Conflict
class File class File
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Conflict module Conflict
class FileCollection class FileCollection
......
# frozen_string_literal: true
module Gitlab module Gitlab
class CrossProjectAccess class CrossProjectAccess
class CheckCollection class CheckCollection
......
# frozen_string_literal: true
module Gitlab module Gitlab
class CrossProjectAccess class CrossProjectAccess
class CheckInfo class CheckInfo
......
# frozen_string_literal: true
module Gitlab module Gitlab
class CrossProjectAccess class CrossProjectAccess
module ClassMethods module ClassMethods
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class BaseEventFetcher class BaseEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module BaseQuery module BaseQuery
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class BaseStage class BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class CodeEventFetcher < BaseEventFetcher class CodeEventFetcher < BaseEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class CodeStage < BaseStage class CodeStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module EventFetcher module EventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class IssueEventFetcher < BaseEventFetcher class IssueEventFetcher < BaseEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class IssueStage < BaseStage class IssueStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module MetricsTables module MetricsTables
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class Permissions class Permissions
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class PlanEventFetcher < BaseEventFetcher class PlanEventFetcher < BaseEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class PlanStage < BaseStage class PlanStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ProductionEventFetcher < IssueEventFetcher class ProductionEventFetcher < IssueEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module ProductionHelper module ProductionHelper
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ProductionStage < BaseStage class ProductionStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ReviewEventFetcher < BaseEventFetcher class ReviewEventFetcher < BaseEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ReviewStage < BaseStage class ReviewStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Stage module Stage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StageSummary class StageSummary
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StagingEventFetcher < BaseEventFetcher class StagingEventFetcher < BaseEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StagingStage < BaseStage class StagingStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class TestEventFetcher < StagingEventFetcher class TestEventFetcher < StagingEventFetcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class TestStage < BaseStage class TestStage < BaseStage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class Updater class Updater
......
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class UsageData class UsageData
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Build module Build
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Note module Note
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Pipeline module Pipeline
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Push module Push
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Repository module Repository
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module WikiPage module WikiPage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module ArelMethods module ArelMethods
......
# frozen_string_literal: true
# For large tables, PostgreSQL can take a long time to count rows due to MVCC. # For large tables, PostgreSQL can take a long time to count rows due to MVCC.
# We can optimize this by using the reltuples count as described in https://wiki.postgresql.org/wiki/Slow_Counting. # We can optimize this by using the reltuples count as described in https://wiki.postgresql.org/wiki/Slow_Counting.
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module DateTime module DateTime
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
# Model that can be used for querying permissions of a SQL user. # Model that can be used for querying permissions of a SQL user.
......
# frozen_string_literal: true
# https://www.periscopedata.com/blog/medians-in-sql.html # https://www.periscopedata.com/blog/medians-in-sql.html
module Gitlab module Gitlab
module Database module Database
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module MigrationHelpers module MigrationHelpers
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module MultiThreadedMigration module MultiThreadedMigration
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
# Module that can be injected into a ActiveRecord::Relation to make it # Module that can be injected into a ActiveRecord::Relation to make it
......
# frozen_string_literal: true
# This module can be included in migrations to make it easier to rename paths # This module can be included in migrations to make it easier to rename paths
# of `Namespace` & `Project` models certain paths would become `reserved`. # of `Namespace` & `Project` models certain paths would become `reserved`.
# #
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
BINARY_TYPE = BINARY_TYPE =
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class BaseLinker class BaseLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class CartfileLinker < MethodLinker class CartfileLinker < MethodLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
module Cocoapods module Cocoapods
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class ComposerJsonLinker < PackageJsonLinker class ComposerJsonLinker < PackageJsonLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class GemfileLinker < MethodLinker class GemfileLinker < MethodLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class GemspecLinker < MethodLinker class GemspecLinker < MethodLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class GodepsJsonLinker < JsonLinker class GodepsJsonLinker < JsonLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class JsonLinker < BaseLinker class JsonLinker < BaseLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class MethodLinker < BaseLinker class MethodLinker < BaseLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PackageJsonLinker < JsonLinker class PackageJsonLinker < JsonLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PodfileLinker < GemfileLinker class PodfileLinker < GemfileLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PodspecJsonLinker < JsonLinker class PodspecJsonLinker < JsonLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PodspecLinker < MethodLinker class PodspecLinker < MethodLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class RequirementsTxtLinker < BaseLinker class RequirementsTxtLinker < BaseLinker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class DiffRefs class DiffRefs
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class File class File
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module Formatters module Formatters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module Formatters module Formatters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module Formatters module Formatters
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class Highlight class Highlight
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class ImagePoint class ImagePoint
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class InlineDiff class InlineDiff
...@@ -71,7 +73,7 @@ module Gitlab ...@@ -71,7 +73,7 @@ module Gitlab
def find_changed_line_pairs(lines) def find_changed_line_pairs(lines)
# Prefixes of all diff lines, indicating their types # Prefixes of all diff lines, indicating their types
# For example: `" - + -+ ---+++ --+ -++"` # For example: `" - + -+ ---+++ --+ -++"`
line_prefixes = lines.each_with_object("") { |line, s| s << (line[0] || ' ') }.gsub(/[^ +-]/, ' ') line_prefixes = lines.each_with_object(+"") { |line, s| s << (line[0] || ' ') }.gsub(/[^ +-]/, ' ')
changed_line_pairs = [] changed_line_pairs = []
line_prefixes.scan(LINE_PAIRS_PATTERN) do line_prefixes.scan(LINE_PAIRS_PATTERN) do
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class InlineDiffMarkdownMarker < Gitlab::StringRangeMarker class InlineDiffMarkdownMarker < Gitlab::StringRangeMarker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class InlineDiffMarker < Gitlab::StringRangeMarker class InlineDiffMarker < Gitlab::StringRangeMarker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class Line class Line
......
# frozen_string_literal: true
# When provided a diff for a specific file, maps old line numbers to new line # When provided a diff for a specific file, maps old line numbers to new line
# numbers and back, to find out where a specific line in a file was moved by the # numbers and back, to find out where a specific line in a file was moved by the
# changes. # changes.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class ParallelDiff class ParallelDiff
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class Parser class Parser
......
# frozen_string_literal: true
# Defines a specific location, identified by paths line numbers and image coordinates, # Defines a specific location, identified by paths line numbers and image coordinates,
# within a specific diff, identified by start, head and base commit ids. # within a specific diff, identified by start, head and base commit ids.
module Gitlab module Gitlab
......
# frozen_string_literal: true
# Finds the diff position in the new diff that corresponds to the same location # Finds the diff position in the new diff that corresponds to the same location
# specified by the provided position in the old diff. # specified by the provided position in the old diff.
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
class DowntimeCheck class DowntimeCheck
class Message class Message
...@@ -18,13 +20,13 @@ module Gitlab ...@@ -18,13 +20,13 @@ module Gitlab
def to_s def to_s
label = offline ? OFFLINE : ONLINE label = offline ? OFFLINE : ONLINE
message = "[#{label}]: #{path}" message = ["[#{label}]: #{path}"]
if reason? if reason?
message += ":\n\n#{reason}\n\n" message << ":\n\n#{reason}\n\n"
end end
message message.join
end end
def reason? def reason?
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
class AttachmentUploader class AttachmentUploader
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
class HTMLParser class HTMLParser
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Message module Message
...@@ -116,7 +118,7 @@ module Gitlab ...@@ -116,7 +118,7 @@ module Gitlab
end end
def subject def subject
subject_text = '[Git]' subject_text = ['[Git]']
subject_text << "[#{project.full_path}]" subject_text << "[#{project.full_path}]"
subject_text << "[#{ref_name}]" if @action == :push subject_text << "[#{ref_name}]" if @action == :push
subject_text << ' ' subject_text << ' '
...@@ -134,6 +136,8 @@ module Gitlab ...@@ -134,6 +136,8 @@ module Gitlab
subject_action[0] = subject_action[0].capitalize subject_action[0] = subject_action[0].capitalize
subject_text << "#{subject_action} #{ref_type} #{ref_name}" subject_text << "#{subject_action} #{ref_type} #{ref_name}"
end end
subject_text.join
end end
end end
end end
......
# frozen_string_literal: true
require_dependency 'gitlab/email/handler' require_dependency 'gitlab/email/handler'
# Inspired in great part by Discourse's Email::Receiver # Inspired in great part by Discourse's Email::Receiver
......
# frozen_string_literal: true
# Inspired in great part by Discourse's Email::Receiver # Inspired in great part by Discourse's Email::Receiver
module Gitlab module Gitlab
module Email module Email
......
# frozen_string_literal: true
module Gitlab module Gitlab
module EtagCaching module EtagCaching
class Middleware class Middleware
......
# frozen_string_literal: true
module Gitlab module Gitlab
module EtagCaching module EtagCaching
class Router class Router
......
# frozen_string_literal: true
module Gitlab module Gitlab
module EtagCaching module EtagCaching
class Store class Store
......
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