Commit d598e4fd authored by gfyoung's avatar gfyoung

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

Enables frozen for the following:

* lib/*.rb
* lib/banzai/**/*.rb
* lib/bitbucket/**/*.rb
* lib/constraints/**/*.rb
* lib/container_registry/**/*.rb
* lib/declarative_policy/**/*.rb

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