solargraph 0.39.3 → 0.39.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7445b5b059ff10d5ff6b998209d3988a4d9f20b48b0b3e51b8e6b63000f18d1b
4
- data.tar.gz: d17e09c8fecf38bb4bff9ca4d6985c898a2256cc6c56e4c54599b4be907e27b9
3
+ metadata.gz: 1a45c7684317779d321e953079f5da5532f7b7eecc852b73e609ce03dafc81dc
4
+ data.tar.gz: '08f96cb16887491e334fa276959cd019da3c356656a9a670c6133e491745fa55'
5
5
  SHA512:
6
- metadata.gz: 61ed8f3f9f68ce49f2496e5fe07eeefbc1121350c15827bc0d600a2417e041d4f2b5d89c861c2f3b4873c20e02bd8fa708d2697b3e73d8e0ee0c858cb7c0f090
7
- data.tar.gz: 6c3646376224f2237e404e4c6fcea9eaf02eaa1cfedebf9a01b6f89896d6454c03b7cbbdc16255549b528243d4c7f73a491f7d94e2d5866c6d15bc18a6db0323
6
+ metadata.gz: 5a9d7ec1fb35b5d870d33f16a9bf6b229b1f62a6221f7fac5d1d35e65620ac030cef5bd53c558a1ee007c37b4e187a43315abfa4cecaf146c3746e9b97a46f3f
7
+ data.tar.gz: 7537aa6bd14209895350f40830dd5986683982609c8e18d257eaca8993b0ab759b2e635ec6c952499a0d8559663b870c1db9b9a3c1955bd8dd096eaedde04d73
data/lib/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ Layout/EndOfLine:
2
+ EnforcedStyle: lf
3
+ Style/MethodDefParentheses:
4
+ Enabled: false
5
+ Layout/EmptyLineAfterGuardClause:
6
+ Enabled: false
7
+ Layout/SpaceAroundMethodCallOperator:
8
+ Enabled: true
9
+ Lint/RaiseException:
10
+ Enabled: true
11
+ Lint/StructNewOverride:
12
+ Enabled: true
13
+ Style/ExponentialNotation:
14
+ Enabled: true
15
+ Style/HashEachMethods:
16
+ Enabled: true
17
+ Style/HashTransformKeys:
18
+ Enabled: true
19
+ Style/HashTransformValues:
20
+ Enabled: true
21
+
@@ -24,7 +24,8 @@ module Solargraph
24
24
  # @return [Array<Hash>]
25
25
  def diagnose source, _api_map
26
26
  options, paths = generate_options(source.filename, source.code)
27
- runner = RuboCop::Runner.new(options, RuboCop::ConfigStore.new)
27
+ store = RuboCop::ConfigStore.new
28
+ runner = RuboCop::Runner.new(options, store)
28
29
  result = redirect_stdout{ runner.run(paths) }
29
30
  make_array JSON.parse(result)
30
31
  rescue RuboCop::ValidationError, RuboCop::ConfigNotFoundError => e
@@ -17,7 +17,8 @@ module Solargraph
17
17
  rubocop_file = find_rubocop_file(filename)
18
18
  args.push('-c', fix_drive_letter(rubocop_file)) unless rubocop_file.nil?
19
19
  args.push filename
20
- options, paths = RuboCop::Options.new.parse(args)
20
+ base_options = RuboCop::Options.new
21
+ options, paths = base_options.parse(args)
21
22
  options[:stdin] = code
22
23
  [options, paths]
23
24
  end
@@ -27,6 +28,8 @@ module Solargraph
27
28
  # @param filename [String]
28
29
  # @return [String, nil]
29
30
  def find_rubocop_file filename
31
+ return nil unless File.exist?(filename)
32
+ filename = File.realpath(filename)
30
33
  dir = File.dirname(filename)
31
34
  until File.dirname(dir) == dir
32
35
  here = File.join(dir, '.rubocop.yml')
@@ -16,11 +16,15 @@ module Solargraph
16
16
  # detects the correct configuration
17
17
  # the .rb extension is needed for ruby file without extension, else rubocop won't format
18
18
  tempfile = File.join(File.dirname(filename), "_tmp_#{SecureRandom.hex(8)}_#{File.basename(filename)}.rb")
19
+ rubocop_file = Diagnostics::RubocopHelpers.find_rubocop_file(filename)
19
20
  original = host.read_text(params['textDocument']['uri'])
20
21
  File.write tempfile, original
21
22
  begin
22
- options, paths = RuboCop::Options.new.parse(['-a', '-f', 'fi', tempfile])
23
- redirect_stdout { RuboCop::Runner.new(options, RuboCop::ConfigStore.new).run(paths) }
23
+ args = ['-a', '-f', 'fi', tempfile]
24
+ args.unshift('-c', fix_drive_letter(rubocop_file)) unless rubocop_file.nil?
25
+ options, paths = RuboCop::Options.new.parse(args)
26
+ store = RuboCop::ConfigStore.new
27
+ redirect_stdout { RuboCop::Runner.new(options, store).run(paths) }
24
28
  result = File.read(tempfile)
25
29
  File.unlink tempfile
26
30
  format original, result
@@ -9,7 +9,7 @@ module Solargraph
9
9
 
10
10
  def process
11
11
  if [:private, :public, :protected].include?(node.children[0])
12
- if (node.type == :FCALL && node.children.last.children.length > 1)
12
+ if node.type == :FCALL && Parser.is_ast_node?(node.children.last)
13
13
  node.children.last.children[0..-2].each do |child|
14
14
  # next unless child.is_a?(AST::Node) && (child.type == :sym || child.type == :str)
15
15
  next unless child.type == :LIT || child.type == :STR
@@ -338,8 +338,8 @@ module Solargraph
338
338
 
339
339
  def first_not_empty_from line
340
340
  cursor = line
341
- cursor += 1 while cursor < code.lines.length && code.lines[cursor].strip.empty?
342
- cursor = line if cursor > code.lines.length - 1
341
+ cursor += 1 while cursor < code_lines.length && code_lines[cursor].strip.empty?
342
+ cursor = line if cursor > code_lines.length - 1
343
343
  cursor
344
344
  end
345
345
 
@@ -468,8 +468,12 @@ module Solargraph
468
468
  # @return [Integer]
469
469
  attr_writer :version
470
470
 
471
+ # @param val [String]
471
472
  # @return [String]
472
- attr_writer :code
473
+ def code=(val)
474
+ @code_lines= nil
475
+ @code = val
476
+ end
473
477
 
474
478
  # @return [Parser::AST::Node]
475
479
  attr_writer :node
@@ -492,6 +496,13 @@ module Solargraph
492
496
  # @return [Source::Updater]
493
497
  attr_accessor :last_updater
494
498
 
499
+ private
500
+
501
+ # @return [Array<String>]
502
+ def code_lines
503
+ @code_lines ||= code.lines
504
+ end
505
+
495
506
  class << self
496
507
  # @param filename [String]
497
508
  # @return [Solargraph::Source]
@@ -185,9 +185,9 @@ module Solargraph
185
185
  # @return [void]
186
186
  def process_comment_directives
187
187
  return unless @code =~ MACRO_REGEXP
188
- used = []
188
+ code_lines = @code.lines
189
189
  @source.associated_comments.each do |line, comments|
190
- src_pos = line ? Position.new(line, @code.lines[line].to_s.chomp.index(/[^\s]/) || 0) : Position.new(@code.lines.length, 0)
190
+ src_pos = line ? Position.new(line, code_lines[line].to_s.chomp.index(/[^\s]/) || 0) : Position.new(code_lines.length, 0)
191
191
  com_pos = Position.new(line - 1, 0)
192
192
  process_comment(src_pos, com_pos, comments)
193
193
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.39.3'
4
+ VERSION = '0.39.4'
5
5
  end
@@ -11,18 +11,23 @@ module Solargraph
11
11
  extend ApiMap::SourceToYard
12
12
 
13
13
  # @param spec [Gem::Specification]
14
- def self.run spec
14
+ # @param cache_dir [String]
15
+ # @return [void]
16
+ def self.run spec, cache_dir: nil
15
17
  Dir.mktmpdir do |tmpdir|
16
18
  rdir = File.join(tmpdir, 'rdoc')
17
19
  Dir.chdir spec.full_gem_path do
18
20
  pins = []
19
21
  pins.push Solargraph::Pin::ROOT_PIN
20
22
  name_hash = {}
21
- cmd = "rdoc -q -N -r -o #{rdir}"
23
+
24
+ argv = ['-q', '-N', '-r', '-o', rdir]
22
25
  spec.load_paths.each do |path|
23
- cmd += " -i #{path}"
26
+ argv.concat ['-i', path]
24
27
  end
25
- `#{cmd}`
28
+ rdoc = RDoc::RDoc.new
29
+ rdoc.document argv
30
+
26
31
  store = RDoc::Store.new(rdir)
27
32
  store.load_all
28
33
  store.cache[:modules].each do |mod|
@@ -64,7 +69,7 @@ module Solargraph
64
69
  closure: namepin,
65
70
  comments: commentary(met.comment),
66
71
  scope: met.type.to_sym,
67
- args: pin.parameters,
72
+ parameters: pin.parameters,
68
73
  visibility: met.visibility,
69
74
  location: locate(met)
70
75
  )
@@ -85,7 +90,7 @@ module Solargraph
85
90
  code_object_map.values.each do |co|
86
91
  YARD::Registry.register(co)
87
92
  end
88
- cache_dir = File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}", "yardoc")
93
+ cache_dir ||= File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}", "yardoc")
89
94
  FileUtils.remove_entry_secure cache_dir if File.exist?(cache_dir)
90
95
  FileUtils.mkdir_p cache_dir
91
96
  # @todo Should merge be true?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.39.3
4
+ version: 0.39.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-28 00:00:00.000000000 Z
11
+ date: 2020-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -301,7 +301,6 @@ extra_rdoc_files: []
301
301
  files:
302
302
  - ".gitignore"
303
303
  - ".rspec"
304
- - ".rubocop.yml"
305
304
  - ".travis.yml"
306
305
  - ".yardopts"
307
306
  - Gemfile
@@ -310,6 +309,7 @@ files:
310
309
  - Rakefile
311
310
  - SPONSORS.md
312
311
  - bin/solargraph
312
+ - lib/.rubocop.yml
313
313
  - lib/solargraph.rb
314
314
  - lib/solargraph/api_map.rb
315
315
  - lib/solargraph/api_map/bundler_methods.rb
data/.rubocop.yml DELETED
@@ -1,6 +0,0 @@
1
- Layout/EndOfLine:
2
- EnforcedStyle: lf
3
- Style/MethodDefParentheses:
4
- Enabled: false
5
- Layout/EmptyLineAfterGuardClause:
6
- Enabled: false