Issue #14938 has been updated by mtsmfm (Fumiaki Matsushima).


I want to get 3 things.

1. Type (warning or error)
2. Message
3. Location

I think location interface should be the same as RubyVM::AST::Node

https://ruby-doc.org/core-2.6.0.preview2/RubyVM/AST/Node.html

My proposal is the following:

~~~ruby
source = <<-RUBY
a = 1
RUBY

results = RubyVM::AST.lint(source) # I'm not sure about suitable class/module for this method
result = results.first
result.type
#=> warning
result.message
#=> assigned but unused variable - a
result.first_lineno
#=> 1 
result.last_lineno
#=> 1 
result.first_column
#=> 0
result.last_column
#=> 1 (or 5?)
~~~

----------------------------------------
Feature #14938: Provide API to get same result as ruby -wc
https://bugs.ruby-lang.org/issues/14938#change-73148

* Author: mtsmfm (Fumiaki Matsushima)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I'm the author of an implementation of Ruby Language Server.
Currently, it uses `RubyVM::InstructionSequence.compile` to get the result of `ruby -wc` and parses message and location by regexp.

https://github.com/mtsmfm/language_server-ruby/blob/v0.11.0/lib/language_server/linter/ruby_wc.rb#L30

Do you have any plan to provide API?



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>