Class: Solargraph::Diagnostics::TypeCheck
- Defined in:
- lib/solargraph/diagnostics/type_check.rb
Overview
TypeCheck reports methods with undefined return types, untagged parameters, and invalid param tags.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Solargraph::Diagnostics::Base
Instance Method Details
#diagnose(source, api_map) ⇒ Array<Hash>
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/solargraph/diagnostics/type_check.rb', line 10 def diagnose source, api_map # return [] unless args.include?('always') || api_map.workspaced?(source.filename) severity = Diagnostics::Severities::ERROR level = args.reverse.find { |a| %w[normal typed strict strong].include?(a) } || :normal # @sg-ignore sensitive typing needs to handle || on nil types checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym) checker.problems .sort { |a, b| a.location.range.start.line <=> b.location.range.start.line } .map do |problem| { range: extract_first_line(problem.location, source), severity: severity, source: 'Typecheck', message: problem. } end end |