Skip to content
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Layout/LineLength:
Max: 120
AllowedPatterns: ['\A\s*#:']

Lint/SelfAssignment:
AllowRBSInlineAnnotation: true

Naming/InclusiveLanguage:
Exclude:
- "lib/tapioca/dsl/compilers/protobuf.rb"
Expand Down
11 changes: 6 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ GEM
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.21.1)
json (2.21.2)
kramdown (2.5.2)
rexml (>= 3.4.4)
kredis (1.8.0)
Expand Down Expand Up @@ -345,8 +345,9 @@ GEM
lint_roller (~> 1.1)
regexp_parser (>= 2.0)
rubocop (~> 1.86, >= 1.86.2)
rubocop-shopify (2.18.0)
rubocop (~> 1.62)
rubocop-shopify (3.0.1)
lint_roller
rubocop (~> 1.72, >= 1.72.1)
rubocop-sorbet (0.13.2)
lint_roller
rubocop (>= 1.75.2)
Expand Down Expand Up @@ -534,7 +535,7 @@ CHECKSUMS
identity_cache (1.6.4) sha256=3f043ff06577765ef532656b1af1058f9a983edcf525ba4f5fa79f0bd6324f26
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
json (2.21.1) sha256=13a43df75d95641443f5702dff350f237164a9d811ff0f2c2800d4d980220583
json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
json_api_client (1.23.0)
kramdown (2.5.2) sha256=1ba542204c66b6f9111ff00dcc26075b95b220b07f2905d8261740c82f7f02fa
kredis (1.8.0) sha256=34b72a0bc242d7aaea98e82b6a5a8c293a27e1b26f2c729a8d4e1e1409886150
Expand Down Expand Up @@ -594,7 +595,7 @@ CHECKSUMS
rubocop (1.88.2) sha256=8def251c90cd955feb4daa3edc0ab56893250c4ce90ef81e6c80c03f9a939bbf
rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
rubocop-rspec (3.10.2) sha256=0b3e2ecc592cd10ecbf0095bb58d1e357905276e069643523cc19eb7495f65e2
rubocop-shopify (2.18.0) sha256=dafa25e5617ce4600ff86b1de3d5b78e43ab3d58cc5729df38e492b8e10294eb
rubocop-shopify (3.0.1) sha256=4adffa6313294bd9da2b0896ae44c5eb8e419336b2413de20c38b7691a7e6774
rubocop-sorbet (0.13.2) sha256=7901e57b6b8e9e9b970d941dbdbb89f2c9de0183bfd2551460468f8aa9548655
ruby-lsp (0.26.10) sha256=e67284af94423531f6b9a583350596421b5a6a4dd93083f1c2ba03da7c23bbed
ruby-lsp-rails (0.4.8) sha256=f09d1f926d4063deeb2f3049311925c20dfe6c912371e3bcd04a265a865c44ae
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/tapioca/run_gem_rbi_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def cleanup_orphaned_rbis

#: (*untyped flags) -> Array[String]
def git_ls_gem_rbis(*flags)
self #: as untyped # rubocop:disable Style/RedundantSelf
self #: as untyped
.execute_in_project_path("git", "ls-files", *flags, "sorbet/rbi/gems/")
.lines
.map(&:strip)
Expand Down
20 changes: 10 additions & 10 deletions lib/tapioca.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ class Error < StandardError; end

LIB_ROOT_DIR = T.must(__dir__) #: String
SORBET_DIR = "sorbet" #: String
SORBET_CONFIG_FILE = "#{SORBET_DIR}/config" #: String
TAPIOCA_DIR = "#{SORBET_DIR}/tapioca" #: String
TAPIOCA_CONFIG_FILE = "#{TAPIOCA_DIR}/config.yml" #: String
SORBET_CONFIG_FILE = "#{SORBET_DIR}/config".freeze #: String
TAPIOCA_DIR = "#{SORBET_DIR}/tapioca".freeze #: String
TAPIOCA_CONFIG_FILE = "#{TAPIOCA_DIR}/config.yml".freeze #: String

BINARY_FILE = "bin/tapioca" #: String
DEFAULT_POSTREQUIRE_FILE = "#{TAPIOCA_DIR}/require.rb" #: String
DEFAULT_RBI_DIR = "#{SORBET_DIR}/rbi" #: String
DEFAULT_DSL_DIR = "#{DEFAULT_RBI_DIR}/dsl" #: String
DEFAULT_GEM_DIR = "#{DEFAULT_RBI_DIR}/gems" #: String
DEFAULT_SHIM_DIR = "#{DEFAULT_RBI_DIR}/shims" #: String
DEFAULT_TODO_FILE = "#{DEFAULT_RBI_DIR}/todo.rbi" #: String
DEFAULT_ANNOTATIONS_DIR = "#{DEFAULT_RBI_DIR}/annotations" #: String
DEFAULT_POSTREQUIRE_FILE = "#{TAPIOCA_DIR}/require.rb".freeze #: String
DEFAULT_RBI_DIR = "#{SORBET_DIR}/rbi".freeze #: String
DEFAULT_DSL_DIR = "#{DEFAULT_RBI_DIR}/dsl".freeze #: String
DEFAULT_GEM_DIR = "#{DEFAULT_RBI_DIR}/gems".freeze #: String
DEFAULT_SHIM_DIR = "#{DEFAULT_RBI_DIR}/shims".freeze #: String
DEFAULT_TODO_FILE = "#{DEFAULT_RBI_DIR}/todo.rbi".freeze #: String
DEFAULT_ANNOTATIONS_DIR = "#{DEFAULT_RBI_DIR}/annotations".freeze #: String

DEFAULT_OVERRIDES = {
# ActiveSupport overrides some core methods with different signatures
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Compilers
NAMESPACES = [
"#{name}::", # compilers in this namespace
"::", # compilers that need to be fully namespaced
] #: Array[String]
].freeze #: Array[String]
end
end
end
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ActiveJob < Compiler
# @override
#: -> void
def decorate
return unless constant.instance_methods(false).include?(:perform)
return unless constant.method_defined?(:perform, false)

root.create_path(constant) do |job|
method = constant.instance_method(:perform)
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/active_model_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def gather_constants

private

HANDLED_METHOD_TARGETS = ["attribute", "attribute="] #: Array[String]
HANDLED_METHOD_TARGETS = ["attribute", "attribute="].freeze #: Array[String]

#: -> Array[[::String, ::String]]
def attribute_methods_for_constant
Expand Down
4 changes: 2 additions & 2 deletions lib/tapioca/dsl/compilers/active_record_relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ def gather_constants
order: ["T.any(Symbol, T::Array[Symbol])", ":asc"],
cursor: ["T.untyped", "primary_key"],
use_ranges: ["T.untyped", "nil"],
} #: Hash[Symbol, [String, String]]
}.freeze #: Hash[Symbol, [String, String]]
CALCULATION_METHODS = ActiveRecord::Calculations.instance_methods(false) #: Array[Symbol]
RELATION_METHODS = ActiveRecord::Relation.instance_methods(false) #: Array[Symbol]
TO_ARRAY_METHODS = [:to_ary, :to_a] #: Array[Symbol]
TO_ARRAY_METHODS = [:to_ary, :to_a].freeze #: Array[Symbol]

private

Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

return unless defined?(Config) && defined?(Config::VERSION) && defined?(Config.const_name)
return unless defined?(Config::VERSION) && defined?(Config.const_name)

module Tapioca
module Dsl
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/json_api_client_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def resource_schema
schema = constant.schema

# empty? does not exist on JsonApiClient::Schema
schema if schema.size > 0 # rubocop:disable Style/ZeroLengthPredicate
schema if schema.size > 0
end

#: (RBI::Scope mod, ::JsonApiClient::Schema::Property property) -> void
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/sidekiq_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SidekiqWorker < Compiler
# @override
#: -> void
def decorate
return unless constant.instance_methods.include?(:perform)
return unless constant.method_defined?(:perform)

root.create_path(constant) do |worker|
method_def = constant.instance_method(:perform)
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/compilers/url_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def gather_constants
next unless name_of(mod)

# Fast-path to quickly disqualify most cases
next false unless url_helpers_module > mod || # rubocop:disable Style/InvertibleUnlessCondition
next false unless url_helpers_module > mod ||
path_helpers_module > mod ||
url_helpers_module > mod.singleton_class ||
path_helpers_module > mod.singleton_class
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/dsl/helpers/graphql_type_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def type_for(type, ignore_nilable_wrapper: false, prepare_method: nil)

#: (Module[top] constant) -> String
def type_for_constant(constant)
if constant.instance_methods.include?(:prepare)
if constant.method_defined?(:prepare)
prepare_method = constant.instance_method(:prepare)

prepare_signature = Runtime::Reflection.signature_of(prepare_method)
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/gem/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class MethodNodeAdded < NodeAdded
#| untyped signature,
#| Array[[Symbol, String]] parameters
#| ) -> void
def initialize(symbol, constant, method, node, signature, parameters) # rubocop:disable Metrics/ParameterLists
def initialize(symbol, constant, method, node, signature, parameters)
super(symbol, constant)
@node = node
@method = method
Expand Down
4 changes: 2 additions & 2 deletions lib/tapioca/gem/listeners/documentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Documentation < Base
"shareable_constant_value:",
"rubocop:",
"@requires_ancestor:",
] #: Array[String]
].freeze #: Array[String]

#: (Pipeline pipeline, Rubydex::Graph gem_graph) -> void
def initialize(pipeline, gem_graph)
Expand Down Expand Up @@ -75,7 +75,7 @@ def documentation_comments(name, sigs: [])

lines = comments
.map { |comment| comment.string.gsub(/^#+ ?/, "") }
.reject { |line| IGNORED_COMMENTS.any? { |comment| line.include?(comment) } || rbs_comment?(line) } # rubocop:disable Style/ArrayIntersect
.reject { |line| IGNORED_COMMENTS.any? { |comment| line.include?(comment) } || rbs_comment?(line) }

# Strip leading and trailing blank lines, matching YARD's behavior
lines = lines.reverse_each.drop_while(&:empty?).reverse_each.drop_while(&:empty?)
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/gem/listeners/sorbet_enums.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SorbetEnums < Base
#: (ScopeNodeAdded event) -> void
def on_scope(event)
constant = event.constant
return unless T::Enum > event.constant # rubocop:disable Style/InvertibleUnlessCondition
return unless T::Enum > event.constant

enum_block = RBI::TEnumBlock.new

Expand Down
6 changes: 3 additions & 3 deletions lib/tapioca/gem/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Pipeline
include Runtime::Reflection
include RBIHelper

IGNORED_SYMBOLS = ["YAML", "MiniTest", "Mutex"] #: Array[String]
IGNORED_SYMBOLS = ["YAML", "MiniTest", "Mutex"].freeze #: Array[String]

#: Gemfile::GemSpec
attr_reader :gem
Expand Down Expand Up @@ -100,7 +100,7 @@ def push_foreign_scope(symbol, constant, node)
#| untyped signature,
#| Array[[Symbol, String]] parameters
#| ) -> void
def push_method(symbol, constant, method, node, signature, parameters) # rubocop:disable Metrics/ParameterLists
def push_method(symbol, constant, method, node, signature, parameters)
@events << Gem::MethodNodeAdded.new(symbol, constant, method, node, signature, parameters)
end

Expand Down Expand Up @@ -356,7 +356,7 @@ def compile_scope(name, constant)

#: (Class[top] constant) -> String?
def compile_superclass(constant)
superclass = nil #: Class[top]? # rubocop:disable Lint/UselessAssignment
superclass = nil #: Class[top]?

while (superclass = superclass_of(constant))
constant_name = name_of(constant)
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/helpers/env_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Tapioca
# @requires_ancestor: Thor
module EnvHelper
#: (Hash[Symbol, untyped] options) -> void
def set_environment(options) # rubocop:disable Naming/AccessorMethodName
def set_environment(options)
ENV["RAILS_ENV"] = ENV["RACK_ENV"] = options[:environment]
ENV["RUBY_DEBUG_LAZY"] = "1"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tapioca/helpers/rbi_files_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def has_duplicated_methods_and_attrs?(nodes, shims_or_todos)
# We compare the shim or todo prop with all the other props of the same name
other_nodes.each do |node|
# Another prop has the same sig, we have a duplicate
return true if shim_or_todo_prop.sigs.any? { |sig| node.sigs.include?(sig) } # rubocop:disable Style/ArrayIntersect
return true if shim_or_todo_prop.sigs.any? { |sig| node.sigs.include?(sig) }
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/tapioca/runtime/dynamic_mixin_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def initialize(constant)
mixins_from_modules[mod] = (after - before).reverse!
end
end
rescue Exception # rubocop:disable Lint/RescueException
rescue Exception
# this is a best effort, bail if we can't perform this
end

Expand Down Expand Up @@ -85,7 +85,6 @@ def initialize(constant)
super(*attrs, **kwargs) if defined?(super)
end

# rubocop:disable Style/MissingRespondToMissing
T::Sig::WithoutRuntime.sig { params(symbol: Symbol, args: T.untyped).returns(T.untyped) }
def method_missing(symbol, *args)
# We need this here so that we can handle any random instance
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions sorbet/rbi/gems/rubocop-shopify@2.18.0.rbi

This file was deleted.

Loading
Loading