Class: FrozenStringReporter

Inherits:
Solargraph::Diagnostics::Base
  • Object
show all
Defined in:
lib/solargraph_frozen_string_literal.rb

Instance Method Summary collapse

Instance Method Details

#diagnose(source, _api_map) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/solargraph_frozen_string_literal.rb', line 4

def diagnose source, _api_map
  return [] if source.code.empty? || source.code.start_with?('# frozen_string_literal:')
  [
    {
      range: Solargraph::Range.from_to(0, 0, 0, source.code.lines[0].length).to_hash,
      severity: Solargraph::Diagnostics::Severities::WARNING,
      source: 'FrozenString',
      message: 'File does not start with frozen_string_literal.'
    }
  ]
end