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.
This commit is contained in:
gfyoung 2018-11-05 20:45:35 -08:00
parent 68cb1e2393
commit 7e6f6e1603
102 changed files with 214 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
title: Enable even more frozen string in lib/gitlab/**/*.rb
merge_request:
author: gfyoung
type: performance

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Conflict module Conflict
class File class File

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Conflict module Conflict
class FileCollection class FileCollection

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
class CrossProjectAccess class CrossProjectAccess
class CheckCollection class CheckCollection

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
class CrossProjectAccess class CrossProjectAccess
class CheckInfo class CheckInfo

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
class CrossProjectAccess class CrossProjectAccess
module ClassMethods module ClassMethods

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class BaseEventFetcher class BaseEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module BaseQuery module BaseQuery

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class BaseStage class BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class CodeEventFetcher < BaseEventFetcher class CodeEventFetcher < BaseEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class CodeStage < BaseStage class CodeStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module EventFetcher module EventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class IssueEventFetcher < BaseEventFetcher class IssueEventFetcher < BaseEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class IssueStage < BaseStage class IssueStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module MetricsTables module MetricsTables

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class Permissions class Permissions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class PlanEventFetcher < BaseEventFetcher class PlanEventFetcher < BaseEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class PlanStage < BaseStage class PlanStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ProductionEventFetcher < IssueEventFetcher class ProductionEventFetcher < IssueEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module ProductionHelper module ProductionHelper

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ProductionStage < BaseStage class ProductionStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ReviewEventFetcher < BaseEventFetcher class ReviewEventFetcher < BaseEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class ReviewStage < BaseStage class ReviewStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Stage module Stage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StageSummary class StageSummary

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StagingEventFetcher < BaseEventFetcher class StagingEventFetcher < BaseEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class StagingStage < BaseStage class StagingStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
module Summary module Summary

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class TestEventFetcher < StagingEventFetcher class TestEventFetcher < StagingEventFetcher

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class TestStage < BaseStage class TestStage < BaseStage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class Updater class Updater

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module CycleAnalytics module CycleAnalytics
class UsageData class UsageData

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Build module Build

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Note module Note

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Pipeline module Pipeline

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Push module Push

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module Repository module Repository

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DataBuilder module DataBuilder
module WikiPage module WikiPage

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module ArelMethods module ArelMethods

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module DateTime module DateTime

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module MigrationHelpers module MigrationHelpers

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module MultiThreadedMigration module MultiThreadedMigration

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# 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`.
# #

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
module RenameReservedPathsMigration module RenameReservedPathsMigration

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Database module Database
BINARY_TYPE = BINARY_TYPE =

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class BaseLinker class BaseLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class CartfileLinker < MethodLinker class CartfileLinker < MethodLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
module Cocoapods module Cocoapods

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class ComposerJsonLinker < PackageJsonLinker class ComposerJsonLinker < PackageJsonLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class GemfileLinker < MethodLinker class GemfileLinker < MethodLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class GemspecLinker < MethodLinker class GemspecLinker < MethodLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class GodepsJsonLinker < JsonLinker class GodepsJsonLinker < JsonLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class JsonLinker < BaseLinker class JsonLinker < BaseLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class MethodLinker < BaseLinker class MethodLinker < BaseLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PackageJsonLinker < JsonLinker class PackageJsonLinker < JsonLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PodfileLinker < GemfileLinker class PodfileLinker < GemfileLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PodspecJsonLinker < JsonLinker class PodspecJsonLinker < JsonLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class PodspecLinker < MethodLinker class PodspecLinker < MethodLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module DependencyLinker module DependencyLinker
class RequirementsTxtLinker < BaseLinker class RequirementsTxtLinker < BaseLinker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class DiffRefs class DiffRefs

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class File class File

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module FileCollection module FileCollection

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module Formatters module Formatters

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module Formatters module Formatters

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
module Formatters module Formatters

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class Highlight class Highlight

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class ImagePoint class ImagePoint

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class InlineDiff class InlineDiff
@ -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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class InlineDiffMarkdownMarker < Gitlab::StringRangeMarker class InlineDiffMarkdownMarker < Gitlab::StringRangeMarker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class InlineDiffMarker < Gitlab::StringRangeMarker class InlineDiffMarker < Gitlab::StringRangeMarker

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class Line class Line

View file

@ -1,3 +1,5 @@
# 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.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class ParallelDiff class ParallelDiff

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Diff module Diff
class Parser class Parser

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
class DowntimeCheck class DowntimeCheck
class Message class Message
@ -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?

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
class AttachmentUploader class AttachmentUploader

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Hook module Hook

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
class HTMLParser class HTMLParser

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module Email module Email
module Message module Message
@ -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
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

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# 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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab module Gitlab
module EtagCaching module EtagCaching
class Middleware class Middleware

Some files were not shown because too many files have changed in this diff Show more