spoom 1.3.3 → 1.4.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/lib/spoom/deadcode/plugins/active_model.rb +1 -1
- data/lib/spoom/deadcode/plugins/minitest.rb +28 -9
- data/lib/spoom/location.rb +74 -19
- data/lib/spoom/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37744936fdd46ee10ee1bc3e85950a6028e78dc5c2c01b7a9308a478f19bd98a
|
4
|
+
data.tar.gz: 5f92d0f181c1fa1191a808dc550bbb8a17b5f1f299586c1233bfd210c00faf0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad03df8edb54fa5cc4f798b1654e22940d91bc063b2d7be3721d9b7bc1e97c0654589b78f632d4c7272e06fa4f85baab6d713f330da7de6c14b62d3b4e38caf
|
7
|
+
data.tar.gz: c8c98e4fe0dd941ee9c9f4d9cdd77fc37686a455fa5d0e849bfab9dceac3ea5ef5bbbde3282e144159df611225790c19d3df29b2fd5b2d995378a5f53809b3f6
|
@@ -8,20 +8,39 @@ module Spoom
|
|
8
8
|
extend T::Sig
|
9
9
|
|
10
10
|
ignore_classes_named(/Test$/)
|
11
|
+
ignore_classes_inheriting_from("Minitest::Test")
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
MINITEST_METHODS = T.let(
|
14
|
+
Set.new([
|
15
|
+
"after_all",
|
16
|
+
"around",
|
17
|
+
"around_all",
|
18
|
+
"before_all",
|
19
|
+
"setup",
|
20
|
+
"teardown",
|
21
|
+
]),
|
22
|
+
T::Set[String],
|
19
23
|
)
|
20
24
|
|
21
25
|
sig { override.params(definition: Model::Method).void }
|
22
26
|
def on_define_method(definition)
|
23
|
-
|
24
|
-
|
27
|
+
return unless definition.name.start_with?("test_") || MINITEST_METHODS.include?(definition.name)
|
28
|
+
|
29
|
+
owner = definition.owner
|
30
|
+
return unless owner.is_a?(Model::Class)
|
31
|
+
|
32
|
+
@index.ignore(definition) if ignored_subclass?(owner)
|
33
|
+
end
|
34
|
+
|
35
|
+
sig { override.params(send: Send).void }
|
36
|
+
def on_send(send)
|
37
|
+
case send.name
|
38
|
+
when "assert_predicate", "refute_predicate"
|
39
|
+
name = send.args[1]&.slice
|
40
|
+
return unless name
|
41
|
+
|
42
|
+
@index.reference_method(name.delete_prefix(":"), send.location)
|
43
|
+
end
|
25
44
|
end
|
26
45
|
end
|
27
46
|
end
|
data/lib/spoom/location.rb
CHANGED
@@ -15,42 +15,73 @@ module Spoom
|
|
15
15
|
sig { params(location_string: String).returns(Location) }
|
16
16
|
def from_string(location_string)
|
17
17
|
file, rest = location_string.split(":", 2)
|
18
|
-
raise LocationError, "Invalid location string
|
18
|
+
raise LocationError, "Invalid location string `#{location_string}`: missing file name" unless file
|
19
|
+
|
20
|
+
return new(file) if rest.nil?
|
19
21
|
|
20
22
|
start_line, rest = rest.split(":", 2)
|
21
|
-
|
23
|
+
if rest.nil?
|
24
|
+
start_line, end_line = T.must(start_line).split("-", 2)
|
25
|
+
raise LocationError, "Invalid location string `#{location_string}`: missing end line" unless end_line
|
26
|
+
|
27
|
+
return new(file, start_line: start_line.to_i, end_line: end_line.to_i) if end_line
|
28
|
+
end
|
22
29
|
|
23
30
|
start_column, rest = rest.split("-", 2)
|
24
|
-
raise LocationError, "Invalid location string
|
31
|
+
raise LocationError, "Invalid location string `#{location_string}`: missing end line and column" if rest.nil?
|
25
32
|
|
26
33
|
end_line, end_column = rest.split(":", 2)
|
27
|
-
raise LocationError,
|
28
|
-
|
29
|
-
|
34
|
+
raise LocationError,
|
35
|
+
"Invalid location string `#{location_string}`: missing end column" unless end_line && end_column
|
36
|
+
|
37
|
+
new(
|
38
|
+
file,
|
39
|
+
start_line: start_line.to_i,
|
40
|
+
start_column: start_column.to_i,
|
41
|
+
end_line: end_line.to_i,
|
42
|
+
end_column: end_column.to_i,
|
43
|
+
)
|
30
44
|
end
|
31
45
|
|
32
46
|
sig { params(file: String, location: Prism::Location).returns(Location) }
|
33
47
|
def from_prism(file, location)
|
34
|
-
new(
|
48
|
+
new(
|
49
|
+
file,
|
50
|
+
start_line: location.start_line,
|
51
|
+
start_column: location.start_column,
|
52
|
+
end_line: location.end_line,
|
53
|
+
end_column: location.end_column,
|
54
|
+
)
|
35
55
|
end
|
36
56
|
end
|
37
57
|
|
38
58
|
sig { returns(String) }
|
39
59
|
attr_reader :file
|
40
60
|
|
41
|
-
sig { returns(Integer) }
|
61
|
+
sig { returns(T.nilable(Integer)) }
|
42
62
|
attr_reader :start_line, :start_column, :end_line, :end_column
|
43
63
|
|
44
64
|
sig do
|
45
65
|
params(
|
46
66
|
file: String,
|
47
|
-
start_line: Integer,
|
48
|
-
start_column: Integer,
|
49
|
-
end_line: Integer,
|
50
|
-
end_column: Integer,
|
67
|
+
start_line: T.nilable(Integer),
|
68
|
+
start_column: T.nilable(Integer),
|
69
|
+
end_line: T.nilable(Integer),
|
70
|
+
end_column: T.nilable(Integer),
|
51
71
|
).void
|
52
72
|
end
|
53
|
-
def initialize(file, start_line, start_column, end_line, end_column)
|
73
|
+
def initialize(file, start_line: nil, start_column: nil, end_line: nil, end_column: nil)
|
74
|
+
raise LocationError,
|
75
|
+
"Invalid location: end line is required if start line is provided" if start_line && !end_line
|
76
|
+
raise LocationError,
|
77
|
+
"Invalid location: start line is required if end line is provided" if !start_line && end_line
|
78
|
+
raise LocationError,
|
79
|
+
"Invalid location: end column is required if start column is provided" if start_column && !end_column
|
80
|
+
raise LocationError,
|
81
|
+
"Invalid location: start column is required if end column is provided" if !start_column && end_column
|
82
|
+
raise LocationError,
|
83
|
+
"Invalid location: lines are required if columns are provided" if start_column && !start_line
|
84
|
+
|
54
85
|
@file = file
|
55
86
|
@start_line = start_line
|
56
87
|
@start_column = start_column
|
@@ -61,10 +92,12 @@ module Spoom
|
|
61
92
|
sig { params(other: Location).returns(T::Boolean) }
|
62
93
|
def include?(other)
|
63
94
|
return false unless @file == other.file
|
64
|
-
return false if @start_line > other.start_line
|
65
|
-
return false if @start_line == other.start_line &&
|
66
|
-
|
67
|
-
return false if @end_line
|
95
|
+
return false if (@start_line || -Float::INFINITY) > (other.start_line || -Float::INFINITY)
|
96
|
+
return false if @start_line == other.start_line &&
|
97
|
+
(@start_column || -Float::INFINITY) > (other.start_column || -Float::INFINITY)
|
98
|
+
return false if (@end_line || Float::INFINITY) < (other.end_line || Float::INFINITY)
|
99
|
+
return false if @end_line == other.end_line &&
|
100
|
+
(@end_column || Float::INFINITY) < (other.end_column || Float::INFINITY)
|
68
101
|
|
69
102
|
true
|
70
103
|
end
|
@@ -73,12 +106,34 @@ module Spoom
|
|
73
106
|
def <=>(other)
|
74
107
|
return unless Location === other
|
75
108
|
|
76
|
-
|
109
|
+
comparison_array_self = [
|
110
|
+
@file,
|
111
|
+
@start_line || -Float::INFINITY,
|
112
|
+
@start_column || -Float::INFINITY,
|
113
|
+
@end_line || Float::INFINITY,
|
114
|
+
@end_column || Float::INFINITY,
|
115
|
+
]
|
116
|
+
|
117
|
+
comparison_array_other = [
|
118
|
+
other.file,
|
119
|
+
other.start_line || -Float::INFINITY,
|
120
|
+
other.start_column || -Float::INFINITY,
|
121
|
+
other.end_line || Float::INFINITY,
|
122
|
+
other.end_column || Float::INFINITY,
|
123
|
+
]
|
124
|
+
|
125
|
+
comparison_array_self <=> comparison_array_other
|
77
126
|
end
|
78
127
|
|
79
128
|
sig { returns(String) }
|
80
129
|
def to_s
|
81
|
-
|
130
|
+
if @start_line && @start_column
|
131
|
+
"#{@file}:#{@start_line}:#{@start_column}-#{@end_line}:#{@end_column}"
|
132
|
+
elsif @start_line
|
133
|
+
"#{@file}:#{@start_line}-#{@end_line}"
|
134
|
+
else
|
135
|
+
@file
|
136
|
+
end
|
82
137
|
end
|
83
138
|
end
|
84
139
|
end
|
data/lib/spoom/version.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.1
|
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-07-
|
11
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
- !ruby/object:Gem::Version
|
234
234
|
version: '0'
|
235
235
|
requirements: []
|
236
|
-
rubygems_version: 3.5.
|
236
|
+
rubygems_version: 3.5.16
|
237
237
|
signing_key:
|
238
238
|
specification_version: 4
|
239
239
|
summary: Useful tools for Sorbet enthusiasts.
|