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
8 changes: 6 additions & 2 deletions gems/rubocop-ast/1.46/rubocop-ast.rbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module RuboCop
module AST
class ProcessedSource
def initialize: (String source, Float ruby_version, ?path?) -> untyped
attr_reader path: String?
attr_reader ast: Node?
attr_reader ruby_version: Float
attr_reader parser_engine: Symbol

def initialize: (String source, Float ruby_version, ?path?, ?parser_engine: Symbol, ?prism_result: untyped) -> untyped
def raw_source: () -> String
def buffer: () -> Parser::Source::Buffer
def comments: () -> Array[Parser::Source::Comment]
attr_reader ast: Node | nil
end

class NodePattern
Expand Down
9 changes: 9 additions & 0 deletions gems/rubocop/1.57/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ def source_location(node)
end
end
end

class MyExtractor
def self.call(processed_source)
[{
offset: 0,
processed_source: processed_source
}]
end
end
4 changes: 4 additions & 0 deletions gems/rubocop/1.57/_test/test.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ module RuboCop
end
end
end

class MyExtractor
def self.call: (RuboCop::ProcessedSource processed_source) -> RuboCop::Runner::extractorResult
end
64 changes: 63 additions & 1 deletion gems/rubocop/1.57/rubocop.rbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
module RuboCop
class CommentConfig
attr_reader processed_source: ProcessedSource

def initialize: (ProcessedSource processed_source) -> void
end

class ConfigLoader
def self.debug?: () -> boolish
def self.merge_with_default: (Config, String) -> Config
end

class Config
def initialize: (Hash[untyped, untyped], String) -> void
def initialize: (?Hash[untyped, untyped] hash, ?String loaded_path) -> void
def for_cop: (String cop) -> Hash[String, untyped]
def for_enabled_cop: (String cop) -> Hash[String, untyped]
end

class ConfigStore
def options_config=: (String options_config) -> void
end

module Cop
class Base
extend AST::NodePattern::Macros
Expand Down Expand Up @@ -72,6 +82,16 @@ module RuboCop
def comments_contain_disables?: (RuboCop::AST::Node node, String cop_name) -> bool
end

class Offense
attr_reader severity: Severity
attr_reader location: Parser::Source::Range
attr_reader message: String
attr_reader cop_name: String

def line: () -> Integer
def column: () -> Integer
end

module RangeHelp
def source_range: (Parser::Source::Buffer source_buffer, Integer line_number, Integer column, ?Integer length) -> Parser::Source::Range
def range_between: (Integer start_pos, Integer end_pos) -> Parser::Source::Range
Expand All @@ -84,12 +104,24 @@ module RuboCop
?buffer: Parser::Source::Buffer) -> Parser::Source::Range
end

class Registry
end

module IgnoredNode
def ignore_node: (RuboCop::AST::Node node) -> void
def part_of_ignored_node?: (RuboCop::AST::Node node) -> bool
def ignored_node?: (RuboCop::AST::Node node) -> bool
end

class Severity
type t = :info | :refactor | :convention | :warning | :error | :fatal

attr_reader name: t

def code: () -> String
def level: () -> Integer
end

module TargetRubyVersion
def minimum_target_ruby_version: (Float) -> void
def maximum_target_ruby_version: (Float) -> void
Expand Down Expand Up @@ -117,8 +149,28 @@ module RuboCop
end
end

module Ext
module ProcessedSource
attr_accessor registry: Cop::Registry
attr_accessor config: Config

def comment_config: () -> CommentConfig
def disabled_line_ranges: () -> Hash[untyped, untyped]
end
end

class ProcessedSource = AST::ProcessedSource

class Runner
type extractorResult = Array[{ offset: Integer, processed_source: ProcessedSource}]?

interface _Extractor
def call: (ProcessedSource) -> extractorResult
end

def self.ruby_extractors: () -> Array[_Extractor]
end

module AutoCorrector
def support_autocorrect?: () -> true
end
Expand All @@ -127,3 +179,13 @@ module RuboCop
def smart_path: (String path) -> String
end
end

# Patch to RuboCop::AST::ProcessedSource

module RuboCop
module AST
class ProcessedSource
include Ext::ProcessedSource
end
end
end
Loading