class RubyLsp::Requests::Support::RuboCopRunner
:nodoc:
def cop_registry
def cop_registry @cop_registry ||= T.let( RuboCop::Cop::Registry.global.to_h, T.nilable(T::Hash[String, [T.class_of(RuboCop::Cop::Base)]]), ) end
def file_finished(_file, offenses)
def file_finished(_file, offenses) @offenses = offenses end
def find_cop_by_name(cop_name)
def find_cop_by_name(cop_name) cop_registry[cop_name]&.first end
def formatted_source
def formatted_source @options[:stdin] end
def initialize(*args)
def initialize(*args) @options = T.let({}, T::Hash[Symbol, T.untyped]) @offenses = T.let([], T::Array[RuboCop::Cop::Offense]) @errors = T.let([], T::Array[String]) @warnings = T.let([], T::Array[String]) args += DEFAULT_ARGS rubocop_options = ::RuboCop::Options.new.parse(args).first config_store = ::RuboCop::ConfigStore.new super(rubocop_options, config_store) end
def run(path, contents)
def run(path, contents) # Clear Runner state between runs since we get a single instance of this class # on every use site. @errors = [] @warnings = [] @offenses = [] @options[:stdin] = contents super([path]) rescue RuboCop::Runner::InfiniteCorrectionLoop => error raise Formatting::Error, error.message rescue RuboCop::ValidationError => error raise ConfigurationError, error.message rescue StandardError => error raise InternalRuboCopError, error end