Skip to content

Commit

Permalink
Migrate all sigs to RBS
Browse files Browse the repository at this point in the history
Using `spoom srb sigs translate`

Signed-off-by: Alexandre Terrasa <[email protected]>
  • Loading branch information
Morriar committed Feb 20, 2025
1 parent 44d7b1b commit 3f9f2d7
Show file tree
Hide file tree
Showing 89 changed files with 1,096 additions and 1,952 deletions.
6 changes: 3 additions & 3 deletions lib/rubocop/cop/ruby_lsp/use_register_with_handler_method.rb
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

0 comments on commit 3f9f2d7

Please sign in to comment.