spoom 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spoom/cli/deadcode.rb +21 -17
- data/lib/spoom/deadcode/index.rb +178 -10
- data/lib/spoom/deadcode/indexer.rb +14 -435
- data/lib/spoom/deadcode/plugins/action_mailer.rb +3 -3
- data/lib/spoom/deadcode/plugins/action_mailer_preview.rb +9 -3
- data/lib/spoom/deadcode/plugins/actionpack.rb +12 -9
- data/lib/spoom/deadcode/plugins/active_model.rb +9 -9
- data/lib/spoom/deadcode/plugins/active_record.rb +5 -5
- data/lib/spoom/deadcode/plugins/active_support.rb +4 -4
- data/lib/spoom/deadcode/plugins/base.rb +70 -57
- data/lib/spoom/deadcode/plugins/graphql.rb +8 -8
- data/lib/spoom/deadcode/plugins/minitest.rb +31 -12
- data/lib/spoom/deadcode/plugins/namespaces.rb +9 -12
- data/lib/spoom/deadcode/plugins/rails.rb +9 -9
- data/lib/spoom/deadcode/plugins/rubocop.rb +13 -17
- data/lib/spoom/deadcode/plugins/ruby.rb +9 -9
- data/lib/spoom/deadcode/plugins/sorbet.rb +15 -18
- data/lib/spoom/deadcode/plugins/thor.rb +5 -4
- data/lib/spoom/deadcode/plugins.rb +4 -5
- data/lib/spoom/deadcode/remover.rb +7 -7
- data/lib/spoom/deadcode/send.rb +1 -0
- data/lib/spoom/deadcode.rb +4 -73
- data/lib/spoom/location.rb +139 -0
- data/lib/spoom/model/builder.rb +246 -0
- data/lib/spoom/model/model.rb +328 -0
- data/lib/spoom/model/namespace_visitor.rb +50 -0
- data/lib/spoom/model/reference.rb +49 -0
- data/lib/spoom/model/references_visitor.rb +200 -0
- data/lib/spoom/model.rb +10 -0
- data/lib/spoom/parse.rb +28 -0
- data/lib/spoom/poset.rb +197 -0
- data/lib/spoom/sorbet/errors.rb +5 -3
- data/lib/spoom/sorbet/lsp/errors.rb +1 -1
- data/lib/spoom/sorbet.rb +1 -1
- data/lib/spoom/version.rb +1 -1
- data/lib/spoom/visitor.rb +755 -0
- data/lib/spoom.rb +2 -0
- metadata +16 -9
- data/lib/spoom/deadcode/location.rb +0 -86
- data/lib/spoom/deadcode/reference.rb +0 -34
- data/lib/spoom/deadcode/visitor.rb +0 -755
data/lib/spoom.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spoom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Terrasa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.28.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.28.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sorbet-static-and-runtime
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,7 +165,6 @@ files:
|
|
165
165
|
- lib/spoom/deadcode/erb.rb
|
166
166
|
- lib/spoom/deadcode/index.rb
|
167
167
|
- lib/spoom/deadcode/indexer.rb
|
168
|
-
- lib/spoom/deadcode/location.rb
|
169
168
|
- lib/spoom/deadcode/plugins.rb
|
170
169
|
- lib/spoom/deadcode/plugins/action_mailer.rb
|
171
170
|
- lib/spoom/deadcode/plugins/action_mailer_preview.rb
|
@@ -185,12 +184,19 @@ files:
|
|
185
184
|
- lib/spoom/deadcode/plugins/ruby.rb
|
186
185
|
- lib/spoom/deadcode/plugins/sorbet.rb
|
187
186
|
- lib/spoom/deadcode/plugins/thor.rb
|
188
|
-
- lib/spoom/deadcode/reference.rb
|
189
187
|
- lib/spoom/deadcode/remover.rb
|
190
188
|
- lib/spoom/deadcode/send.rb
|
191
|
-
- lib/spoom/deadcode/visitor.rb
|
192
189
|
- lib/spoom/file_collector.rb
|
193
190
|
- lib/spoom/file_tree.rb
|
191
|
+
- lib/spoom/location.rb
|
192
|
+
- lib/spoom/model.rb
|
193
|
+
- lib/spoom/model/builder.rb
|
194
|
+
- lib/spoom/model/model.rb
|
195
|
+
- lib/spoom/model/namespace_visitor.rb
|
196
|
+
- lib/spoom/model/reference.rb
|
197
|
+
- lib/spoom/model/references_visitor.rb
|
198
|
+
- lib/spoom/parse.rb
|
199
|
+
- lib/spoom/poset.rb
|
194
200
|
- lib/spoom/printer.rb
|
195
201
|
- lib/spoom/sorbet.rb
|
196
202
|
- lib/spoom/sorbet/config.rb
|
@@ -203,6 +209,7 @@ files:
|
|
203
209
|
- lib/spoom/sorbet/sigils.rb
|
204
210
|
- lib/spoom/timeline.rb
|
205
211
|
- lib/spoom/version.rb
|
212
|
+
- lib/spoom/visitor.rb
|
206
213
|
- templates/card.erb
|
207
214
|
- templates/card_snapshot.erb
|
208
215
|
- templates/page.erb
|
@@ -219,14 +226,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
226
|
requirements:
|
220
227
|
- - ">="
|
221
228
|
- !ruby/object:Gem::Version
|
222
|
-
version: 3.
|
229
|
+
version: '3.1'
|
223
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
231
|
requirements:
|
225
232
|
- - ">="
|
226
233
|
- !ruby/object:Gem::Version
|
227
234
|
version: '0'
|
228
235
|
requirements: []
|
229
|
-
rubygems_version: 3.5.
|
236
|
+
rubygems_version: 3.5.3
|
230
237
|
signing_key:
|
231
238
|
specification_version: 4
|
232
239
|
summary: Useful tools for Sorbet enthusiasts.
|
@@ -1,86 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Spoom
|
5
|
-
module Deadcode
|
6
|
-
class Location
|
7
|
-
extend T::Sig
|
8
|
-
|
9
|
-
include Comparable
|
10
|
-
|
11
|
-
class LocationError < Spoom::Error; end
|
12
|
-
|
13
|
-
class << self
|
14
|
-
extend T::Sig
|
15
|
-
|
16
|
-
sig { params(location_string: String).returns(Location) }
|
17
|
-
def from_string(location_string)
|
18
|
-
file, rest = location_string.split(":", 2)
|
19
|
-
raise LocationError, "Invalid location string: #{location_string}" unless file && rest
|
20
|
-
|
21
|
-
start_line, rest = rest.split(":", 2)
|
22
|
-
raise LocationError, "Invalid location string: #{location_string}" unless start_line && rest
|
23
|
-
|
24
|
-
start_column, rest = rest.split("-", 2)
|
25
|
-
raise LocationError, "Invalid location string: #{location_string}" unless start_column && rest
|
26
|
-
|
27
|
-
end_line, end_column = rest.split(":", 2)
|
28
|
-
raise LocationError, "Invalid location string: #{location_string}" unless end_line && end_column
|
29
|
-
|
30
|
-
new(file, start_line.to_i, start_column.to_i, end_line.to_i, end_column.to_i)
|
31
|
-
end
|
32
|
-
|
33
|
-
sig { params(file: String, location: Prism::Location).returns(Location) }
|
34
|
-
def from_prism(file, location)
|
35
|
-
new(file, location.start_line, location.start_column, location.end_line, location.end_column)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
sig { returns(String) }
|
40
|
-
attr_reader :file
|
41
|
-
|
42
|
-
sig { returns(Integer) }
|
43
|
-
attr_reader :start_line, :start_column, :end_line, :end_column
|
44
|
-
|
45
|
-
sig do
|
46
|
-
params(
|
47
|
-
file: String,
|
48
|
-
start_line: Integer,
|
49
|
-
start_column: Integer,
|
50
|
-
end_line: Integer,
|
51
|
-
end_column: Integer,
|
52
|
-
).void
|
53
|
-
end
|
54
|
-
def initialize(file, start_line, start_column, end_line, end_column)
|
55
|
-
@file = file
|
56
|
-
@start_line = start_line
|
57
|
-
@start_column = start_column
|
58
|
-
@end_line = end_line
|
59
|
-
@end_column = end_column
|
60
|
-
end
|
61
|
-
|
62
|
-
sig { params(other: Location).returns(T::Boolean) }
|
63
|
-
def include?(other)
|
64
|
-
return false unless @file == other.file
|
65
|
-
return false if @start_line > other.start_line
|
66
|
-
return false if @start_line == other.start_line && @start_column > other.start_column
|
67
|
-
return false if @end_line < other.end_line
|
68
|
-
return false if @end_line == other.end_line && @end_column < other.end_column
|
69
|
-
|
70
|
-
true
|
71
|
-
end
|
72
|
-
|
73
|
-
sig { override.params(other: BasicObject).returns(T.nilable(Integer)) }
|
74
|
-
def <=>(other)
|
75
|
-
return unless Location === other
|
76
|
-
|
77
|
-
to_s <=> other.to_s
|
78
|
-
end
|
79
|
-
|
80
|
-
sig { returns(String) }
|
81
|
-
def to_s
|
82
|
-
"#{@file}:#{@start_line}:#{@start_column}-#{@end_line}:#{@end_column}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Spoom
|
5
|
-
module Deadcode
|
6
|
-
# A reference is a call to a method or a constant
|
7
|
-
class Reference < T::Struct
|
8
|
-
extend T::Sig
|
9
|
-
|
10
|
-
class Kind < T::Enum
|
11
|
-
enums do
|
12
|
-
Constant = new
|
13
|
-
Method = new
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
const :kind, Kind
|
18
|
-
const :name, String
|
19
|
-
const :location, Location
|
20
|
-
|
21
|
-
# Kind
|
22
|
-
|
23
|
-
sig { returns(T::Boolean) }
|
24
|
-
def constant?
|
25
|
-
kind == Kind::Constant
|
26
|
-
end
|
27
|
-
|
28
|
-
sig { returns(T::Boolean) }
|
29
|
-
def method?
|
30
|
-
kind == Kind::Method
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|