Commit 79279f44 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'more-frozen-string-enable-lib' into 'master'

Enable more frozen string in lib/**/*.rb

See merge request gitlab-org/gitlab-ce!22174
parents 7f22bc98 d598e4fd
---
title: Enable more frozen string in lib/**/*.rb
merge_request:
author: gfyoung
type: performance
# frozen_string_literal: true
module AfterCommitQueue module AfterCommitQueue
extend ActiveSupport::Concern extend ActiveSupport::Concern
......
# frozen_string_literal: true
module Backup module Backup
Error = Class.new(StandardError) Error = Class.new(StandardError)
end end
# frozen_string_literal: true
module Banzai module Banzai
# if you need to render markdown, then you probably need to post_process as well, # if you need to render markdown, then you probably need to post_process as well,
# such as removing references that the current user doesn't have # such as removing references that the current user doesn't have
......
# frozen_string_literal: true
module Banzai module Banzai
module ColorParser module ColorParser
ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/ # 0.0..1.0 ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/ # 0.0..1.0
......
# frozen_string_literal: true
module Banzai module Banzai
module CommitRenderer module CommitRenderer
ATTRIBUTES = [:description, :title].freeze ATTRIBUTES = [:description, :title].freeze
......
# frozen_string_literal: true
module Banzai module Banzai
# Common methods for ReferenceFilters that support an optional cross-project # Common methods for ReferenceFilters that support an optional cross-project
# reference. # reference.
......
# frozen_string_literal: true
module Banzai module Banzai
module Filter module Filter
def self.[](name) def self.[](name)
......
# frozen_string_literal: true
# `CommonMark` markdown engine for GitLab's Banzai markdown filter. # `CommonMark` markdown engine for GitLab's Banzai markdown filter.
# This module is used in Banzai::Filter::MarkdownFilter. # This module is used in Banzai::Filter::MarkdownFilter.
# Used gem is `commonmarker` which is a ruby wrapper for libcmark (CommonMark parser) # Used gem is `commonmarker` which is a ruby wrapper for libcmark (CommonMark parser)
......
# frozen_string_literal: true
# `Redcarpet` markdown engine for GitLab's Banzai markdown filter. # `Redcarpet` markdown engine for GitLab's Banzai markdown filter.
# This module is used in Banzai::Filter::MarkdownFilter. # This module is used in Banzai::Filter::MarkdownFilter.
# Used gem is `redcarpet` which is a ruby library for markdown processing. # Used gem is `redcarpet` which is a ruby library for markdown processing.
......
# frozen_string_literal: true
module Banzai module Banzai
module Filter module Filter
class WikiLinkFilter < HTML::Pipeline::Filter class WikiLinkFilter < HTML::Pipeline::Filter
......
# frozen_string_literal: true
module Banzai module Banzai
class FilterArray < Array class FilterArray < Array
# Insert a value immediately after another value # Insert a value immediately after another value
......
# frozen_string_literal: true
module Banzai module Banzai
# Extract references to issuables from multiple documents # Extract references to issuables from multiple documents
......
# frozen_string_literal: true
module Banzai module Banzai
# Class for rendering multiple objects (e.g. Note instances) in a single pass, # Class for rendering multiple objects (e.g. Note instances) in a single pass,
# using +render_field+ to benefit from caching in the database. Rendering and # using +render_field+ to benefit from caching in the database. Rendering and
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
def self.[](name) def self.[](name)
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class AsciiDocPipeline < BasePipeline class AsciiDocPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class AtomPipeline < FullPipeline class AtomPipeline < FullPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class BasePipeline class BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class BroadcastMessagePipeline < DescriptionPipeline class BroadcastMessagePipeline < DescriptionPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
module CombinedPipeline module CombinedPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class CommitDescriptionPipeline < SingleLinePipeline class CommitDescriptionPipeline < SingleLinePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class DescriptionPipeline < FullPipeline class DescriptionPipeline < FullPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class EmailPipeline < FullPipeline class EmailPipeline < FullPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class FullPipeline < CombinedPipeline.new(PlainMarkdownPipeline, GfmPipeline) class FullPipeline < CombinedPipeline.new(PlainMarkdownPipeline, GfmPipeline)
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class GfmPipeline < BasePipeline class GfmPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class MarkupPipeline < BasePipeline class MarkupPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class NotePipeline < FullPipeline class NotePipeline < FullPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class PlainMarkdownPipeline < BasePipeline class PlainMarkdownPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class PostProcessPipeline < BasePipeline class PostProcessPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class PreProcessPipeline < BasePipeline class PreProcessPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class RelativeLinkPipeline < BasePipeline class RelativeLinkPipeline < BasePipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class SingleLinePipeline < GfmPipeline class SingleLinePipeline < GfmPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Pipeline module Pipeline
class WikiPipeline < FullPipeline class WikiPipeline < FullPipeline
......
# frozen_string_literal: true
module Banzai module Banzai
module Querying module Querying
module_function module_function
......
# frozen_string_literal: true
module Banzai module Banzai
# Class for removing Markdown references a certain user is not allowed to # Class for removing Markdown references a certain user is not allowed to
# view. # view.
......
# frozen_string_literal: true
module Banzai module Banzai
# Extract possible GFM references from an arbitrary String for further processing. # Extract possible GFM references from an arbitrary String for further processing.
class ReferenceExtractor class ReferenceExtractor
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
# Returns the reference parser class for the given type # Returns the reference parser class for the given type
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
# Base class for reference parsing classes. # Base class for reference parsing classes.
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class CommitParser < BaseParser class CommitParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class CommitRangeParser < BaseParser class CommitRangeParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class DirectlyAddressedUserParser < UserParser class DirectlyAddressedUserParser < UserParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
# The actual parser is implemented in the EE mixin # The actual parser is implemented in the EE mixin
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class ExternalIssueParser < BaseParser class ExternalIssueParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class IssuableParser < BaseParser class IssuableParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class IssueParser < IssuableParser class IssueParser < IssuableParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class LabelParser < BaseParser class LabelParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class MergeRequestParser < IssuableParser class MergeRequestParser < IssuableParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class MilestoneParser < BaseParser class MilestoneParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class SnippetParser < BaseParser class SnippetParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module ReferenceParser module ReferenceParser
class UserParser < BaseParser class UserParser < BaseParser
......
# frozen_string_literal: true
module Banzai module Banzai
module Renderer module Renderer
# Convert a Markdown String into an HTML-safe String of HTML # Convert a Markdown String into an HTML-safe String of HTML
......
# frozen_string_literal: true
module Banzai module Banzai
module Renderer module Renderer
module CommonMark module CommonMark
......
# frozen_string_literal: true
module Banzai module Banzai
module Renderer module Renderer
module Redcarpet module Redcarpet
......
# frozen_string_literal: true
module Banzai module Banzai
module RequestStoreReferenceCache module RequestStoreReferenceCache
def cached_call(request_store_key, cache_key, path: []) def cached_call(request_store_key, cache_key, path: [])
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
class Client class Client
attr_reader :connection attr_reader :connection
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
class Collection < Enumerator class Collection < Enumerator
def initialize(paginator) def initialize(paginator)
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
class Connection class Connection
DEFAULT_API_VERSION = '2.0'.freeze DEFAULT_API_VERSION = '2.0'.freeze
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Error module Error
Unauthorized = Class.new(StandardError) Unauthorized = Class.new(StandardError)
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
class Page class Page
attr_reader :attrs, :items attr_reader :attrs, :items
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
class Paginator class Paginator
PAGE_LENGTH = 50 # The minimum length is 10 and the maximum is 100. PAGE_LENGTH = 50 # The minimum length is 10 and the maximum is 100.
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class Base class Base
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class Comment < Representation::Base class Comment < Representation::Base
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class Issue < Representation::Base class Issue < Representation::Base
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class PullRequest < Representation::Base class PullRequest < Representation::Base
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class PullRequestComment < Comment class PullRequestComment < Comment
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class Repo < Representation::Base class Repo < Representation::Base
......
# frozen_string_literal: true
module Bitbucket module Bitbucket
module Representation module Representation
class User < Representation::Base class User < Representation::Base
......
# frozen_string_literal: true
class CarrierWaveStringFile < StringIO class CarrierWaveStringFile < StringIO
def original_filename def original_filename
"" ""
......
# frozen_string_literal: true
module Constraints module Constraints
class FeatureConstrainer class FeatureConstrainer
attr_reader :feature attr_reader :feature
......
# frozen_string_literal: true
module Constraints module Constraints
class GroupUrlConstrainer class GroupUrlConstrainer
def matches?(request) def matches?(request)
......
# frozen_string_literal: true
module Constraints module Constraints
class ProjectUrlConstrainer class ProjectUrlConstrainer
def matches?(request) def matches?(request)
......
# frozen_string_literal: true
module Constraints module Constraints
class UserUrlConstrainer class UserUrlConstrainer
def matches?(request) def matches?(request)
......
# frozen_string_literal: true
module ContainerRegistry module ContainerRegistry
class Blob class Blob
attr_reader :repository, :config attr_reader :repository, :config
......
# frozen_string_literal: true
require 'faraday' require 'faraday'
require 'faraday_middleware' require 'faraday_middleware'
......
# frozen_string_literal: true
module ContainerRegistry module ContainerRegistry
class Config class Config
attr_reader :tag, :blob, :data attr_reader :tag, :blob, :data
......
# frozen_string_literal: true
module ContainerRegistry module ContainerRegistry
## ##
# Class responsible for extracting project and repository name from # Class responsible for extracting project and repository name from
......
# frozen_string_literal: true
module ContainerRegistry module ContainerRegistry
class Registry class Registry
attr_reader :uri, :client, :path attr_reader :uri, :client, :path
......
# frozen_string_literal: true
module ContainerRegistry module ContainerRegistry
class Tag class Tag
attr_reader :repository, :name attr_reader :repository, :name
......
# frozen_string_literal: true
require_dependency 'declarative_policy/cache' require_dependency 'declarative_policy/cache'
require_dependency 'declarative_policy/condition' require_dependency 'declarative_policy/condition'
require_dependency 'declarative_policy/delegate_dsl' require_dependency 'declarative_policy/delegate_dsl'
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
class Base class Base
# A map of ability => list of rules together with :enable # A map of ability => list of rules together with :enable
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
module Cache module Cache
class << self class << self
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
# A Condition is the data structure that is created by the # A Condition is the data structure that is created by the
# `condition` declaration on DeclarativePolicy::Base. It is # `condition` declaration on DeclarativePolicy::Base. It is
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
# Used when the name of a delegate is mentioned in # Used when the name of a delegate is mentioned in
# the rule DSL. # the rule DSL.
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
# The return value of a rule { ... } declaration. # The return value of a rule { ... } declaration.
# Can call back to register rules with the containing # Can call back to register rules with the containing
......
module DeclarativePolicy # rubocop:disable Naming/FileName # rubocop:disable Naming/FileName
# frozen_string_literal: true
module DeclarativePolicy
PREFERRED_SCOPE_KEY = :"DeclarativePolicy.preferred_scope" PREFERRED_SCOPE_KEY = :"DeclarativePolicy.preferred_scope"
class << self class << self
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
module Rule module Rule
# A Rule is the object that results from the `rule` declaration, # A Rule is the object that results from the `rule` declaration,
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
# The DSL evaluation context inside rule { ... } blocks. # The DSL evaluation context inside rule { ... } blocks.
# Responsible for creating and combining Rule objects. # Responsible for creating and combining Rule objects.
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
class Runner class Runner
class State class State
......
# frozen_string_literal: true
module DeclarativePolicy module DeclarativePolicy
# This object represents one step in the runtime decision of whether # This object represents one step in the runtime decision of whether
# an ability is allowed. It contains a Rule and a context (instance # an ability is allowed. It contains a Rule and a context (instance
......
# frozen_string_literal: true
module ExpandVariables module ExpandVariables
class << self class << self
def expand(value, variables) def expand(value, variables)
......
# frozen_string_literal: true
# Module providing methods for dealing with separating a tree-ish string and a # Module providing methods for dealing with separating a tree-ish string and a
# file path string when combined in a request parameter # file path string when combined in a request parameter
module ExtractsPath module ExtractsPath
...@@ -50,7 +52,9 @@ module ExtractsPath ...@@ -50,7 +52,9 @@ module ExtractsPath
# branches and tags # branches and tags
# Append a trailing slash if we only get a ref and no file path # Append a trailing slash if we only get a ref and no file path
id += '/' unless id.ends_with?('/') unless id.ends_with?('/')
id = [id, '/'].join
end
valid_refs = ref_names.select { |v| id.start_with?("#{v}/") } valid_refs = ref_names.select { |v| id.start_with?("#{v}/") }
...@@ -151,9 +155,9 @@ module ExtractsPath ...@@ -151,9 +155,9 @@ module ExtractsPath
# overriden in subclasses, do not remove # overriden in subclasses, do not remove
def get_id def get_id
id = params[:id] || params[:ref] id = [params[:id] || params[:ref]]
id += "/" + params[:path] unless params[:path].blank? id << "/" + params[:path] unless params[:path].blank?
id id.join
end end
def ref_names def ref_names
......
# frozen_string_literal: true
require 'flipper/adapters/active_record' require 'flipper/adapters/active_record'
require 'flipper/adapters/active_support_cache_store' require 'flipper/adapters/active_support_cache_store'
......
# frozen_string_literal: true
class FileSizeValidator < ActiveModel::EachValidator class FileSizeValidator < ActiveModel::EachValidator
MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze
CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze
......
# frozen_string_literal: true
class Forever class Forever
POSTGRESQL_DATE = DateTime.new(3000, 1, 1) POSTGRESQL_DATE = DateTime.new(3000, 1, 1)
MYSQL_DATE = DateTime.new(2038, 01, 19) MYSQL_DATE = DateTime.new(2038, 01, 19)
......
# frozen_string_literal: true
require_dependency 'gitlab/popen' require_dependency 'gitlab/popen'
module Gitlab module Gitlab
......
# frozen_string_literal: true
class GtOneCoercion < Virtus::Attribute class GtOneCoercion < Virtus::Attribute
def coerce(value) def coerce(value)
[1, value.to_i].max [1, value.to_i].max
......
# frozen_string_literal: true
module MilestoneArray module MilestoneArray
class << self class << self
def sort(array, sort_method) def sort(array, sort_method)
......
# frozen_string_literal: true
# Disable NO_ZERO_DATE mode for mysql in rails 5. # Disable NO_ZERO_DATE mode for mysql in rails 5.
# We use zero date as a default value # We use zero date as a default value
# (config/initializers/active_record_mysql_timestamp.rb), in # (config/initializers/active_record_mysql_timestamp.rb), in
......
# frozen_string_literal: true
# Provides an ActiveRecord-like interface to a model whose data is not persisted to a database. # Provides an ActiveRecord-like interface to a model whose data is not persisted to a database.
module StaticModel module StaticModel
extend ActiveSupport::Concern extend ActiveSupport::Concern
......
# frozen_string_literal: true
# Library to perform System Checks # Library to perform System Checks
# #
# Every Check is implemented as its own class inherited from SystemCheck::BaseCheck # Every Check is implemented as its own class inherited from SystemCheck::BaseCheck
......
# frozen_string_literal: true
require_relative 'gt_one_coercion' require_relative 'gt_one_coercion'
class UnfoldForm class UnfoldForm
......
# frozen_string_literal: true
require "tempfile" require "tempfile"
require "tmpdir" require "tmpdir"
require "fileutils" require "fileutils"
......
# frozen_string_literal: true
require "base64" require "base64"
# This class is used to build image URL to # This class is used to build image URL to
......
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