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.
This commit is contained in:
gfyoung 2018-10-06 16:10:08 -07:00
parent c3389c8006
commit d598e4fd93
103 changed files with 217 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
title: Enable more frozen string in lib/**/*.rb
merge_request:
author: gfyoung
type: performance

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module AfterCommitQueue
extend ActiveSupport::Concern

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Backup
Error = Class.new(StandardError)
end

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ColorParser
ALPHA = /0(?:\.\d+)?|\.\d+|1(?:\.0+)?/ # 0.0..1.0

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module CommitRenderer
ATTRIBUTES = [:description, :title].freeze

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
# Common methods for ReferenceFilters that support an optional cross-project
# reference.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Filter
def self.[](name)

View File

@ -1,3 +1,5 @@
# 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)

View File

@ -1,3 +1,5 @@
# 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.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Filter
class WikiLinkFilter < HTML::Pipeline::Filter

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
class FilterArray < Array
# Insert a value immediately after another value

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
# Extract references to issuables from multiple documents

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
def self.[](name)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class AsciiDocPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class AtomPipeline < FullPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class BroadcastMessagePipeline < DescriptionPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
module CombinedPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class CommitDescriptionPipeline < SingleLinePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class DescriptionPipeline < FullPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class EmailPipeline < FullPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class FullPipeline < CombinedPipeline.new(PlainMarkdownPipeline, GfmPipeline)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class GfmPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class MarkupPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class NotePipeline < FullPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class PlainMarkdownPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class PostProcessPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class PreProcessPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class RelativeLinkPipeline < BasePipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class SingleLinePipeline < GfmPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Pipeline
class WikiPipeline < FullPipeline

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Querying
module_function

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
# Class for removing Markdown references a certain user is not allowed to
# view.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
# Extract possible GFM references from an arbitrary String for further processing.
class ReferenceExtractor

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
# Returns the reference parser class for the given type

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
# Base class for reference parsing classes.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class CommitParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class CommitRangeParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class DirectlyAddressedUserParser < UserParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
# The actual parser is implemented in the EE mixin

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class ExternalIssueParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class IssuableParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class IssueParser < IssuableParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class LabelParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class MergeRequestParser < IssuableParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class MilestoneParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class SnippetParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module ReferenceParser
class UserParser < BaseParser

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Renderer
# Convert a Markdown String into an HTML-safe String of HTML

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Renderer
module CommonMark

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module Renderer
module Redcarpet

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Banzai
module RequestStoreReferenceCache
def cached_call(request_store_key, cache_key, path: [])

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
class Client
attr_reader :connection

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
class Collection < Enumerator
def initialize(paginator)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
class Connection
DEFAULT_API_VERSION = '2.0'.freeze

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Error
Unauthorized = Class.new(StandardError)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
class Page
attr_reader :attrs, :items

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
class Paginator
PAGE_LENGTH = 50 # The minimum length is 10 and the maximum is 100.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class Comment < Representation::Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class Issue < Representation::Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class PullRequest < Representation::Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class PullRequestComment < Comment

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class Repo < Representation::Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Bitbucket
module Representation
class User < Representation::Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CarrierWaveStringFile < StringIO
def original_filename
""

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Constraints
class FeatureConstrainer
attr_reader :feature

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Constraints
class GroupUrlConstrainer
def matches?(request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Constraints
class ProjectUrlConstrainer
def matches?(request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Constraints
class UserUrlConstrainer
def matches?(request)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ContainerRegistry
class Blob
attr_reader :repository, :config

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'faraday'
require 'faraday_middleware'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ContainerRegistry
class Config
attr_reader :tag, :blob, :data

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ContainerRegistry
##
# Class responsible for extracting project and repository name from

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ContainerRegistry
class Registry
attr_reader :uri, :client, :path

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ContainerRegistry
class Tag
attr_reader :repository, :name

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'declarative_policy/cache'
require_dependency 'declarative_policy/condition'
require_dependency 'declarative_policy/delegate_dsl'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
class Base
# A map of ability => list of rules together with :enable

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
module Cache
class << self

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
# A Condition is the data structure that is created by the
# `condition` declaration on DeclarativePolicy::Base. It is

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
# Used when the name of a delegate is mentioned in
# the rule DSL.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
# The return value of a rule { ... } declaration.
# Can call back to register rules with the containing

View File

@ -1,4 +1,7 @@
module DeclarativePolicy # rubocop:disable Naming/FileName
# rubocop:disable Naming/FileName
# frozen_string_literal: true
module DeclarativePolicy
PREFERRED_SCOPE_KEY = :"DeclarativePolicy.preferred_scope"
class << self

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
module Rule
# A Rule is the object that results from the `rule` declaration,

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
# The DSL evaluation context inside rule { ... } blocks.
# Responsible for creating and combining Rule objects.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DeclarativePolicy
class Runner
class State

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ExpandVariables
class << self
def expand(value, variables)

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'flipper/adapters/active_record'
require 'flipper/adapters/active_support_cache_store'

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Forever
POSTGRESQL_DATE = DateTime.new(3000, 1, 1)
MYSQL_DATE = DateTime.new(2038, 01, 19)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'gitlab/popen'
module Gitlab

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class GtOneCoercion < Virtus::Attribute
def coerce(value)
[1, value.to_i].max

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module MilestoneArray
class << self
def sort(array, sort_method)

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# 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

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Library to perform System Checks
#
# Every Check is implemented as its own class inherited from SystemCheck::BaseCheck

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