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 Conflict
class File

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab
module Database
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.
# We can optimize this by using the reltuples count as described in https://wiki.postgresql.org/wiki/Slow_Counting.
module Gitlab

View file

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

View file

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

View file

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

View file

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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab
module Database
# 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
# of `Namespace` & `Project` models certain paths would become `reserved`.
#

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab
module Diff
class InlineDiff
@ -71,7 +73,7 @@ module Gitlab
def find_changed_line_pairs(lines)
# Prefixes of all diff lines, indicating their types
# 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 = []
line_prefixes.scan(LINE_PAIRS_PATTERN) do

View file

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

View file

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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab
module Diff
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
# numbers and back, to find out where a specific line in a file was moved by the
# changes.

View file

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

View file

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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Defines a specific location, identified by paths line numbers and image coordinates,
# within a specific diff, identified by start, head and base commit ids.
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
# specified by the provided position in the old diff.
module Gitlab

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab
class DowntimeCheck
class Message
@ -18,13 +20,13 @@ module Gitlab
def to_s
label = offline ? OFFLINE : ONLINE
message = "[#{label}]: #{path}"
message = ["[#{label}]: #{path}"]
if reason?
message += ":\n\n#{reason}\n\n"
message << ":\n\n#{reason}\n\n"
end
message
message.join
end
def reason?

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Gitlab
module Email
module Message
@ -116,7 +118,7 @@ module Gitlab
end
def subject
subject_text = '[Git]'
subject_text = ['[Git]']
subject_text << "[#{project.full_path}]"
subject_text << "[#{ref_name}]" if @action == :push
subject_text << ' '
@ -134,6 +136,8 @@ module Gitlab
subject_action[0] = subject_action[0].capitalize
subject_text << "#{subject_action} #{ref_type} #{ref_name}"
end
subject_text.join
end
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'gitlab/email/handler'
# 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
module Gitlab
module Email

View file

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

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