ruby-lsp-reek 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/ruby_lsp/reek/addon.rb +1 -1
- data/lib/ruby_lsp/reek/runner.rb +28 -2
- data/lib/ruby_lsp/reek/version.rb +1 -1
- metadata +2 -2
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/README.md
CHANGED
@@ -14,10 +14,9 @@ And then execute:
|
|
14
14
|
|
15
15
|
$ bundle
|
16
16
|
|
17
|
-
Note:
|
18
|
-
|
19
|
-
|
20
|
-
$ gem install ruby-lsp-reek
|
17
|
+
Note: Using globally installed linters in Ruby LSP is [not
|
18
|
+
supported](https://github.com/Shopify/ruby-lsp/blob/main/vscode/README.md#formatting),
|
19
|
+
they must in your Gemfile or gemspec.
|
21
20
|
|
22
21
|
## Usage
|
23
22
|
|
data/lib/ruby_lsp/reek/addon.rb
CHANGED
@@ -68,7 +68,7 @@ module RubyLsp
|
|
68
68
|
def workspace_did_change_watched_files(changes)
|
69
69
|
return unless changes.any? { |change| change[:uri].end_with?(".reek.yml") }
|
70
70
|
|
71
|
-
runner.
|
71
|
+
@runner = Runner.new
|
72
72
|
warn "Re-initialized Reek Ruby LSP addon v#{::RubyLsp::Reek::VERSION} due to .reek.yml file change"
|
73
73
|
end
|
74
74
|
|
data/lib/ruby_lsp/reek/runner.rb
CHANGED
@@ -24,9 +24,10 @@ module RubyLsp
|
|
24
24
|
# @param uri [String] The URI of the document to run diagnostics on.
|
25
25
|
# @param document [RubyLsp::Interface::TextDocumentItem] The document to run diagnostics on.
|
26
26
|
def run_diagnostic(uri, document)
|
27
|
-
|
27
|
+
path = Pathname.new(uri.path)
|
28
|
+
return [] if path_excluded?(path)
|
28
29
|
|
29
|
-
examiner =
|
30
|
+
examiner = build_examiner(path, document)
|
30
31
|
examiner.smells.map { |smell| warning_to_diagnostic(smell) }
|
31
32
|
end
|
32
33
|
|
@@ -34,6 +35,23 @@ module RubyLsp
|
|
34
35
|
|
35
36
|
attr_reader :config
|
36
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
|
+
|
37
55
|
# @param warning [Reek::SmellWarning] The warning to convert to a diagnostic.
|
38
56
|
# @return [RubyLsp::Interface::Diagnostic] The diagnostic.
|
39
57
|
def warning_to_diagnostic(warning)
|
@@ -56,6 +74,14 @@ module RubyLsp
|
|
56
74
|
message: warning.message
|
57
75
|
)
|
58
76
|
end
|
77
|
+
|
78
|
+
def path_excluded?(path)
|
79
|
+
path.ascend do |ascendant|
|
80
|
+
break true if config.path_excluded?(ascendant)
|
81
|
+
|
82
|
+
false
|
83
|
+
end
|
84
|
+
end
|
59
85
|
end
|
60
86
|
end
|
61
87
|
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.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iain Gray
|
@@ -194,5 +194,5 @@ requirements: []
|
|
194
194
|
rubygems_version: 3.5.11
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
|
-
summary: Ruby
|
197
|
+
summary: Reek addon for Ruby-LSP
|
198
198
|
test_files: []
|