Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frozen_string_literal: true #1100

Merged
merged 2 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ Lint/DuplicateMethods:
Enabled: true
Include:
- 'test/**/*_test.rb'

Style/FrozenStringLiteralComment:
Enabled: true
Include:
- 'lib/**/*.rb'
2 changes: 2 additions & 0 deletions lib/rbs.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rbs/version"

require "set"
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/ancestor_graph.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class AncestorGraph
InstanceNode = _ = Struct.new(:type_name, keyword_init: true)
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/annotate.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rdoc"

require "rbs/annotate/rdoc_annotator"
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/annotate/annotations.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Annotate
class Annotations
Expand Down
6 changes: 4 additions & 2 deletions lib/rbs/annotate/formatter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

module RBS
module Annotate
class Formatter
attr_reader :buffer

def initialize()
@buffer = ""
@buffer = +""
@pending_separator = nil
end

Expand All @@ -14,7 +16,7 @@ def <<(s)
s = self.class.translate(s) or raise
end

s.rstrip!
s = s.rstrip

unless s.empty?
if ss = @pending_separator
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/annotate/rdoc_annotator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Annotate
class RDocAnnotator
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/annotate/rdoc_source.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Annotate
class RDocSource
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/ast/annotation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module AST
class Annotation
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/ast/comment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module AST
class Comment
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/ast/declarations.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module AST
module Declarations
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/ast/members.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module AST
module Members
Expand Down
4 changes: 3 additions & 1 deletion lib/rbs/ast/type_param.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module AST
class TypeParam
Expand Down Expand Up @@ -106,7 +108,7 @@ def self.rename(params, new_names:)
end

def to_s
s = ""
s = +""

if unchecked?
s << "unchecked "
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/buffer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Buffer
attr_reader :name
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/builtin_names.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module BuiltinNames
class Name
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/cli.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "open3"
require "optparse"
require "shellwords"
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'yaml'
require 'bundler'

Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Collection
class Cleaner
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Collection

Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/config/lockfile_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Collection

Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/installer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Collection
class Installer
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/sources.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative './sources/base'
require_relative './sources/git'
require_relative './sources/stdlib'
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/sources/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Collection
module Sources
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/sources/git.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'digest/sha2'
require 'open3'
require 'find'
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/sources/rubygems.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'singleton'

module RBS
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/collection/sources/stdlib.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'singleton'

module RBS
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/constant.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Constant
attr_reader :name
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/constant_table.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class ConstantTable
attr_reader :definition_builder
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/definition.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Definition
class Variable
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/definition_builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class DefinitionBuilder
attr_reader :env
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/definition_builder/ancestor_builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class DefinitionBuilder
class AncestorBuilder
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/definition_builder/method_builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class DefinitionBuilder
class MethodBuilder
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/environment.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Environment
attr_reader :declarations
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/environment_loader.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class EnvironmentLoader
class UnknownLibraryError < StandardError
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/environment_walker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class EnvironmentWalker
InstanceNode = _ = Struct.new(:type_name, keyword_init: true)
Expand Down
4 changes: 3 additions & 1 deletion lib/rbs/errors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module MethodNameHelper
def method_name_string()
Expand Down Expand Up @@ -216,7 +218,7 @@ def initialize(type:, method_name:, members:)
@method_name = method_name
@members = members

message = "#{Location.to_string location}: #{qualified_method_name} has duplicated definitions"
message = +"#{Location.to_string location}: #{qualified_method_name} has duplicated definitions"
if members.size > 1
message << " in #{other_locations.map { |loc| Location.to_string loc }.join(', ')}"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/factory.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Factory
def type_name(string)
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/location_aux.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Location
def inspect
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/locator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Locator
attr_reader :decls
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/method_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class MethodType
attr_reader :type_params
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/namespace.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Namespace
attr_reader :path
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/parser_aux.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Parser
def self.parse_type(source, line: 1, column: 0, variables: [])
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/parser_compat/lexer_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RBS.print_warning {
"RBS::Parser::LexerError is deprecated and will be deleted in RBS 2.0."
}
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/parser_compat/located_value.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RBS.print_warning {
"RBS::Parser::LocatedValue is deprecated and will be deleted in RBS 2.0."
}
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/parser_compat/semantics_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RBS.print_warning {
"RBS::Parser::SemanticsError is deprecated and will be deleted in RBS 2.0."
}
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/parser_compat/syntax_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RBS.print_warning {
"RBS::Parser::SyntaxError is deprecated and will be deleted in RBS 2.0."
}
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/prototype/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Prototype
module Helpers
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/prototype/rb.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Prototype
class RB
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/prototype/rbi.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Prototype
class RBI
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/prototype/runtime.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Prototype
class Runtime
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/repository.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Repository
DEFAULT_STDLIB_ROOT = Pathname(_ = __dir__) + "../../stdlib"
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/resolver/constant_resolver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Resolver
class ConstantResolver
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/resolver/type_name_resolver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Resolver
class TypeNameResolver
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/sorter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Sorter
include RBS::AST
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/substitution.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
class Substitution
attr_reader :mapping
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "securerandom"
require "rbs/test/observer"
require "rbs/test/spy"
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/test/errors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Test
module Errors
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/test/hook.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rbs"
require "pp"

Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/test/observer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RBS
module Test
module Observer
Expand Down
2 changes: 2 additions & 0 deletions lib/rbs/test/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "rbs"
require "rbs/test"
require "optparse"
Expand Down
Loading