ruby-lsp-reek 0.3.0 → 0.3.1

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: 2a825d18e3f5825299c0d0e6af7682e3a1f8aa2bc2a030a96a807eaa12aced63
4
- data.tar.gz: c001a2068adb09a8c9610130da10d4ce9bdbb4e534c587b28a13ba53ad1fe42b
3
+ metadata.gz: dae5db882de49d44fa828397d1b3edb0c4c1f1a66133a9fd8418621f799d0d8b
4
+ data.tar.gz: 0ec106ffb86fa62903d979a1a13a02de06c92773b23e03df4e0dfb97ee30a5dd
5
5
  SHA512:
6
- metadata.gz: 0cec537f3c7d5d39842c75a6715b54ae39999784bedc3b331b2f98effc248847b4a8daf534e193ae055a68b0aeef3b3f5af17b5aae7610510bb095b578dfbf3f
7
- data.tar.gz: 3b8f36ccfc2455b2af3c6bb548c67b95e1ce95a72f98ed55138ec5efebf237fe2d2453822f09eef1bb902490794f2e6dcc1efb67fa793f083dea65e725ac5040
6
+ metadata.gz: 3c8ad667879e4a2e110c68d65ea3bca3825e9dd71cf8a6b05b942db9362ab9e7b2e67f04496bf5a12ae9adb97dd78732da15aa9739b50c75455b8d80f7dc7104
7
+ data.tar.gz: 85aaa5e72ff6ed6c9019f4ff0256335ef3be659b3479e87d1f30f6737a5344b99e600fbef03b4be4bbb885570dec13b1235afb716f8070bd109193bbd48e7e7b
@@ -27,7 +27,7 @@ module RubyLsp
27
27
  path = Pathname.new(uri.path)
28
28
  return [] if path_excluded?(path)
29
29
 
30
- examiner = ::Reek::Examiner.new(path, configuration: config)
30
+ examiner = build_examiner(path, document)
31
31
  examiner.smells.map { |smell| warning_to_diagnostic(smell) }
32
32
  end
33
33
 
@@ -35,6 +35,23 @@ module RubyLsp
35
35
 
36
36
  attr_reader :config
37
37
 
38
+ # Examiner does not allow separate source and origin, but we need to
39
+ # lint the string from the editor AND know what the filename of the
40
+ # edited file is. This patches the examiner to allow this.
41
+ def build_examiner(path, document)
42
+ examiner = ::Reek::Examiner.new(document.source, configuration: config)
43
+ origin = ::Reek::Source::SourceCode.from(path).origin
44
+ examiner.instance_variable_set(:@origin, origin)
45
+ examiner.instance_variable_set(
46
+ :@detector_repository,
47
+ ::Reek::DetectorRepository.new(
48
+ smell_types: examiner.instance_variable_get(:@smell_types),
49
+ configuration: config.directive_for(origin)
50
+ )
51
+ )
52
+ examiner
53
+ end
54
+
38
55
  # @param warning [Reek::SmellWarning] The warning to convert to a diagnostic.
39
56
  # @return [RubyLsp::Interface::Diagnostic] The diagnostic.
40
57
  def warning_to_diagnostic(warning)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLsp
4
4
  module Reek
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lsp-reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iain Gray