pack_stats 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pack_stats/private/metrics/nested_packs.rb +1 -1
- data/lib/pack_stats/private/metrics/packwerk_checker_usage.rb +6 -8
- data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
- data/sorbet/rbi/gems/{parse_packwerk@0.14.0.rbi → parse_packwerk@0.16.0.rbi} +84 -15
- data/sorbet/rbi/gems/rubocop-packs@0.0.30.rbi +272 -0
- metadata +5 -4
- data/sorbet/rbi/gems/rubocop-packs@0.0.20.rbi +0 -141
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da5c8a0753cdd0e4b878fc2fb2c2732fc5ca3664b1e53dc55f9c16e3b7f43fef
|
4
|
+
data.tar.gz: a57f443a4572e99c7bd8c187d5b963ff9fdecebf71cf5d1339518ea3f89d5852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c1bed7cbd4c71fe9937b9ea9ceb47a9784b7852f3a788f0f69c240848dd1d106e5be56a0005a2f6785f5e948c3419b2c9d7094bca559112e3289fe4334ea3ed
|
7
|
+
data.tar.gz: 06c0b6fd7a7af65934ad6c6f346bb0fafa61874742c12f4d752b8437e5f6024c34153a079c0666004d68eac8c693fbd5354a62d2fc7d45e8bdb6615ded6d0569
|
@@ -53,7 +53,7 @@ module PackStats
|
|
53
53
|
sig { returns(T::Array[ParsePackwerk::Violation]) }
|
54
54
|
def cross_group_violations
|
55
55
|
all_violations = members.flat_map do |member|
|
56
|
-
ParsePackwerk::
|
56
|
+
ParsePackwerk::PackageTodo.for(member).violations
|
57
57
|
end
|
58
58
|
|
59
59
|
all_violations.select do |violation|
|
@@ -12,7 +12,6 @@ module PackStats
|
|
12
12
|
# Later, we might find a way we can get this directly from `packwerk`
|
13
13
|
class PackwerkChecker < T::Struct
|
14
14
|
const :setting, String
|
15
|
-
const :strict_mode, String
|
16
15
|
end
|
17
16
|
|
18
17
|
sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) }
|
@@ -20,22 +19,21 @@ module PackStats
|
|
20
19
|
metrics = T.let([], T::Array[GaugeMetric])
|
21
20
|
|
22
21
|
checkers = [
|
23
|
-
PackwerkChecker.new(setting: 'enforce_dependencies'
|
24
|
-
PackwerkChecker.new(setting: 'enforce_privacy'
|
22
|
+
PackwerkChecker.new(setting: 'enforce_dependencies'),
|
23
|
+
PackwerkChecker.new(setting: 'enforce_privacy')
|
25
24
|
]
|
26
25
|
|
27
26
|
checkers.each do |checker|
|
28
27
|
['false', 'true', 'strict'].each do |enabled_mode|
|
29
28
|
count_of_packages = ParsePackwerk.all.count do |package|
|
30
|
-
|
31
|
-
enabled = YAML.load_file(package.yml)[checker.setting]
|
29
|
+
checker_setting = YAML.load_file(package.yml)[checker.setting]
|
32
30
|
case enabled_mode
|
33
31
|
when 'false'
|
34
|
-
!
|
32
|
+
!checker_setting
|
35
33
|
when 'true'
|
36
|
-
|
34
|
+
checker_setting && checker_setting != 'strict'
|
37
35
|
when 'strict'
|
38
|
-
|
36
|
+
checker_setting == 'strict'
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
@@ -0,0 +1,584 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `ast` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem ast`.
|
6
|
+
|
7
|
+
# {AST} is a library for manipulating abstract syntax trees.
|
8
|
+
#
|
9
|
+
# It embraces immutability; each AST node is inherently frozen at
|
10
|
+
# creation, and updating a child node requires recreating that node
|
11
|
+
# and its every parent, recursively.
|
12
|
+
# This is a design choice. It does create some pressure on
|
13
|
+
# garbage collector, but completely eliminates all concurrency
|
14
|
+
# and aliasing problems.
|
15
|
+
#
|
16
|
+
# See also {AST::Node}, {AST::Processor::Mixin} and {AST::Sexp} for
|
17
|
+
# additional recommendations and design patterns.
|
18
|
+
#
|
19
|
+
# source://ast//lib/ast.rb#13
|
20
|
+
module AST; end
|
21
|
+
|
22
|
+
# Node is an immutable class, instances of which represent abstract
|
23
|
+
# syntax tree nodes. It combines semantic information (i.e. anything
|
24
|
+
# that affects the algorithmic properties of a program) with
|
25
|
+
# meta-information (line numbers or compiler intermediates).
|
26
|
+
#
|
27
|
+
# Notes on inheritance
|
28
|
+
# ====================
|
29
|
+
#
|
30
|
+
# The distinction between semantics and metadata is important. Complete
|
31
|
+
# semantic information should be contained within just the {#type} and
|
32
|
+
# {#children} of a Node instance; in other words, if an AST was to be
|
33
|
+
# stripped of all meta-information, it should remain a valid AST which
|
34
|
+
# could be successfully processed to yield a result with the same
|
35
|
+
# algorithmic properties.
|
36
|
+
#
|
37
|
+
# Thus, Node should never be inherited in order to define methods which
|
38
|
+
# affect or return semantic information, such as getters for `class_name`,
|
39
|
+
# `superclass` and `body` in the case of a hypothetical `ClassNode`. The
|
40
|
+
# correct solution is to use a generic Node with a {#type} of `:class`
|
41
|
+
# and three children. See also {Processor} for tips on working with such
|
42
|
+
# ASTs.
|
43
|
+
#
|
44
|
+
# On the other hand, Node can and should be inherited to define
|
45
|
+
# application-specific metadata (see also {#initialize}) or customize the
|
46
|
+
# printing format. It is expected that an application would have one or two
|
47
|
+
# such classes and use them across the entire codebase.
|
48
|
+
#
|
49
|
+
# The rationale for this pattern is extensibility and maintainability.
|
50
|
+
# Unlike static ones, dynamic languages do not require the presence of a
|
51
|
+
# predefined, rigid structure, nor does it improve dispatch efficiency,
|
52
|
+
# and while such a structure can certainly be defined, it does not add
|
53
|
+
# any value but incurs a maintaining cost.
|
54
|
+
# For example, extending the AST even with a transformation-local
|
55
|
+
# temporary node type requires making globally visible changes to
|
56
|
+
# the codebase.
|
57
|
+
#
|
58
|
+
# source://ast//lib/ast/node.rb#40
|
59
|
+
class AST::Node
|
60
|
+
# Constructs a new instance of Node.
|
61
|
+
#
|
62
|
+
# The arguments `type` and `children` are converted with `to_sym` and
|
63
|
+
# `to_a` respectively. Additionally, the result of converting `children`
|
64
|
+
# is frozen. While mutating the arguments is generally considered harmful,
|
65
|
+
# the most common case is to pass an array literal to the constructor. If
|
66
|
+
# your code does not expect the argument to be frozen, use `#dup`.
|
67
|
+
#
|
68
|
+
# The `properties` hash is passed to {#assign_properties}.
|
69
|
+
#
|
70
|
+
# @return [Node] a new instance of Node
|
71
|
+
#
|
72
|
+
# source://ast//lib/ast/node.rb#72
|
73
|
+
def initialize(type, children = T.unsafe(nil), properties = T.unsafe(nil)); end
|
74
|
+
|
75
|
+
# Concatenates `array` with `children` and returns the resulting node.
|
76
|
+
#
|
77
|
+
# @return [AST::Node]
|
78
|
+
#
|
79
|
+
# source://ast//lib/ast/node.rb#168
|
80
|
+
def +(array); end
|
81
|
+
|
82
|
+
# Appends `element` to `children` and returns the resulting node.
|
83
|
+
#
|
84
|
+
# @return [AST::Node]
|
85
|
+
#
|
86
|
+
# source://ast//lib/ast/node.rb#177
|
87
|
+
def <<(element); end
|
88
|
+
|
89
|
+
# Compares `self` to `other`, possibly converting with `to_ast`. Only
|
90
|
+
# `type` and `children` are compared; metadata is deliberately ignored.
|
91
|
+
#
|
92
|
+
# @return [Boolean]
|
93
|
+
#
|
94
|
+
# source://ast//lib/ast/node.rb#153
|
95
|
+
def ==(other); end
|
96
|
+
|
97
|
+
# Appends `element` to `children` and returns the resulting node.
|
98
|
+
#
|
99
|
+
# @return [AST::Node]
|
100
|
+
#
|
101
|
+
# source://ast//lib/ast/node.rb#177
|
102
|
+
def append(element); end
|
103
|
+
|
104
|
+
# Returns the children of this node.
|
105
|
+
# The returned value is frozen.
|
106
|
+
# The to_a alias is useful for decomposing nodes concisely.
|
107
|
+
# For example:
|
108
|
+
#
|
109
|
+
# node = s(:gasgn, :$foo, s(:integer, 1))
|
110
|
+
# var_name, value = *node
|
111
|
+
# p var_name # => :$foo
|
112
|
+
# p value # => (integer 1)
|
113
|
+
#
|
114
|
+
# @return [Array]
|
115
|
+
#
|
116
|
+
# source://ast//lib/ast/node.rb#56
|
117
|
+
def children; end
|
118
|
+
|
119
|
+
# Nodes are already frozen, so there is no harm in returning the
|
120
|
+
# current node as opposed to initializing from scratch and freezing
|
121
|
+
# another one.
|
122
|
+
#
|
123
|
+
# @return self
|
124
|
+
#
|
125
|
+
# source://ast//lib/ast/node.rb#115
|
126
|
+
def clone; end
|
127
|
+
|
128
|
+
# Concatenates `array` with `children` and returns the resulting node.
|
129
|
+
#
|
130
|
+
# @return [AST::Node]
|
131
|
+
#
|
132
|
+
# source://ast//lib/ast/node.rb#168
|
133
|
+
def concat(array); end
|
134
|
+
|
135
|
+
# Enables matching for Node, where type is the first element
|
136
|
+
# and the children are remaining items.
|
137
|
+
#
|
138
|
+
# @return [Array]
|
139
|
+
#
|
140
|
+
# source://ast//lib/ast/node.rb#253
|
141
|
+
def deconstruct; end
|
142
|
+
|
143
|
+
# Nodes are already frozen, so there is no harm in returning the
|
144
|
+
# current node as opposed to initializing from scratch and freezing
|
145
|
+
# another one.
|
146
|
+
#
|
147
|
+
# @return self
|
148
|
+
#
|
149
|
+
# source://ast//lib/ast/node.rb#115
|
150
|
+
def dup; end
|
151
|
+
|
152
|
+
# Test if other object is equal to
|
153
|
+
#
|
154
|
+
# @param other [Object]
|
155
|
+
# @return [Boolean]
|
156
|
+
#
|
157
|
+
# source://ast//lib/ast/node.rb#85
|
158
|
+
def eql?(other); end
|
159
|
+
|
160
|
+
# Returns the precomputed hash value for this node
|
161
|
+
#
|
162
|
+
# @return [Fixnum]
|
163
|
+
#
|
164
|
+
# source://ast//lib/ast/node.rb#61
|
165
|
+
def hash; end
|
166
|
+
|
167
|
+
# Converts `self` to a s-expression ruby string.
|
168
|
+
# The code return will recreate the node, using the sexp module s()
|
169
|
+
#
|
170
|
+
# @param indent [Integer] Base indentation level.
|
171
|
+
# @return [String]
|
172
|
+
#
|
173
|
+
# source://ast//lib/ast/node.rb#211
|
174
|
+
def inspect(indent = T.unsafe(nil)); end
|
175
|
+
|
176
|
+
# Returns the children of this node.
|
177
|
+
# The returned value is frozen.
|
178
|
+
# The to_a alias is useful for decomposing nodes concisely.
|
179
|
+
# For example:
|
180
|
+
#
|
181
|
+
# node = s(:gasgn, :$foo, s(:integer, 1))
|
182
|
+
# var_name, value = *node
|
183
|
+
# p var_name # => :$foo
|
184
|
+
# p value # => (integer 1)
|
185
|
+
#
|
186
|
+
# @return [Array]
|
187
|
+
#
|
188
|
+
# source://ast//lib/ast/node.rb#56
|
189
|
+
def to_a; end
|
190
|
+
|
191
|
+
# @return [AST::Node] self
|
192
|
+
#
|
193
|
+
# source://ast//lib/ast/node.rb#229
|
194
|
+
def to_ast; end
|
195
|
+
|
196
|
+
# Converts `self` to a pretty-printed s-expression.
|
197
|
+
#
|
198
|
+
# @param indent [Integer] Base indentation level.
|
199
|
+
# @return [String]
|
200
|
+
#
|
201
|
+
# source://ast//lib/ast/node.rb#187
|
202
|
+
def to_s(indent = T.unsafe(nil)); end
|
203
|
+
|
204
|
+
# Converts `self` to a pretty-printed s-expression.
|
205
|
+
#
|
206
|
+
# @param indent [Integer] Base indentation level.
|
207
|
+
# @return [String]
|
208
|
+
#
|
209
|
+
# source://ast//lib/ast/node.rb#187
|
210
|
+
def to_sexp(indent = T.unsafe(nil)); end
|
211
|
+
|
212
|
+
# Converts `self` to an Array where the first element is the type as a Symbol,
|
213
|
+
# and subsequent elements are the same representation of its children.
|
214
|
+
#
|
215
|
+
# @return [Array<Symbol, [...Array]>]
|
216
|
+
#
|
217
|
+
# source://ast//lib/ast/node.rb#237
|
218
|
+
def to_sexp_array; end
|
219
|
+
|
220
|
+
# Returns the type of this node.
|
221
|
+
#
|
222
|
+
# @return [Symbol]
|
223
|
+
#
|
224
|
+
# source://ast//lib/ast/node.rb#43
|
225
|
+
def type; end
|
226
|
+
|
227
|
+
# Returns a new instance of Node where non-nil arguments replace the
|
228
|
+
# corresponding fields of `self`.
|
229
|
+
#
|
230
|
+
# For example, `Node.new(:foo, [ 1, 2 ]).updated(:bar)` would yield
|
231
|
+
# `(bar 1 2)`, and `Node.new(:foo, [ 1, 2 ]).updated(nil, [])` would
|
232
|
+
# yield `(foo)`.
|
233
|
+
#
|
234
|
+
# If the resulting node would be identical to `self`, does nothing.
|
235
|
+
#
|
236
|
+
# @param type [Symbol, nil]
|
237
|
+
# @param children [Array, nil]
|
238
|
+
# @param properties [Hash, nil]
|
239
|
+
# @return [AST::Node]
|
240
|
+
#
|
241
|
+
# source://ast//lib/ast/node.rb#133
|
242
|
+
def updated(type = T.unsafe(nil), children = T.unsafe(nil), properties = T.unsafe(nil)); end
|
243
|
+
|
244
|
+
protected
|
245
|
+
|
246
|
+
# By default, each entry in the `properties` hash is assigned to
|
247
|
+
# an instance variable in this instance of Node. A subclass should define
|
248
|
+
# attribute readers for such variables. The values passed in the hash
|
249
|
+
# are not frozen or whitelisted; such behavior can also be implemented
|
250
|
+
# by subclassing Node and overriding this method.
|
251
|
+
#
|
252
|
+
# @return [nil]
|
253
|
+
#
|
254
|
+
# source://ast//lib/ast/node.rb#98
|
255
|
+
def assign_properties(properties); end
|
256
|
+
|
257
|
+
# Returns `@type` with all underscores replaced by dashes. This allows
|
258
|
+
# to write symbol literals without quotes in Ruby sources and yet have
|
259
|
+
# nicely looking s-expressions.
|
260
|
+
#
|
261
|
+
# @return [String]
|
262
|
+
#
|
263
|
+
# source://ast//lib/ast/node.rb#264
|
264
|
+
def fancy_type; end
|
265
|
+
|
266
|
+
private
|
267
|
+
|
268
|
+
def original_dup; end
|
269
|
+
end
|
270
|
+
|
271
|
+
# This class includes {AST::Processor::Mixin}; however, it is
|
272
|
+
# deprecated, since the module defines all of the behaviors that
|
273
|
+
# the processor includes. Any new libraries should use
|
274
|
+
# {AST::Processor::Mixin} instead of subclassing this.
|
275
|
+
#
|
276
|
+
# @deprecated Use {AST::Processor::Mixin} instead.
|
277
|
+
#
|
278
|
+
# source://ast//lib/ast/processor.rb#8
|
279
|
+
class AST::Processor
|
280
|
+
include ::AST::Processor::Mixin
|
281
|
+
end
|
282
|
+
|
283
|
+
# The processor module is a module which helps transforming one
|
284
|
+
# AST into another. In a nutshell, the {#process} method accepts
|
285
|
+
# a {Node} and dispatches it to a handler corresponding to its
|
286
|
+
# type, and returns a (possibly) updated variant of the node.
|
287
|
+
#
|
288
|
+
# The processor module has a set of associated design patterns.
|
289
|
+
# They are best explained with a concrete example. Let's define a
|
290
|
+
# simple arithmetic language and an AST format for it:
|
291
|
+
#
|
292
|
+
# Terminals (AST nodes which do not have other AST nodes inside):
|
293
|
+
#
|
294
|
+
# * `(integer <int-literal>)`,
|
295
|
+
#
|
296
|
+
# Nonterminals (AST nodes with other nodes as children):
|
297
|
+
#
|
298
|
+
# * `(add <node> <node>)`,
|
299
|
+
# * `(multiply <node> <node>)`,
|
300
|
+
# * `(divide <node> <node>)`,
|
301
|
+
# * `(negate <node>)`,
|
302
|
+
# * `(store <node> <string-literal>)`: stores value of `<node>`
|
303
|
+
# into a variable named `<string-literal>`,
|
304
|
+
# * `(load <string-literal>)`: loads value of a variable named
|
305
|
+
# `<string-literal>`,
|
306
|
+
# * `(each <node> ...)`: computes each of the `<node>`s and
|
307
|
+
# prints the result.
|
308
|
+
#
|
309
|
+
# All AST nodes have the same Ruby class, and therefore they don't
|
310
|
+
# know how to traverse themselves. (A solution which dynamically
|
311
|
+
# checks the type of children is possible, but is slow and
|
312
|
+
# error-prone.) So, a class including the module which knows how
|
313
|
+
# to traverse the entire tree should be defined. Such classes
|
314
|
+
# have a handler for each nonterminal node which recursively
|
315
|
+
# processes children nodes:
|
316
|
+
#
|
317
|
+
# require 'ast'
|
318
|
+
#
|
319
|
+
# class ArithmeticsProcessor
|
320
|
+
# include AST::Processor::Mixin
|
321
|
+
# # This method traverses any binary operators such as (add)
|
322
|
+
# # or (multiply).
|
323
|
+
# def process_binary_op(node)
|
324
|
+
# # Children aren't decomposed automatically; it is
|
325
|
+
# # suggested to use Ruby multiple assignment expansion,
|
326
|
+
# # as it is very convenient here.
|
327
|
+
# left_expr, right_expr = *node
|
328
|
+
#
|
329
|
+
# # AST::Node#updated won't change node type if nil is
|
330
|
+
# # passed as a first argument, which allows to reuse the
|
331
|
+
# # same handler for multiple node types using `alias'
|
332
|
+
# # (below).
|
333
|
+
# node.updated(nil, [
|
334
|
+
# process(left_expr),
|
335
|
+
# process(right_expr)
|
336
|
+
# ])
|
337
|
+
# end
|
338
|
+
# alias_method :on_add, :process_binary_op
|
339
|
+
# alias_method :on_multiply, :process_binary_op
|
340
|
+
# alias_method :on_divide, :process_binary_op
|
341
|
+
#
|
342
|
+
# def on_negate(node)
|
343
|
+
# # It is also possible to use #process_all for more
|
344
|
+
# # compact code if every child is a Node.
|
345
|
+
# node.updated(nil, process_all(node))
|
346
|
+
# end
|
347
|
+
#
|
348
|
+
# def on_store(node)
|
349
|
+
# expr, variable_name = *node
|
350
|
+
#
|
351
|
+
# # Note that variable_name is not a Node and thus isn't
|
352
|
+
# # passed to #process.
|
353
|
+
# node.updated(nil, [
|
354
|
+
# process(expr),
|
355
|
+
# variable_name
|
356
|
+
# ])
|
357
|
+
# end
|
358
|
+
#
|
359
|
+
# # (load) is effectively a terminal node, and so it does
|
360
|
+
# # not need an explicit handler, as the following is the
|
361
|
+
# # default behavior. Essentially, for any nodes that don't
|
362
|
+
# # have a defined handler, the node remains unchanged.
|
363
|
+
# def on_load(node)
|
364
|
+
# nil
|
365
|
+
# end
|
366
|
+
#
|
367
|
+
# def on_each(node)
|
368
|
+
# node.updated(nil, process_all(node))
|
369
|
+
# end
|
370
|
+
# end
|
371
|
+
#
|
372
|
+
# Let's test our ArithmeticsProcessor:
|
373
|
+
#
|
374
|
+
# include AST::Sexp
|
375
|
+
# expr = s(:add, s(:integer, 2), s(:integer, 2))
|
376
|
+
#
|
377
|
+
# p ArithmeticsProcessor.new.process(expr) == expr # => true
|
378
|
+
#
|
379
|
+
# As expected, it does not change anything at all. This isn't
|
380
|
+
# actually very useful, so let's now define a Calculator, which
|
381
|
+
# will compute the expression values:
|
382
|
+
#
|
383
|
+
# # This Processor folds nonterminal nodes and returns an
|
384
|
+
# # (integer) terminal node.
|
385
|
+
# class ArithmeticsCalculator < ArithmeticsProcessor
|
386
|
+
# def compute_op(node)
|
387
|
+
# # First, node children are processed and then unpacked
|
388
|
+
# # to local variables.
|
389
|
+
# nodes = process_all(node)
|
390
|
+
#
|
391
|
+
# if nodes.all? { |node| node.type == :integer }
|
392
|
+
# # If each of those nodes represents a literal, we can
|
393
|
+
# # fold this node!
|
394
|
+
# values = nodes.map { |node| node.children.first }
|
395
|
+
# AST::Node.new(:integer, [
|
396
|
+
# yield(values)
|
397
|
+
# ])
|
398
|
+
# else
|
399
|
+
# # Otherwise, we can just leave the current node in the
|
400
|
+
# # tree and only update it with processed children
|
401
|
+
# # nodes, which can be partially folded.
|
402
|
+
# node.updated(nil, nodes)
|
403
|
+
# end
|
404
|
+
# end
|
405
|
+
#
|
406
|
+
# def on_add(node)
|
407
|
+
# compute_op(node) { |left, right| left + right }
|
408
|
+
# end
|
409
|
+
#
|
410
|
+
# def on_multiply(node)
|
411
|
+
# compute_op(node) { |left, right| left * right }
|
412
|
+
# end
|
413
|
+
# end
|
414
|
+
#
|
415
|
+
# Let's check:
|
416
|
+
#
|
417
|
+
# p ArithmeticsCalculator.new.process(expr) # => (integer 4)
|
418
|
+
#
|
419
|
+
# Excellent, the calculator works! Now, a careful reader could
|
420
|
+
# notice that the ArithmeticsCalculator does not know how to
|
421
|
+
# divide numbers. What if we pass an expression with division to
|
422
|
+
# it?
|
423
|
+
#
|
424
|
+
# expr_with_division = \
|
425
|
+
# s(:add,
|
426
|
+
# s(:integer, 1),
|
427
|
+
# s(:divide,
|
428
|
+
# s(:add, s(:integer, 8), s(:integer, 4)),
|
429
|
+
# s(:integer, 3))) # 1 + (8 + 4) / 3
|
430
|
+
#
|
431
|
+
# folded_expr_with_division = ArithmeticsCalculator.new.process(expr_with_division)
|
432
|
+
# p folded_expr_with_division
|
433
|
+
# # => (add
|
434
|
+
# # (integer 1)
|
435
|
+
# # (divide
|
436
|
+
# # (integer 12)
|
437
|
+
# # (integer 3)))
|
438
|
+
#
|
439
|
+
# As you can see, the expression was folded _partially_: the inner
|
440
|
+
# `(add)` node which could be computed was folded to
|
441
|
+
# `(integer 12)`, the `(divide)` node is left as-is because there
|
442
|
+
# is no computing handler for it, and the root `(add)` node was
|
443
|
+
# also left as it is because some of its children were not
|
444
|
+
# literals.
|
445
|
+
#
|
446
|
+
# Note that this partial folding is only possible because the
|
447
|
+
# _data_ format, i.e. the format in which the computed values of
|
448
|
+
# the nodes are represented, is the same as the AST itself.
|
449
|
+
#
|
450
|
+
# Let's extend our ArithmeticsCalculator class further.
|
451
|
+
#
|
452
|
+
# class ArithmeticsCalculator
|
453
|
+
# def on_divide(node)
|
454
|
+
# compute_op(node) { |left, right| left / right }
|
455
|
+
# end
|
456
|
+
#
|
457
|
+
# def on_negate(node)
|
458
|
+
# # Note how #compute_op works regardless of the operator
|
459
|
+
# # arity.
|
460
|
+
# compute_op(node) { |value| -value }
|
461
|
+
# end
|
462
|
+
# end
|
463
|
+
#
|
464
|
+
# Now, let's apply our renewed ArithmeticsCalculator to a partial
|
465
|
+
# result of previous evaluation:
|
466
|
+
#
|
467
|
+
# p ArithmeticsCalculator.new.process(expr_with_division) # => (integer 5)
|
468
|
+
#
|
469
|
+
# Five! Excellent. This is also pretty much how CRuby 1.8 executed
|
470
|
+
# its programs.
|
471
|
+
#
|
472
|
+
# Now, let's do some automated bug searching. Division by zero is
|
473
|
+
# an error, right? So if we could detect that someone has divided
|
474
|
+
# by zero before the program is even run, that could save some
|
475
|
+
# debugging time.
|
476
|
+
#
|
477
|
+
# class DivisionByZeroVerifier < ArithmeticsProcessor
|
478
|
+
# class VerificationFailure < Exception; end
|
479
|
+
#
|
480
|
+
# def on_divide(node)
|
481
|
+
# # You need to process the children to handle nested divisions
|
482
|
+
# # such as:
|
483
|
+
# # (divide
|
484
|
+
# # (integer 1)
|
485
|
+
# # (divide (integer 1) (integer 0))
|
486
|
+
# left, right = process_all(node)
|
487
|
+
#
|
488
|
+
# if right.type == :integer &&
|
489
|
+
# right.children.first == 0
|
490
|
+
# raise VerificationFailure, "Ouch! This code divides by zero."
|
491
|
+
# end
|
492
|
+
# end
|
493
|
+
#
|
494
|
+
# def divides_by_zero?(ast)
|
495
|
+
# process(ast)
|
496
|
+
# false
|
497
|
+
# rescue VerificationFailure
|
498
|
+
# true
|
499
|
+
# end
|
500
|
+
# end
|
501
|
+
#
|
502
|
+
# nice_expr = \
|
503
|
+
# s(:divide,
|
504
|
+
# s(:add, s(:integer, 10), s(:integer, 2)),
|
505
|
+
# s(:integer, 4))
|
506
|
+
#
|
507
|
+
# p DivisionByZeroVerifier.new.divides_by_zero?(nice_expr)
|
508
|
+
# # => false. Good.
|
509
|
+
#
|
510
|
+
# bad_expr = \
|
511
|
+
# s(:add, s(:integer, 10),
|
512
|
+
# s(:divide, s(:integer, 1), s(:integer, 0)))
|
513
|
+
#
|
514
|
+
# p DivisionByZeroVerifier.new.divides_by_zero?(bad_expr)
|
515
|
+
# # => true. WHOOPS. DO NOT RUN THIS.
|
516
|
+
#
|
517
|
+
# Of course, this won't detect more complex cases... unless you
|
518
|
+
# use some partial evaluation before! The possibilites are
|
519
|
+
# endless. Have fun.
|
520
|
+
#
|
521
|
+
# source://ast//lib/ast/processor/mixin.rb#240
|
522
|
+
module AST::Processor::Mixin
|
523
|
+
# Default handler. Does nothing.
|
524
|
+
#
|
525
|
+
# @param node [AST::Node]
|
526
|
+
# @return [AST::Node, nil]
|
527
|
+
#
|
528
|
+
# source://ast//lib/ast/processor/mixin.rb#284
|
529
|
+
def handler_missing(node); end
|
530
|
+
|
531
|
+
# Dispatches `node`. If a node has type `:foo`, then a handler
|
532
|
+
# named `on_foo` is invoked with one argument, the `node`; if
|
533
|
+
# there isn't such a handler, {#handler_missing} is invoked
|
534
|
+
# with the same argument.
|
535
|
+
#
|
536
|
+
# If the handler returns `nil`, `node` is returned; otherwise,
|
537
|
+
# the return value of the handler is passed along.
|
538
|
+
#
|
539
|
+
# @param node [AST::Node, nil]
|
540
|
+
# @return [AST::Node, nil]
|
541
|
+
#
|
542
|
+
# source://ast//lib/ast/processor/mixin.rb#251
|
543
|
+
def process(node); end
|
544
|
+
|
545
|
+
# {#process}es each node from `nodes` and returns an array of
|
546
|
+
# results.
|
547
|
+
#
|
548
|
+
# @param nodes [Array<AST::Node>]
|
549
|
+
# @return [Array<AST::Node>]
|
550
|
+
#
|
551
|
+
# source://ast//lib/ast/processor/mixin.rb#274
|
552
|
+
def process_all(nodes); end
|
553
|
+
end
|
554
|
+
|
555
|
+
# This simple module is very useful in the cases where one needs
|
556
|
+
# to define deeply nested ASTs from Ruby code, for example, in
|
557
|
+
# tests. It should be used like this:
|
558
|
+
#
|
559
|
+
# describe YourLanguage::AST do
|
560
|
+
# include Sexp
|
561
|
+
#
|
562
|
+
# it "should correctly parse expressions" do
|
563
|
+
# YourLanguage.parse("1 + 2 * 3").should ==
|
564
|
+
# s(:add,
|
565
|
+
# s(:integer, 1),
|
566
|
+
# s(:multiply,
|
567
|
+
# s(:integer, 2),
|
568
|
+
# s(:integer, 3)))
|
569
|
+
# end
|
570
|
+
# end
|
571
|
+
#
|
572
|
+
# This way the amount of boilerplate code is greatly reduced.
|
573
|
+
#
|
574
|
+
# source://ast//lib/ast/sexp.rb#20
|
575
|
+
module AST::Sexp
|
576
|
+
# Creates a {Node} with type `type` and children `children`.
|
577
|
+
# Note that the resulting node is of the type AST::Node and not a
|
578
|
+
# subclass.
|
579
|
+
# This would not pose a problem with comparisons, as {Node#==}
|
580
|
+
# ignores metadata.
|
581
|
+
#
|
582
|
+
# source://ast//lib/ast/sexp.rb#26
|
583
|
+
def s(type, *children); end
|
584
|
+
end
|
@@ -4,86 +4,120 @@
|
|
4
4
|
# This is an autogenerated file for types exported from the `parse_packwerk` gem.
|
5
5
|
# Please instead update this file by running `bin/tapioca gem parse_packwerk`.
|
6
6
|
|
7
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#3
|
7
8
|
module ParsePackwerk
|
8
9
|
class << self
|
10
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#28
|
9
11
|
sig { returns(T::Array[::ParsePackwerk::Package]) }
|
10
12
|
def all; end
|
11
13
|
|
14
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#112
|
12
15
|
sig { void }
|
13
16
|
def bust_cache!; end
|
14
17
|
|
18
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#33
|
15
19
|
sig { params(name: ::String).returns(T.nilable(::ParsePackwerk::Package)) }
|
16
20
|
def find(name); end
|
17
21
|
|
22
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#43
|
18
23
|
sig { params(file_path: T.any(::Pathname, ::String)).returns(::ParsePackwerk::Package) }
|
19
24
|
def package_from_path(file_path); end
|
20
25
|
|
26
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#54
|
21
27
|
sig { params(package: ::ParsePackwerk::Package).void }
|
22
28
|
def write_package_yml!(package); end
|
23
29
|
|
30
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#38
|
24
31
|
sig { returns(::ParsePackwerk::Configuration) }
|
25
32
|
def yml; end
|
26
33
|
|
27
34
|
private
|
28
35
|
|
36
|
+
# We memoize packages_by_name for fast lookup.
|
37
|
+
# Since Graph is an immutable value object, we can create indexes and general caching mechanisms safely.
|
38
|
+
#
|
39
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#100
|
29
40
|
sig { returns(T::Hash[::String, ::ParsePackwerk::Package]) }
|
30
41
|
def packages_by_name; end
|
31
42
|
end
|
32
43
|
end
|
33
44
|
|
45
|
+
# source://parse_packwerk//lib/parse_packwerk/configuration.rb#4
|
34
46
|
class ParsePackwerk::Configuration < ::T::Struct
|
35
47
|
const :exclude, T::Array[::String]
|
36
48
|
const :package_paths, T::Array[::String]
|
37
49
|
|
38
50
|
class << self
|
51
|
+
# source://parse_packwerk//lib/parse_packwerk/configuration.rb#28
|
39
52
|
sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
|
40
53
|
def excludes(config_hash); end
|
41
54
|
|
55
|
+
# source://parse_packwerk//lib/parse_packwerk/configuration.rb#11
|
42
56
|
sig { returns(::ParsePackwerk::Configuration) }
|
43
57
|
def fetch; end
|
44
58
|
|
59
|
+
# source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
|
45
60
|
def inherited(s); end
|
46
61
|
|
62
|
+
# source://parse_packwerk//lib/parse_packwerk/configuration.rb#40
|
47
63
|
sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(T::Array[::String]) }
|
48
64
|
def package_paths(config_hash); end
|
49
65
|
end
|
50
66
|
end
|
51
67
|
|
68
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#22
|
52
69
|
ParsePackwerk::DEFAULT_EXCLUDE_GLOBS = T.let(T.unsafe(nil), Array)
|
53
|
-
ParsePackwerk::DEFAULT_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
|
54
|
-
ParsePackwerk::DEFAULT_PUBLIC_PATH = T.let(T.unsafe(nil), String)
|
55
|
-
ParsePackwerk::DEPENDENCIES = T.let(T.unsafe(nil), String)
|
56
|
-
ParsePackwerk::DEPRECATED_REFERENCES_YML_NAME = T.let(T.unsafe(nil), String)
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
const :violations, T::Array[::ParsePackwerk::Violation]
|
71
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#23
|
72
|
+
ParsePackwerk::DEFAULT_PACKAGE_PATHS = T.let(T.unsafe(nil), Array)
|
61
73
|
|
62
|
-
|
63
|
-
|
64
|
-
def for(package); end
|
74
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#24
|
75
|
+
ParsePackwerk::DEFAULT_PUBLIC_PATH = T.let(T.unsafe(nil), String)
|
65
76
|
|
66
|
-
|
67
|
-
|
77
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#14
|
78
|
+
ParsePackwerk::DEPENDENCIES = T.let(T.unsafe(nil), String)
|
68
79
|
|
69
|
-
|
70
|
-
|
71
|
-
end
|
80
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#10
|
81
|
+
ParsePackwerk::DEPENDENCY_VIOLATION_TYPE = T.let(T.unsafe(nil), String)
|
72
82
|
|
83
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#8
|
73
84
|
ParsePackwerk::ENFORCE_DEPENDENCIES = T.let(T.unsafe(nil), String)
|
85
|
+
|
86
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#9
|
74
87
|
ParsePackwerk::ENFORCE_PRIVACY = T.let(T.unsafe(nil), String)
|
88
|
+
|
89
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#13
|
75
90
|
ParsePackwerk::METADATA = T.let(T.unsafe(nil), String)
|
91
|
+
|
92
|
+
# Since this metadata is unstructured YAML, it could be any type. We leave it to clients of `ParsePackwerk::Package`
|
93
|
+
# to add types based on their known usage of metadata.
|
94
|
+
#
|
95
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#18
|
76
96
|
ParsePackwerk::MetadataYmlType = T.type_alias { T::Hash[T.untyped, T.untyped] }
|
77
97
|
|
98
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#14
|
78
99
|
class ParsePackwerk::MissingConfiguration < ::StandardError
|
100
|
+
# source://parse_packwerk//lib/parse_packwerk.rb#18
|
79
101
|
sig { params(packwerk_file_name: ::Pathname).void }
|
80
102
|
def initialize(packwerk_file_name); end
|
81
103
|
end
|
82
104
|
|
105
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#7
|
106
|
+
ParsePackwerk::PACKAGE_TODO_YML_NAME = T.let(T.unsafe(nil), String)
|
107
|
+
|
108
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#5
|
83
109
|
ParsePackwerk::PACKAGE_YML_NAME = T.let(T.unsafe(nil), String)
|
110
|
+
|
111
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#6
|
84
112
|
ParsePackwerk::PACKWERK_YML_NAME = T.let(T.unsafe(nil), String)
|
113
|
+
|
114
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#11
|
115
|
+
ParsePackwerk::PRIVACY_VIOLATION_TYPE = T.let(T.unsafe(nil), String)
|
116
|
+
|
117
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#12
|
85
118
|
ParsePackwerk::PUBLIC_PATH = T.let(T.unsafe(nil), String)
|
86
119
|
|
120
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#4
|
87
121
|
class ParsePackwerk::Package < ::T::Struct
|
88
122
|
const :dependencies, T::Array[::String]
|
89
123
|
const :enforce_dependencies, T::Boolean
|
@@ -92,34 +126,44 @@ class ParsePackwerk::Package < ::T::Struct
|
|
92
126
|
const :name, ::String
|
93
127
|
const :public_path, ::String, default: T.unsafe(nil)
|
94
128
|
|
129
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#35
|
95
130
|
sig { returns(::Pathname) }
|
96
131
|
def directory; end
|
97
132
|
|
133
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#45
|
98
134
|
sig { returns(T::Boolean) }
|
99
135
|
def enforces_dependencies?; end
|
100
136
|
|
137
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#50
|
101
138
|
sig { returns(T::Boolean) }
|
102
139
|
def enforces_privacy?; end
|
103
140
|
|
141
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#40
|
104
142
|
sig { returns(::Pathname) }
|
105
143
|
def public_directory; end
|
106
144
|
|
145
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#55
|
107
146
|
sig { returns(T::Array[::ParsePackwerk::Violation]) }
|
108
147
|
def violations; end
|
109
148
|
|
149
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#30
|
110
150
|
sig { returns(::Pathname) }
|
111
151
|
def yml; end
|
112
152
|
|
113
153
|
class << self
|
154
|
+
# source://parse_packwerk//lib/parse_packwerk/package.rb#15
|
114
155
|
sig { params(pathname: ::Pathname).returns(::ParsePackwerk::Package) }
|
115
156
|
def from(pathname); end
|
116
157
|
|
158
|
+
# source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
|
117
159
|
def inherited(s); end
|
118
160
|
end
|
119
161
|
end
|
120
162
|
|
163
|
+
# source://parse_packwerk//lib/parse_packwerk/package_set.rb#8
|
121
164
|
class ParsePackwerk::PackageSet
|
122
165
|
class << self
|
166
|
+
# source://parse_packwerk//lib/parse_packwerk/package_set.rb#12
|
123
167
|
sig do
|
124
168
|
params(
|
125
169
|
package_pathspec: T::Array[::String],
|
@@ -130,26 +174,51 @@ class ParsePackwerk::PackageSet
|
|
130
174
|
|
131
175
|
private
|
132
176
|
|
177
|
+
# source://parse_packwerk//lib/parse_packwerk/package_set.rb#28
|
133
178
|
sig { params(globs: T::Array[::String], path: ::Pathname).returns(T::Boolean) }
|
134
179
|
def exclude_path?(globs, path); end
|
135
180
|
end
|
136
181
|
end
|
137
182
|
|
183
|
+
# source://parse_packwerk//lib/parse_packwerk/package_todo.rb#4
|
184
|
+
class ParsePackwerk::PackageTodo < ::T::Struct
|
185
|
+
const :pathname, ::Pathname
|
186
|
+
const :violations, T::Array[::ParsePackwerk::Violation]
|
187
|
+
|
188
|
+
class << self
|
189
|
+
# source://parse_packwerk//lib/parse_packwerk/package_todo.rb#11
|
190
|
+
sig { params(package: ::ParsePackwerk::Package).returns(::ParsePackwerk::PackageTodo) }
|
191
|
+
def for(package); end
|
192
|
+
|
193
|
+
# source://parse_packwerk//lib/parse_packwerk/package_todo.rb#17
|
194
|
+
sig { params(pathname: ::Pathname).returns(::ParsePackwerk::PackageTodo) }
|
195
|
+
def from(pathname); end
|
196
|
+
|
197
|
+
# source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
|
198
|
+
def inherited(s); end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# source://parse_packwerk//lib/parse_packwerk/constants.rb#4
|
138
203
|
ParsePackwerk::ROOT_PACKAGE_NAME = T.let(T.unsafe(nil), String)
|
139
204
|
|
205
|
+
# source://parse_packwerk//lib/parse_packwerk/violation.rb#4
|
140
206
|
class ParsePackwerk::Violation < ::T::Struct
|
141
207
|
const :class_name, ::String
|
142
208
|
const :files, T::Array[::String]
|
143
209
|
const :to_package_name, ::String
|
144
210
|
const :type, ::String
|
145
211
|
|
212
|
+
# source://parse_packwerk//lib/parse_packwerk/violation.rb#13
|
146
213
|
sig { returns(T::Boolean) }
|
147
214
|
def dependency?; end
|
148
215
|
|
216
|
+
# source://parse_packwerk//lib/parse_packwerk/violation.rb#18
|
149
217
|
sig { returns(T::Boolean) }
|
150
218
|
def privacy?; end
|
151
219
|
|
152
220
|
class << self
|
221
|
+
# source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
|
153
222
|
def inherited(s); end
|
154
223
|
end
|
155
224
|
end
|
@@ -0,0 +1,272 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `rubocop-packs` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem rubocop-packs`.
|
6
|
+
|
7
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#4
|
8
|
+
module RuboCop; end
|
9
|
+
|
10
|
+
# source://rubocop-packs//lib/rubocop/cop/packwerk_lite/private.rb#4
|
11
|
+
module RuboCop::Cop; end
|
12
|
+
|
13
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#5
|
14
|
+
module RuboCop::Cop::Packs; end
|
15
|
+
|
16
|
+
# This is a private class that represents API that we would prefer to be available somehow in Zeitwerk.
|
17
|
+
# However, the boundaries between systems (packwerk/zeitwerk, rubocop/zeitwerk) are poor in this class, so
|
18
|
+
# that would need to be separated prior to proposing any API changes in zeitwerk.
|
19
|
+
#
|
20
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#12
|
21
|
+
class RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi
|
22
|
+
# For now, this API includes `package_for_path`
|
23
|
+
# If this were truly zeitwerk API, it wouldn't include any mention of packs and it would likely not need the package at all
|
24
|
+
# Since it could get the actual namespace without knowing anything about packs.
|
25
|
+
# However, we would need to pass to it the desired namespace based on the pack name for it to be able to suggest
|
26
|
+
# a desired filepath.
|
27
|
+
# Likely this means that our own cop should determine the desired namespace and pass that in
|
28
|
+
# and this can determine actual namespace and how to get to expected.
|
29
|
+
#
|
30
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#32
|
31
|
+
sig do
|
32
|
+
params(
|
33
|
+
relative_filename: ::String,
|
34
|
+
package_for_path: ::ParsePackwerk::Package
|
35
|
+
).returns(T.nilable(::RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi::NamespaceContext))
|
36
|
+
end
|
37
|
+
def for_file(relative_filename, package_for_path); end
|
38
|
+
|
39
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#86
|
40
|
+
sig { params(pack: ::ParsePackwerk::Package).returns(::String) }
|
41
|
+
def get_pack_based_namespace(pack); end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#103
|
46
|
+
sig { params(remaining_file_path: ::String, package_name: ::String).returns(::String) }
|
47
|
+
def get_actual_namespace(remaining_file_path, package_name); end
|
48
|
+
|
49
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#98
|
50
|
+
sig { params(pack: ::ParsePackwerk::Package).returns(::String) }
|
51
|
+
def get_package_last_name(pack); end
|
52
|
+
|
53
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#93
|
54
|
+
sig { returns(::Pathname) }
|
55
|
+
def root_pathname; end
|
56
|
+
end
|
57
|
+
|
58
|
+
# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#15
|
59
|
+
class RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi::NamespaceContext < ::T::Struct
|
60
|
+
const :current_fully_qualified_constant, ::String
|
61
|
+
const :current_namespace, ::String
|
62
|
+
const :expected_filepath, ::String
|
63
|
+
const :expected_namespace, ::String
|
64
|
+
|
65
|
+
class << self
|
66
|
+
# source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
|
67
|
+
def inherited(s); end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# source://rubocop-packs//lib/rubocop/cop/packwerk_lite/private.rb#5
|
72
|
+
module RuboCop::Cop::PackwerkLite; end
|
73
|
+
|
74
|
+
# This is a private class that represents API that we would prefer to be available somehow in Zeitwerk.
|
75
|
+
# However, the boundaries between systems (packwerk/zeitwerk, rubocop/zeitwerk) are poor in this class, so
|
76
|
+
# that would need to be separated prior to proposing any API changes in zeitwerk.
|
77
|
+
#
|
78
|
+
# source://rubocop-packs//lib/rubocop/cop/packwerk_lite/constant_resolver.rb#11
|
79
|
+
class RuboCop::Cop::PackwerkLite::ConstantResolver; end
|
80
|
+
|
81
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#5
|
82
|
+
module RuboCop::Packs
|
83
|
+
class << self
|
84
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#135
|
85
|
+
sig { void }
|
86
|
+
def bust_cache!; end
|
87
|
+
|
88
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#146
|
89
|
+
sig { returns(::RuboCop::Packs::Private::Configuration) }
|
90
|
+
def config; end
|
91
|
+
|
92
|
+
# @yield [config]
|
93
|
+
#
|
94
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#141
|
95
|
+
sig { params(blk: T.proc.params(arg0: ::RuboCop::Packs::Private::Configuration).void).void }
|
96
|
+
def configure(&blk); end
|
97
|
+
|
98
|
+
# We can remove this function once package_protections is fully deprecated
|
99
|
+
#
|
100
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#154
|
101
|
+
sig { params(rule: ::String).returns(T::Set[::String]) }
|
102
|
+
def exclude_for_rule(rule); end
|
103
|
+
|
104
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#99
|
105
|
+
sig { params(root_pathname: ::String).returns(::String) }
|
106
|
+
def pack_based_rubocop_config(root_pathname: T.unsafe(nil)); end
|
107
|
+
|
108
|
+
# Ideally, this is API that is available to us via `rubocop` itself.
|
109
|
+
# That is: the ability to preserve the location of `.rubocop_todo.yml` files and associate
|
110
|
+
# exclusions with the closest ancestor `.rubocop_todo.yml`
|
111
|
+
#
|
112
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#30
|
113
|
+
sig { params(packs: T::Array[::ParsePackwerk::Package], files: T::Array[::String]).void }
|
114
|
+
def regenerate_todo(packs: T.unsafe(nil), files: T.unsafe(nil)); end
|
115
|
+
|
116
|
+
# Ideally, this is API that is available to us via `rubocop` itself.
|
117
|
+
# That is: the ability to preserve the location of `.rubocop_todo.yml` files and associate
|
118
|
+
# exclusions with the closest ancestor `.rubocop_todo.yml`
|
119
|
+
#
|
120
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#78
|
121
|
+
sig { params(packs: T::Array[::ParsePackwerk::Package]).void }
|
122
|
+
def set_default_rubocop_yml(packs:); end
|
123
|
+
|
124
|
+
# Note: when we add per-pack `.rubocop.yml` files, we'll want to add some validations here
|
125
|
+
# to restrict what cops are permitted to be configured in those files.
|
126
|
+
# We might also want further (configurable?) constraints *requiring* that the "permitted pack level cops" be specified explicitly.
|
127
|
+
#
|
128
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#164
|
129
|
+
sig { returns(T::Array[::String]) }
|
130
|
+
def validate; end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#20
|
135
|
+
RuboCop::Packs::CONFIG = T.let(T.unsafe(nil), Hash)
|
136
|
+
|
137
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#19
|
138
|
+
RuboCop::Packs::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
|
139
|
+
|
140
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
141
|
+
# bit of our configuration.
|
142
|
+
#
|
143
|
+
# source://rubocop-packs//lib/rubocop/packs/inject.rb#10
|
144
|
+
module RuboCop::Packs::Inject
|
145
|
+
class << self
|
146
|
+
# source://rubocop-packs//lib/rubocop/packs/inject.rb#14
|
147
|
+
sig { void }
|
148
|
+
def defaults!; end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#16
|
153
|
+
RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML = T.let(T.unsafe(nil), String)
|
154
|
+
|
155
|
+
# Pack-level rubocop and rubocop_todo YML files are named differently because they are not integrated
|
156
|
+
# into rubocop in the standard way. For example, we could call these the standard `.rubocop.yml` and
|
157
|
+
# `.rubocop_todo.yml`. However, this introduces a number of path relativity issues (https://docs.rubocop.org/rubocop/configuration.html#path-relativity)
|
158
|
+
# that make this approach not possible. Therefore, for pack level rubocops, we name them in a way that mirrors packwerk `package_todo.yml` files
|
159
|
+
# for consistency and to ensure that thes are not read by rubocop except via the ERB templating mechanism.
|
160
|
+
#
|
161
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#15
|
162
|
+
RuboCop::Packs::PACK_LEVEL_RUBOCOP_YML = T.let(T.unsafe(nil), String)
|
163
|
+
|
164
|
+
# source://rubocop-packs//lib/rubocop/packs.rb#18
|
165
|
+
RuboCop::Packs::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
|
166
|
+
|
167
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#6
|
168
|
+
module RuboCop::Packs::Private
|
169
|
+
class << self
|
170
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#13
|
171
|
+
sig { void }
|
172
|
+
def bust_cache!; end
|
173
|
+
|
174
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#107
|
175
|
+
sig { params(rule: ::String).returns(T::Set[::String]) }
|
176
|
+
def exclude_for_rule(rule); end
|
177
|
+
|
178
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#152
|
179
|
+
sig { params(args: T.untyped).void }
|
180
|
+
def execute_rubocop(args); end
|
181
|
+
|
182
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#19
|
183
|
+
sig { void }
|
184
|
+
def load_client_configuration; end
|
185
|
+
|
186
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#157
|
187
|
+
sig do
|
188
|
+
params(
|
189
|
+
paths: T::Array[::String],
|
190
|
+
cop_names: T::Array[::String]
|
191
|
+
).returns(T::Array[::RuboCop::Packs::Private::Offense])
|
192
|
+
end
|
193
|
+
def offenses_for(paths:, cop_names:); end
|
194
|
+
|
195
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#29
|
196
|
+
sig { returns(T::Array[T::Hash[T.untyped, T.untyped]]) }
|
197
|
+
def rubocop_todo_ymls; end
|
198
|
+
|
199
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#126
|
200
|
+
sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) }
|
201
|
+
def validate_failure_mode_strict(package); end
|
202
|
+
|
203
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#40
|
204
|
+
sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) }
|
205
|
+
def validate_rubocop_todo_yml(package); end
|
206
|
+
|
207
|
+
# source://rubocop-packs//lib/rubocop/packs/private.rb#75
|
208
|
+
sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) }
|
209
|
+
def validate_rubocop_yml(package); end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#7
|
214
|
+
class RuboCop::Packs::Private::Configuration
|
215
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#20
|
216
|
+
sig { void }
|
217
|
+
def initialize; end
|
218
|
+
|
219
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#27
|
220
|
+
sig { void }
|
221
|
+
def bust_cache!; end
|
222
|
+
|
223
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#17
|
224
|
+
sig { returns(T::Array[::String]) }
|
225
|
+
def globally_permitted_namespaces; end
|
226
|
+
|
227
|
+
# @return [Array<String>]
|
228
|
+
#
|
229
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#17
|
230
|
+
def globally_permitted_namespaces=(_arg0); end
|
231
|
+
|
232
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#11
|
233
|
+
sig { returns(T::Array[::String]) }
|
234
|
+
def permitted_pack_level_cops; end
|
235
|
+
|
236
|
+
# @return [Array<String>]
|
237
|
+
#
|
238
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#11
|
239
|
+
def permitted_pack_level_cops=(_arg0); end
|
240
|
+
|
241
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#14
|
242
|
+
sig { returns(T::Array[::String]) }
|
243
|
+
def required_pack_level_cops; end
|
244
|
+
|
245
|
+
# @return [Array<String>]
|
246
|
+
#
|
247
|
+
# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#14
|
248
|
+
def required_pack_level_cops=(_arg0); end
|
249
|
+
end
|
250
|
+
|
251
|
+
# source://rubocop-packs//lib/rubocop/packs/private/offense.rb#6
|
252
|
+
class RuboCop::Packs::Private::Offense < ::T::Struct
|
253
|
+
const :cop_name, ::String
|
254
|
+
const :filepath, ::String
|
255
|
+
|
256
|
+
# source://rubocop-packs//lib/rubocop/packs/private/offense.rb#13
|
257
|
+
sig { returns(::ParsePackwerk::Package) }
|
258
|
+
def pack; end
|
259
|
+
|
260
|
+
class << self
|
261
|
+
# source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13
|
262
|
+
def inherited(s); end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# See docs/packwerk_lite.md
|
267
|
+
#
|
268
|
+
# source://rubocop-packs//lib/rubocop/packwerk_lite.rb#11
|
269
|
+
module RuboCop::PackwerkLite; end
|
270
|
+
|
271
|
+
# source://rubocop-packs//lib/rubocop/packwerk_lite.rb#12
|
272
|
+
class RuboCop::PackwerkLite::Error < ::StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pack_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_teams
|
@@ -189,13 +189,14 @@ files:
|
|
189
189
|
- lib/pack_stats/tag.rb
|
190
190
|
- lib/pack_stats/tags.rb
|
191
191
|
- sorbet/config
|
192
|
+
- sorbet/rbi/gems/ast@2.4.2.rbi
|
192
193
|
- sorbet/rbi/gems/code_ownership@1.28.0.rbi
|
193
194
|
- sorbet/rbi/gems/code_teams@1.0.0.rbi
|
194
195
|
- sorbet/rbi/gems/dogapi@1.45.0.rbi
|
195
196
|
- sorbet/rbi/gems/manual.rbi
|
196
|
-
- sorbet/rbi/gems/parse_packwerk@0.
|
197
|
+
- sorbet/rbi/gems/parse_packwerk@0.16.0.rbi
|
197
198
|
- sorbet/rbi/gems/rspec@3.10.0.rbi
|
198
|
-
- sorbet/rbi/gems/rubocop-packs@0.0.
|
199
|
+
- sorbet/rbi/gems/rubocop-packs@0.0.30.rbi
|
199
200
|
- sorbet/rbi/todo.rbi
|
200
201
|
homepage: https://github.com/rubyatscale/pack_stats
|
201
202
|
licenses:
|
@@ -1,141 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
|
3
|
-
# DO NOT EDIT MANUALLY
|
4
|
-
# This is an autogenerated file for types exported from the `rubocop-packs` gem.
|
5
|
-
# Please instead update this file by running `bin/tapioca gem rubocop-packs`.
|
6
|
-
|
7
|
-
module RuboCop; end
|
8
|
-
module RuboCop::Cop; end
|
9
|
-
module RuboCop::Cop::Packs; end
|
10
|
-
|
11
|
-
class RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi
|
12
|
-
sig do
|
13
|
-
params(
|
14
|
-
relative_filename: ::String,
|
15
|
-
package_for_path: ::ParsePackwerk::Package
|
16
|
-
).returns(T.nilable(::RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi::NamespaceContext))
|
17
|
-
end
|
18
|
-
def for_file(relative_filename, package_for_path); end
|
19
|
-
|
20
|
-
sig { params(pack: ::ParsePackwerk::Package).returns(::String) }
|
21
|
-
def get_pack_based_namespace(pack); end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
sig { params(remaining_file_path: ::String, package_name: ::String).returns(::String) }
|
26
|
-
def get_actual_namespace(remaining_file_path, package_name); end
|
27
|
-
|
28
|
-
sig { params(pack: ::ParsePackwerk::Package).returns(::String) }
|
29
|
-
def get_package_last_name(pack); end
|
30
|
-
|
31
|
-
sig { returns(::Pathname) }
|
32
|
-
def root_pathname; end
|
33
|
-
end
|
34
|
-
|
35
|
-
class RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi::NamespaceContext < ::T::Struct
|
36
|
-
const :current_fully_qualified_constant, ::String
|
37
|
-
const :current_namespace, ::String
|
38
|
-
const :expected_filepath, ::String
|
39
|
-
const :expected_namespace, ::String
|
40
|
-
|
41
|
-
class << self
|
42
|
-
def inherited(s); end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
module RuboCop::Cop::PackwerkLite; end
|
47
|
-
class RuboCop::Cop::PackwerkLite::ConstantResolver; end
|
48
|
-
|
49
|
-
module RuboCop::Packs
|
50
|
-
class << self
|
51
|
-
sig { params(packs: T::Array[::ParsePackwerk::Package]).void }
|
52
|
-
def auto_generate_rubocop_todo(packs:); end
|
53
|
-
|
54
|
-
sig { void }
|
55
|
-
def bust_cache!; end
|
56
|
-
|
57
|
-
sig { returns(::RuboCop::Packs::Private::Configuration) }
|
58
|
-
def config; end
|
59
|
-
|
60
|
-
sig { params(blk: T.proc.params(arg0: ::RuboCop::Packs::Private::Configuration).void).void }
|
61
|
-
def configure(&blk); end
|
62
|
-
|
63
|
-
sig { params(rule: ::String).returns(T::Set[::String]) }
|
64
|
-
def exclude_for_rule(rule); end
|
65
|
-
|
66
|
-
sig { params(root_pathname: ::String).returns(::String) }
|
67
|
-
def pack_based_rubocop_config(root_pathname: T.unsafe(nil)); end
|
68
|
-
|
69
|
-
sig { params(packs: T::Array[::ParsePackwerk::Package]).void }
|
70
|
-
def set_default_rubocop_yml(packs:); end
|
71
|
-
|
72
|
-
sig { returns(T::Array[::String]) }
|
73
|
-
def validate; end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
RuboCop::Packs::CONFIG = T.let(T.unsafe(nil), Hash)
|
78
|
-
RuboCop::Packs::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname)
|
79
|
-
class RuboCop::Packs::Error < ::StandardError; end
|
80
|
-
|
81
|
-
module RuboCop::Packs::Inject
|
82
|
-
class << self
|
83
|
-
sig { void }
|
84
|
-
def defaults!; end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML = T.let(T.unsafe(nil), String)
|
89
|
-
RuboCop::Packs::PACK_LEVEL_RUBOCOP_YML = T.let(T.unsafe(nil), String)
|
90
|
-
RuboCop::Packs::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname)
|
91
|
-
|
92
|
-
module RuboCop::Packs::Private
|
93
|
-
class << self
|
94
|
-
sig { void }
|
95
|
-
def bust_cache!; end
|
96
|
-
|
97
|
-
sig { params(rule: ::String).returns(T::Set[::String]) }
|
98
|
-
def exclude_for_rule(rule); end
|
99
|
-
|
100
|
-
sig { void }
|
101
|
-
def load_client_configuration; end
|
102
|
-
|
103
|
-
sig { returns(T::Array[T::Hash[T.untyped, T.untyped]]) }
|
104
|
-
def rubocop_todo_ymls; end
|
105
|
-
|
106
|
-
sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) }
|
107
|
-
def validate_failure_mode_strict(package); end
|
108
|
-
|
109
|
-
sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) }
|
110
|
-
def validate_rubocop_todo_yml(package); end
|
111
|
-
|
112
|
-
sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) }
|
113
|
-
def validate_rubocop_yml(package); end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
class RuboCop::Packs::Private::Configuration
|
118
|
-
sig { void }
|
119
|
-
def initialize; end
|
120
|
-
|
121
|
-
sig { void }
|
122
|
-
def bust_cache!; end
|
123
|
-
|
124
|
-
sig { returns(T::Array[::String]) }
|
125
|
-
def globally_permitted_namespaces; end
|
126
|
-
|
127
|
-
def globally_permitted_namespaces=(_arg0); end
|
128
|
-
|
129
|
-
sig { returns(T::Array[::String]) }
|
130
|
-
def permitted_pack_level_cops; end
|
131
|
-
|
132
|
-
def permitted_pack_level_cops=(_arg0); end
|
133
|
-
|
134
|
-
sig { returns(T::Array[::String]) }
|
135
|
-
def required_pack_level_cops; end
|
136
|
-
|
137
|
-
def required_pack_level_cops=(_arg0); end
|
138
|
-
end
|
139
|
-
|
140
|
-
module RuboCop::PackwerkLite; end
|
141
|
-
class RuboCop::PackwerkLite::Error < ::StandardError; end
|