Commit 6494467a authored by Stan Hu's avatar Stan Hu

Merge branch 'frozen-string-lib-gitlab-even-more' into 'master'

Enable even more frozen string in lib/gitlab

See merge request gitlab-org/gitlab-ce!22959
parents 1d165305 ebf98f27
---
title: Enable even more frozen string in lib/gitlab/**/*.rb
merge_request:
author: gfyoung
type: performance
# frozen_string_literal: true
require 'fogbugz' require 'fogbugz'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module FogbugzImport module FogbugzImport
class Importer class Importer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module FogbugzImport module FogbugzImport
class ProjectCreator class ProjectCreator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module FogbugzImport module FogbugzImport
class Repository class Repository
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Gfm module Gfm
## ##
......
# frozen_string_literal: true
require 'fileutils' require 'fileutils'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
# Parses root .gitattributes file at a given ref # Parses root .gitattributes file at a given ref
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
# Class for parsing Git attribute files and extracting the attributes for # Class for parsing Git attribute files and extracting the attributes for
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Blame class Blame
......
# frozen_string_literal: true
# Gitaly note: JV: seems to be completely migrated (behind feature flags). # Gitaly note: JV: seems to be completely migrated (behind feature flags).
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Branch < Ref class Branch < Ref
......
# frozen_string_literal: true
# Gitlab::Git::Commit is a wrapper around Gitaly::GitCommit # Gitlab::Git::Commit is a wrapper around Gitaly::GitCommit
module Gitlab module Gitlab
module Git module Git
......
# frozen_string_literal: true
# Gitlab::Git::CommitStats counts the additions, deletions, and total changes # Gitlab::Git::CommitStats counts the additions, deletions, and total changes
# in a commit. # in a commit.
module Gitlab module Gitlab
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here. # Gitaly note: JV: no RPC's here.
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module Conflict module Conflict
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module Conflict module Conflict
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module Conflict module Conflict
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module Conflict module Conflict
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Diff class Diff
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here. # Gitaly note: JV: no RPC's here.
module Gitlab module Gitlab
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here. # Gitaly note: JV: no RPC's here.
module Gitlab module Gitlab
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here. # Gitaly note: JV: no RPC's here.
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Index class Index
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class LfsChanges class LfsChanges
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class LfsPointerFile class LfsPointerFile
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class OperationService class OperationService
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here. # Gitaly note: JV: no RPC's here.
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
# #
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
# This class behaves like a struct with fields :blob_id, :blob_size, :operation, :old_path, :new_path # This class behaves like a struct with fields :blob_id, :blob_size, :operation, :old_path, :new_path
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Ref class Ref
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class RemoteMirror class RemoteMirror
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
# #
......
# frozen_string_literal: true
require 'tempfile' require 'tempfile'
require 'forwardable' require 'forwardable'
require "rubygems/package" require "rubygems/package"
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module RepositoryMirroring module RepositoryMirroring
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Tag < Ref class Tag < Ref
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Tree class Tree
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class User class User
......
# frozen_string_literal: true
# Gitaly note: JV: no RPC's here. # Gitaly note: JV: no RPC's here.
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module Version module Version
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class Wiki class Wiki
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class WikiFile class WikiFile
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class WikiPage class WikiPage
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
class WikiPageVersion class WikiPageVersion
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Git module Git
module WrapsGitalyErrors module WrapsGitalyErrors
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
# This module expects an `ATTRS` const to be defined on the subclass # This module expects an `ATTRS` const to be defined on the subclass
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class BlobService class BlobService
...@@ -15,7 +17,7 @@ module Gitlab ...@@ -15,7 +17,7 @@ module Gitlab
) )
response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_blob, request, timeout: GitalyClient.fast_timeout) response = GitalyClient.call(@gitaly_repo.storage_name, :blob_service, :get_blob, request, timeout: GitalyClient.fast_timeout)
data = '' data = []
blob = nil blob = nil
response.each do |msg| response.each do |msg|
if blob.nil? if blob.nil?
...@@ -27,6 +29,8 @@ module Gitlab ...@@ -27,6 +29,8 @@ module Gitlab
return nil if blob.oid.blank? return nil if blob.oid.blank?
data = data.join
Gitlab::Git::Blob.new( Gitlab::Git::Blob.new(
id: blob.oid, id: blob.oid,
size: blob.size, size: blob.size,
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class BlobsStitcher class BlobsStitcher
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class CommitService class CommitService
...@@ -93,7 +95,7 @@ module Gitlab ...@@ -93,7 +95,7 @@ module Gitlab
response = GitalyClient.call(@repository.storage, :commit_service, :tree_entry, request, timeout: GitalyClient.medium_timeout) response = GitalyClient.call(@repository.storage, :commit_service, :tree_entry, request, timeout: GitalyClient.medium_timeout)
entry = nil entry = nil
data = '' data = []
response.each do |msg| response.each do |msg|
if entry.nil? if entry.nil?
entry = msg entry = msg
...@@ -103,7 +105,7 @@ module Gitlab ...@@ -103,7 +105,7 @@ module Gitlab
data << msg.data data << msg.data
end end
entry.data = data entry.data = data.join
entry unless entry.oid.blank? entry unless entry.oid.blank?
end end
...@@ -254,7 +256,7 @@ module Gitlab ...@@ -254,7 +256,7 @@ module Gitlab
) )
response = GitalyClient.call(@repository.storage, :commit_service, :raw_blame, request, timeout: GitalyClient.medium_timeout) 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 end
def find_commit(revision) def find_commit(revision)
...@@ -345,8 +347,8 @@ module Gitlab ...@@ -345,8 +347,8 @@ module Gitlab
request = Gitaly::ExtractCommitSignatureRequest.new(repository: @gitaly_repo, commit_id: commit_id) request = Gitaly::ExtractCommitSignatureRequest.new(repository: @gitaly_repo, commit_id: commit_id)
response = GitalyClient.call(@repository.storage, :commit_service, :extract_commit_signature, request) response = GitalyClient.call(@repository.storage, :commit_service, :extract_commit_signature, request)
signature = ''.b signature = +''.b
signed_text = ''.b signed_text = +''.b
response.each do |message| response.each do |message|
signature << message.signature signature << message.signature
...@@ -364,7 +366,7 @@ module Gitlab ...@@ -364,7 +366,7 @@ module Gitlab
request = Gitaly::GetCommitSignaturesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids) 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) 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 current_commit_id = nil
response.each do |message| response.each do |message|
...@@ -383,7 +385,7 @@ module Gitlab ...@@ -383,7 +385,7 @@ module Gitlab
request = Gitaly::GetCommitMessagesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids) 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) 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 current_commit_id = nil
response.each do |rpc_message| response.each do |rpc_message|
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class ConflictFilesStitcher class ConflictFilesStitcher
...@@ -17,7 +19,7 @@ module Gitlab ...@@ -17,7 +19,7 @@ module Gitlab
current_file = file_from_gitaly_header(gitaly_file.header) current_file = file_from_gitaly_header(gitaly_file.header)
else else
current_file.raw_content << gitaly_file.content current_file.raw_content = "#{current_file.raw_content}#{gitaly_file.content}"
end end
end end
end end
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class ConflictsService class ConflictsService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class Diff class Diff
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class DiffStitcher class DiffStitcher
...@@ -20,7 +22,7 @@ module Gitlab ...@@ -20,7 +22,7 @@ module Gitlab
current_diff = GitalyClient::Diff.new(diff_params) current_diff = GitalyClient::Diff.new(diff_params)
else else
current_diff.patch += diff_msg.raw_patch_data current_diff.patch = "#{current_diff.patch}#{diff_msg.raw_patch_data}"
end end
if diff_msg.end_of_patch if diff_msg.end_of_patch
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class HealthCheckService class HealthCheckService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class NamespaceService class NamespaceService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class NotificationService class NotificationService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class OperationService class OperationService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class QueueEnumerator class QueueEnumerator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class RefService class RefService
...@@ -218,7 +220,7 @@ module Gitlab ...@@ -218,7 +220,7 @@ module Gitlab
request = Gitaly::GetTagMessagesRequest.new(repository: @gitaly_repo, tag_ids: tag_ids) 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) 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 current_tag_id = nil
response.each do |rpc_message| response.each do |rpc_message|
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class RemoteService class RemoteService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class RepositoryService class RepositoryService
...@@ -56,9 +58,9 @@ module Gitlab ...@@ -56,9 +58,9 @@ module Gitlab
request = Gitaly::GetInfoAttributesRequest.new(repository: @gitaly_repo) request = Gitaly::GetInfoAttributesRequest.new(repository: @gitaly_repo)
response = GitalyClient.call(@storage, :repository_service, :get_info_attributes, request, timeout: GitalyClient.fast_timeout) 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 attributes << message.attributes
end end.join
end end
def fetch_remote(remote, ssh_auth:, forced:, no_tags:, timeout:, prune: true) def fetch_remote(remote, ssh_auth:, forced:, no_tags:, timeout:, prune: true)
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
# Meant for extraction of server data, and later maybe to perform misc task # Meant for extraction of server data, and later maybe to perform misc task
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class StorageService class StorageService
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
# This is a chokepoint that is meant to help us stop remove all places # This is a chokepoint that is meant to help us stop remove all places
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
module Util module Util
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class WikiFile class WikiFile
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitalyClient module GitalyClient
class WikiPage class WikiPage
......
# frozen_string_literal: true
require 'stringio' require 'stringio'
module Gitlab module Gitlab
...@@ -139,7 +141,7 @@ module Gitlab ...@@ -139,7 +141,7 @@ module Gitlab
next unless message.name.present? || wiki_file next unless message.name.present? || wiki_file
if wiki_file if wiki_file
wiki_file.raw_data << message.raw_data wiki_file.raw_data = "#{wiki_file.raw_data}#{message.raw_data}"
else else
wiki_file = GitalyClient::WikiFile.new(message.to_h) wiki_file = GitalyClient::WikiFile.new(message.to_h)
# All gRPC strings in a response are frozen, so we get # All gRPC strings in a response are frozen, so we get
...@@ -160,7 +162,7 @@ module Gitlab ...@@ -160,7 +162,7 @@ module Gitlab
) )
response = GitalyClient.call(@repository.storage, :wiki_service, :wiki_get_formatted_data, request) 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 end
private private
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitlabImport module GitlabImport
class Client class Client
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitlabImport module GitlabImport
class Importer class Importer
...@@ -22,22 +24,22 @@ module Gitlab ...@@ -22,22 +24,22 @@ module Gitlab
issues = client.issues(project_identifier) issues = client.issues(project_identifier)
issues.each do |issue| issues.each do |issue|
body = @formatter.author_line(issue["author"]["name"]) body = [@formatter.author_line(issue["author"]["name"])]
body += issue["description"] body << issue["description"]
comments = client.issue_comments(project_identifier, issue["iid"]) comments = client.issue_comments(project_identifier, issue["iid"])
if comments.any? if comments.any?
body += @formatter.comments_header body << @formatter.comments_header
end end
comments.each do |comment| 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 end
project.issues.create!( project.issues.create!(
iid: issue["iid"], iid: issue["iid"],
description: body, description: body.join,
title: issue["title"], title: issue["title"],
state: issue["state"], state: issue["state"],
updated_at: issue["updated_at"], updated_at: issue["updated_at"],
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GitlabImport module GitlabImport
class ProjectCreator class ProjectCreator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GoogleCodeImport module GoogleCodeImport
class Client class Client
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GoogleCodeImport module GoogleCodeImport
class Importer class Importer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GoogleCodeImport module GoogleCodeImport
class ProjectCreator class ProjectCreator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GoogleCodeImport module GoogleCodeImport
class Repository class Repository
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Gpg module Gpg
class Commit class Commit
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Gpg module Gpg
class InvalidGpgSignatureUpdater class InvalidGpgSignatureUpdater
......
# frozen_string_literal: true
module Gitlab module Gitlab
module GrapeLogging module GrapeLogging
module Formatters module Formatters
......
# frozen_string_literal: true
# This grape_logging module (https://github.com/aserafin/grape_logging) makes it # This grape_logging module (https://github.com/aserafin/grape_logging) makes it
# possible to log how much time an API request was queued by Workhorse. # possible to log how much time an API request was queued by Workhorse.
module Gitlab module Gitlab
......
# frozen_string_literal: true
# This grape_logging module (https://github.com/aserafin/grape_logging) makes it # This grape_logging module (https://github.com/aserafin/grape_logging) makes it
# possible to log the user who performed the Grape API action by retrieving # possible to log the user who performed the Grape API action by retrieving
# the user context from the request environment. # the user context from the request environment.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
# Allow fields to declare permissions their objects must have. The field # Allow fields to declare permissions their objects must have. The field
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Authorize module Authorize
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Authorize module Authorize
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Connections module Connections
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Connections module Connections
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Errors module Errors
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module ExposePermissions module ExposePermissions
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Present module Present
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
module Present module Present
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphql module Graphql
class Variables class Variables
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Graphs module Graphs
class Commits class Commits
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HashedStorage module HashedStorage
# Hashed Storage Migrator # Hashed Storage Migrator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HashedStorage module HashedStorage
module RakeHelper module RakeHelper
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HealthChecks module HealthChecks
module BaseAbstractCheck module BaseAbstractCheck
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HealthChecks module HealthChecks
class DbCheck class DbCheck
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HealthChecks module HealthChecks
class GitalyCheck class GitalyCheck
......
module Gitlab::HealthChecks # rubocop:disable Naming/FileName # rubocop:disable Naming/FileName
# frozen_string_literal: true
module Gitlab::HealthChecks
Metric = Struct.new(:name, :value, :labels) Metric = Struct.new(:name, :value, :labels)
end end
# frozen_string_literal: true
module Gitlab module Gitlab
module HealthChecks module HealthChecks
class PrometheusTextFormat class PrometheusTextFormat
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HealthChecks module HealthChecks
module Redis module Redis
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HealthChecks module HealthChecks
module Redis module Redis
......
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