solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

typecheck: strict mode giving errors for methods/variables that are in scope

Open lararosekelley opened this issue 3 years ago • 1 comments

Right off the bat, I will admit I am not a seasoned Ruby developer, so there may be some configuration issue on my end. But I'm seeing some incorrect results from solargraph typecheck --level strict. I have run bundle exec yard gems as well.

Here is the file in question:

# frozen_string_literal: true

require "sinatra"
require "sinatra/json"

# web server
class App < Sinatra::Application
  get "/" do
    json foo: "bar"
  end

  run! if app_file == $PROGRAM_NAME
end

And my .solargraph.yml:

---
include:
- "**/*.rb"
reporters:
- rubocop
- require_not_found
- typecheck:strict

Lastly, Rubocop config:

Style/StringLiterals:
  EnforcedStyle: double_quotes

Gems are installed via bundle, located in my project directory. The errors I get are:

$ bundle exec solargraph typecheck --level strict
/home/tylucaskelley/Code/personal/tlk/server.rb:9 - Unresolved call to json
/home/tylucaskelley/Code/personal/tlk/server.rb:12 - Unresolved call to app_file
2 problems found.

Things seem to be working for the most part - for example, it correctly detects that Sinatra::Application is in scope - but the json provided by sinatra/json and the global app_file variable are not detected.

lararosekelley avatar Aug 28 '21 01:08 lararosekelley

Confirmed. This appears to be an issue with the generated YARD documentation for Sinatra instead of Solargraph itself, but I'll investigate possible solutions.

castwide avatar Sep 19 '21 16:09 castwide