Commit ebf98f27 authored by gfyoung's avatar gfyoung 🤔

Enable even more frozen string in lib/gitlab

Enables frozen string for the following:

* lib/gitlab/fogbugz_import/**/*.rb
* lib/gitlab/gfm/**/*.rb
* lib/gitlab/git/**/*.rb
* lib/gitlab/gitaly_client/**/*.rb
* lib/gitlab/gitlab_import/**/*.rb
* lib/gitlab/google_code_import/**/*.rb
* lib/gitlab/gpg/**/*.rb
* lib/gitlab/grape_logging/**/*.rb
* lib/gitlab/graphql/**/*.rb
* lib/gitlab/graphs/**/*.rb
* lib/gitlab/hashed_storage/**/*.rb
* lib/gitlab/health_checks/**/*.rb

Partially address gitlab-org/gitlab-ce#47424.
parent 132e6c9f
---
title: Enable even more frozen string in lib/gitlab/**/*.rb
merge_request:
author: gfyoung
type: performance
# frozen_string_literal: true
require 'fogbugz'
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module FogbugzImport
class Importer
......
# frozen_string_literal: true
module Gitlab
module FogbugzImport
class ProjectCreator
......
# frozen_string_literal: true
module Gitlab
module FogbugzImport
class Repository
......
# frozen_string_literal: true
module Gitlab
module Gfm
##
......
# frozen_string_literal: true
require 'fileutils'
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Git
# Parses root .gitattributes file at a given ref
......
# frozen_string_literal: true
module Gitlab
module Git
# Class for parsing Git attribute files and extracting the attributes for
......
# frozen_string_literal: true
module Gitlab
module Git
class Blame
......
# frozen_string_literal: true
# Gitaly note: JV: seems to be completely migrated (behind feature flags).
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Git
class Branch < Ref
......
# frozen_string_literal: true
# Gitlab::Git::Commit is a wrapper around Gitaly::GitCommit
module Gitlab
module Git
......
# frozen_string_literal: true
# Gitlab::Git::CommitStats counts the additions, deletions, and total changes
# in a commit.
module Gitlab
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here.
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Git
module Conflict
......
# frozen_string_literal: true
module Gitlab
module Git
module Conflict
......
# frozen_string_literal: true
module Gitlab
module Git
module Conflict
......
# frozen_string_literal: true
module Gitlab
module Git
module Conflict
......
# frozen_string_literal: true
module Gitlab
module Git
class Diff
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here.
module Gitlab
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here.
module Gitlab
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here.
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Git
class Index
......
# frozen_string_literal: true
module Gitlab
module Git
class LfsChanges
......
# frozen_string_literal: true
module Gitlab
module Git
class LfsPointerFile
......
# frozen_string_literal: true
module Gitlab
module Git
class OperationService
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here.
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Git
#
......
# frozen_string_literal: true
module Gitlab
module Git
# This class behaves like a struct with fields :blob_id, :blob_size, :operation, :old_path, :new_path
......
# frozen_string_literal: true
module Gitlab
module Git
class Ref
......
# frozen_string_literal: true
module Gitlab
module Git
class RemoteMirror
......
# frozen_string_literal: true
module Gitlab
module Git
#
......
# frozen_string_literal: true
require 'tempfile'
require 'forwardable'
require "rubygems/package"
......
# frozen_string_literal: true
module Gitlab
module Git
module RepositoryMirroring
......
# frozen_string_literal: true
module Gitlab
module Git
class Tag < Ref
......
# frozen_string_literal: true
module Gitlab
module Git
class Tree
......
# frozen_string_literal: true
module Gitlab
module Git
class User
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here.
module Gitlab
......
# frozen_string_literal: true
module Gitlab
module Git
module Version
......
# frozen_string_literal: true
module Gitlab
module Git
class Wiki
......
# frozen_string_literal: true
module Gitlab
module Git
class WikiFile
......
# frozen_string_literal: true
module Gitlab
module Git
class WikiPage
......
# frozen_string_literal: true
module Gitlab
module Git
class WikiPageVersion
......
# frozen_string_literal: true
module Gitlab
module Git
module WrapsGitalyErrors
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
# This module expects an `ATTRS` const to be defined on the subclass
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class BlobService
......@@ -15,7 +17,7 @@ module Gitlab
)
response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_blob, request, timeout: GitalyClient.fast_timeout)
data = ''
data = []
blob = nil
response.each do |msg|
if blob.nil?
......@@ -27,6 +29,8 @@ module Gitlab
return nil if blob.oid.blank?
data = data.join
Gitlab::Git::Blob.new(
id: blob.oid,
size: blob.size,
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class BlobsStitcher
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class CommitService
......@@ -93,7 +95,7 @@ module Gitlab
response = GitalyClient.call(@repository.storage, :commit_service, :tree_entry, request, timeout: GitalyClient.medium_timeout)
entry = nil
data = ''
data = []
response.each do |msg|
if entry.nil?
entry = msg
......@@ -103,7 +105,7 @@ module Gitlab
data << msg.data
end
entry.data = data
entry.data = data.join
entry unless entry.oid.blank?
end
......@@ -254,7 +256,7 @@ module Gitlab
)
response = GitalyClient.call(@repository.storage, :commit_service, :raw_blame, request, timeout: GitalyClient.medium_timeout)
response.reduce("") { |memo, msg| memo << msg.data }
response.reduce([]) { |memo, msg| memo << msg.data }.join
end
def find_commit(revision)
......@@ -345,8 +347,8 @@ module Gitlab
request = Gitaly::ExtractCommitSignatureRequest.new(repository: @gitaly_repo, commit_id: commit_id)
response = GitalyClient.call(@repository.storage, :commit_service, :extract_commit_signature, request)
signature = ''.b
signed_text = ''.b
signature = +''.b
signed_text = +''.b
response.each do |message|
signature << message.signature
......@@ -364,7 +366,7 @@ module Gitlab
request = Gitaly::GetCommitSignaturesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids)
response = GitalyClient.call(@repository.storage, :commit_service, :get_commit_signatures, request, timeout: GitalyClient.fast_timeout)
signatures = Hash.new { |h, k| h[k] = [''.b, ''.b] }
signatures = Hash.new { |h, k| h[k] = [+''.b, +''.b] }
current_commit_id = nil
response.each do |message|
......@@ -383,7 +385,7 @@ module Gitlab
request = Gitaly::GetCommitMessagesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids)
response = GitalyClient.call(@repository.storage, :commit_service, :get_commit_messages, request, timeout: GitalyClient.fast_timeout)
messages = Hash.new { |h, k| h[k] = ''.b }
messages = Hash.new { |h, k| h[k] = +''.b }
current_commit_id = nil
response.each do |rpc_message|
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class ConflictFilesStitcher
......@@ -17,7 +19,7 @@ module Gitlab
current_file = file_from_gitaly_header(gitaly_file.header)
else
current_file.raw_content << gitaly_file.content
current_file.raw_content = "#{current_file.raw_content}#{gitaly_file.content}"
end
end
end
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class ConflictsService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class Diff
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class DiffStitcher
......@@ -20,7 +22,7 @@ module Gitlab
current_diff = GitalyClient::Diff.new(diff_params)
else
current_diff.patch += diff_msg.raw_patch_data
current_diff.patch = "#{current_diff.patch}#{diff_msg.raw_patch_data}"
end
if diff_msg.end_of_patch
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class HealthCheckService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class NamespaceService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class NotificationService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class OperationService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class QueueEnumerator
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class RefService
......@@ -218,7 +220,7 @@ module Gitlab
request = Gitaly::GetTagMessagesRequest.new(repository: @gitaly_repo, tag_ids: tag_ids)
response = GitalyClient.call(@repository.storage, :ref_service, :get_tag_messages, request, timeout: GitalyClient.fast_timeout)
messages = Hash.new { |h, k| h[k] = ''.b }
messages = Hash.new { |h, k| h[k] = +''.b }
current_tag_id = nil
response.each do |rpc_message|
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class RemoteService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class RepositoryService
......@@ -56,9 +58,9 @@ module Gitlab
request = Gitaly::GetInfoAttributesRequest.new(repository: @gitaly_repo)
response = GitalyClient.call(@storage, :repository_service, :get_info_attributes, request, timeout: GitalyClient.fast_timeout)
response.each_with_object("") do |message, attributes|
response.each_with_object([]) do |message, attributes|
attributes << message.attributes
end
end.join
end
def fetch_remote(remote, ssh_auth:, forced:, no_tags:, timeout:, prune: true)
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
# Meant for extraction of server data, and later maybe to perform misc task
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class StorageService
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
# This is a chokepoint that is meant to help us stop remove all places
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
module Util
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class WikiFile
......
# frozen_string_literal: true
module Gitlab
module GitalyClient
class WikiPage
......
# frozen_string_literal: true
require 'stringio'
module Gitlab
......@@ -139,7 +141,7 @@ module Gitlab
next unless message.name.present? || wiki_file
if wiki_file
wiki_file.raw_data << message.raw_data
wiki_file.raw_data = "#{wiki_file.raw_data}#{message.raw_data}"
else
wiki_file = GitalyClient::WikiFile.new(message.to_h)
# All gRPC strings in a response are frozen, so we get
......@@ -160,7 +162,7 @@ module Gitlab
)
response = GitalyClient.call(@repository.storage, :wiki_service, :wiki_get_formatted_data, request)
response.reduce("") { |memo, msg| memo << msg.data }
response.reduce([]) { |memo, msg| memo << msg.data }.join
end
private
......
# frozen_string_literal: true
module Gitlab
module GitlabImport
class Client
......
# frozen_string_literal: true
module Gitlab
module GitlabImport
class Importer
......@@ -22,22 +24,22 @@ module Gitlab
issues = client.issues(project_identifier)
issues.each do |issue|
body = @formatter.author_line(issue["author"]["name"])
body += issue["description"]
body = [@formatter.author_line(issue["author"]["name"])]
body << issue["description"]
comments = client.issue_comments(project_identifier, issue["iid"])
if comments.any?
body += @formatter.comments_header
body << @formatter.comments_header
end
comments.each do |comment|
body += @formatter.comment(comment["author"]["name"], comment["created_at"], comment["body"])
body << @formatter.comment(comment["author"]["name"], comment["created_at"], comment["body"])
end
project.issues.create!(
iid: issue["iid"],
description: body,
description: body.join,
title: issue["title"],
state: issue["state"],
updated_at: issue["updated_at"],
......
# frozen_string_literal: true
module Gitlab
module GitlabImport
class ProjectCreator
......
# frozen_string_literal: true
module Gitlab
module GoogleCodeImport
class Client
......
# frozen_string_literal: true
module Gitlab
module GoogleCodeImport
class Importer
......
# frozen_string_literal: true
module Gitlab
module GoogleCodeImport
class ProjectCreator
......
# frozen_string_literal: true
module Gitlab
module GoogleCodeImport
class Repository
......