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

Migrate to RBS signatures supported by Sorbet #3222

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ AllCops:
- "test/expectations/**/*"
- "jekyll/**/*"

Layout/LeadingCommentSpace:
AllowRBSInlineAnnotation: true

Layout/LineLength:
Max: 120
AllowedPatterns: ['\A\s*#:']

Minitest/AssertPredicate:
Enabled: true

Expand Down Expand Up @@ -87,7 +94,3 @@ Layout/ClassStructure:
- include
- prepend
- extend

Layout/LeadingCommentSpace:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reordering by alphabetical order

Enabled: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already enabled by default

AllowRBSInlineAnnotation: true
19 changes: 10 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,18 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
sorbet (0.5.11829)
sorbet-static (= 0.5.11829)
sorbet-runtime (0.5.11829)
sorbet-static (0.5.11829-universal-darwin)
sorbet-static (0.5.11829-x86_64-linux)
sorbet-static-and-runtime (0.5.11829)
sorbet (= 0.5.11829)
sorbet-runtime (= 0.5.11829)
spoom (1.5.1)
sorbet (0.5.11842)
sorbet-static (= 0.5.11842)
sorbet-runtime (0.5.11842)
sorbet-static (0.5.11842-universal-darwin)
sorbet-static (0.5.11842-x86_64-linux)
sorbet-static-and-runtime (0.5.11842)
sorbet (= 0.5.11842)
sorbet-runtime (= 0.5.11842)
spoom (1.5.4)
erubi (>= 1.10.0)
prism (>= 0.28.0)
rbi (>= 0.2.3)
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)
stringio (3.1.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ def on_new_investigation

private

sig { params(event_name: Symbol).returns(T::Boolean) }
#: (Symbol event_name) -> bool
def valid_event_name?(event_name)
/^on_.*(node_enter|node_leave)$/.match?(event_name)
end

sig { params(listeners: T::Array[RuboCop::AST::SymbolNode], handlers: T::Array[RuboCop::AST::DefNode]).void }
#: (Array[RuboCop::AST::SymbolNode] listeners, Array[RuboCop::AST::DefNode] handlers) -> void
def add_offense_to_listeners_without_handler(listeners, handlers)
return if listeners.none?

Expand All @@ -107,7 +107,7 @@ def add_offense_to_listeners_without_handler(listeners, handlers)
.each { |node| add_offense(node, message: format(MSG_MISSING_HANDLER, listener: node.value)) }
end

sig { params(listeners: T::Array[RuboCop::AST::SymbolNode], handlers: T::Array[RuboCop::AST::DefNode]).void }
#: (Array[RuboCop::AST::SymbolNode] listeners, Array[RuboCop::AST::DefNode] handlers) -> void
def add_offense_handlers_without_listener(listeners, handlers)
return if handlers.none?

Expand Down
18 changes: 9 additions & 9 deletions lib/ruby_indexer/lib/ruby_indexer/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class Configuration
T::Hash[String, T.untyped],
)

sig { params(workspace_path: String).void }
#: String
attr_writer :workspace_path

sig { returns(Encoding) }
#: Encoding
attr_accessor :encoding

sig { void }
#: -> void
def initialize
@workspace_path = T.let(Dir.pwd, String)
@encoding = T.let(Encoding::UTF_8, Encoding)
Expand Down Expand Up @@ -66,7 +66,7 @@ def initialize
)
end

sig { returns(String) }
#: -> String
def merged_excluded_file_pattern
# This regex looks for @excluded_patterns that follow the format of "something/**/*", where
# "something" is one or more non-"/"
Expand All @@ -81,7 +81,7 @@ def merged_excluded_file_pattern
.then { |dirs| File.join(@workspace_path, "{#{dirs.join(",")}}/**/*") }
end

sig { returns(T::Array[URI::Generic]) }
#: -> Array[URI::Generic]
def indexable_uris
excluded_gems = @excluded_gems - @included_gems
locked_gems = Bundler.locked_gems&.specs
Expand Down Expand Up @@ -222,12 +222,12 @@ def indexable_uris
uris
end

sig { returns(Regexp) }
#: -> Regexp
def magic_comment_regex
@magic_comment_regex ||= T.let(/^#\s*#{@excluded_magic_comments.join("|")}/, T.nilable(Regexp))
end

sig { params(config: T::Hash[String, T.untyped]).void }
#: (Hash[String, untyped] config) -> void
def apply_config(config)
validate_config!(config)

Expand All @@ -240,7 +240,7 @@ def apply_config(config)

private

sig { params(config: T::Hash[String, T.untyped]).void }
#: (Hash[String, untyped] config) -> void
def validate_config!(config)
errors = config.filter_map do |key, value|
type = CONFIGURATION_SCHEMA[key]
Expand All @@ -255,7 +255,7 @@ def validate_config!(config)
raise ArgumentError, errors.join("\n") if errors.any?
end

sig { returns(T::Array[String]) }
#: -> Array[String]
def initial_excluded_gems
excluded, others = Bundler.definition.dependencies.partition do |dependency|
dependency.groups == [:development]
Expand Down
Loading
Loading