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 +4 -4
- data/lib/ruby_lsp/reek/runner.rb +18 -1
- data/lib/ruby_lsp/reek/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dae5db882de49d44fa828397d1b3edb0c4c1f1a66133a9fd8418621f799d0d8b
|
4
|
+
data.tar.gz: 0ec106ffb86fa62903d979a1a13a02de06c92773b23e03df4e0dfb97ee30a5dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c8ad667879e4a2e110c68d65ea3bca3825e9dd71cf8a6b05b942db9362ab9e7b2e67f04496bf5a12ae9adb97dd78732da15aa9739b50c75455b8d80f7dc7104
|
7
|
+
data.tar.gz: 85aaa5e72ff6ed6c9019f4ff0256335ef3be659b3479e87d1f30f6737a5344b99e600fbef03b4be4bbb885570dec13b1235afb716f8070bd109193bbd48e7e7b
|
data/lib/ruby_lsp/reek/runner.rb
CHANGED
@@ -27,7 +27,7 @@ module RubyLsp
|
|
27
27
|
path = Pathname.new(uri.path)
|
28
28
|
return [] if path_excluded?(path)
|
29
29
|
|
30
|
-
examiner =
|
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)
|