modularization_statistics 1.41.0 → 1.42.0
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 +8 -3
- data/lib/modularization_statistics/private/metrics/protection_usage.rb +1 -16
- data/lib/modularization_statistics/private/metrics/rubocop_protections_exclusions.rb +6 -1
- data/sorbet/rbi/gems/{package_protections@1.4.0.rbi → package_protections@4.0.1.rbi} +24 -79
- data/sorbet/rbi/gems/rubocop-packs@0.0.20.rbi +141 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79da508fe87219aecb90819b7b1cb7c1681108e8938fc48079d2dac98de6b998
|
4
|
+
data.tar.gz: 408f7f9f5bef70a3e11f8022cd7c6a328ad744095625aa94fc1af4757177c903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdd4ec7596f32e10267deb3bb1a75c3a84e4269b583317a9879ce7e992caaf2503daf20b64c27f1471395e51f0d575d3ef6aa1bf424ce53af3f71b75f7a6df7d
|
7
|
+
data.tar.gz: ec1c565bf1c3a5e01fea05a8fa128ac35519adbb58939ef787dca80b2c6db1e5054f6407ef619cde00efacaa5395827aac8c8b4f5690efb8e518e6d0888f7340
|
data/README.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
This gem is used to report opinionated statistics about modularization to DataDog and other observability systems.
|
4
4
|
|
5
|
+
# Configuring Ownership
|
6
|
+
The gem reports metrics per-team, where each team is configured based on metadata included in Packwerk package.yml files.
|
7
|
+
|
8
|
+
Define your teams as described in the [Code Team - Package Based Ownership](https://github.com/rubyatscale/code_ownership#package-based-ownership) documentation.
|
9
|
+
|
5
10
|
# Usage
|
6
11
|
The main method to this gem is `ModularizationStatistics#report_to_datadog!`. Refer to the Sorbet signature for this method for the exact types to be passed in.
|
7
12
|
|
@@ -19,8 +24,8 @@ ModularizationStatistics.report_to_datadog!(
|
|
19
24
|
# Example: Time.now
|
20
25
|
#
|
21
26
|
report_time: report_time
|
22
|
-
#
|
23
|
-
# This is used to determine what files to look at for building statistics about what types of files are packaged, componentized, or unpackaged.
|
27
|
+
#
|
28
|
+
# This is used to determine what files to look at for building statistics about what types of files are packaged, componentized, or unpackaged.
|
24
29
|
# This is an array of `Pathname`. `Pathname` can be relative or absolute paths.
|
25
30
|
#
|
26
31
|
# Example: source_code_pathnames = Pathname.glob('./**/**.rb')
|
@@ -33,7 +38,7 @@ ModularizationStatistics.report_to_datadog!(
|
|
33
38
|
# Example: [Pathname.new("./gems")]
|
34
39
|
#
|
35
40
|
componentized_source_code_locations: componentized_source_code_locations,
|
36
|
-
#
|
41
|
+
#
|
37
42
|
# A file is determined to be packaged if it exists in any of these directories.
|
38
43
|
# This is an array of `Pathname`. `Pathname` can be relative or absolute paths.
|
39
44
|
#
|
@@ -93,24 +93,9 @@ module ModularizationStatistics
|
|
93
93
|
else
|
94
94
|
T.absurd(violation_behavior)
|
95
95
|
end
|
96
|
-
elsif protection.identifier == 'prevent_other_packages_from_using_this_package_without_explicit_visibility'
|
97
|
-
case violation_behavior
|
98
|
-
when PackageProtections::ViolationBehavior::FailOnAny
|
99
|
-
# We'd probably not want to support this right away
|
100
|
-
false
|
101
|
-
when PackageProtections::ViolationBehavior::FailNever
|
102
|
-
# We'd need to add this to `parse_packwerk` so that we can get other arbitrary top-level keys.
|
103
|
-
# Alternatively we can put this in `metadata` for the time being to unblock us.
|
104
|
-
# package.config['enforce_visibility']
|
105
|
-
!package.metadata['enforce_visibility']
|
106
|
-
when PackageProtections::ViolationBehavior::FailOnNew
|
107
|
-
!!package.metadata['enforce_visibility']
|
108
|
-
else
|
109
|
-
T.absurd(violation_behavior)
|
110
|
-
end
|
111
96
|
else
|
112
97
|
# Otherwise, we're in a rubocop case
|
113
|
-
rubocop_yml_file = package.directory.join(
|
98
|
+
rubocop_yml_file = package.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_YML)
|
114
99
|
return false if !rubocop_yml_file.exist?
|
115
100
|
rubocop_yml = YAML.load_file(rubocop_yml_file)
|
116
101
|
protection = T.cast(protection, PackageProtections::RubocopProtectionInterface)
|
@@ -22,7 +22,12 @@ module ModularizationStatistics
|
|
22
22
|
# TODO: `rubocop-packs` may want to expose API for this
|
23
23
|
sig { params(package: ParsePackwerk::Package, protection: PackageProtections::RubocopProtectionInterface).returns(Integer) }
|
24
24
|
def self.exclude_count_for_package_and_protection(package, protection)
|
25
|
-
|
25
|
+
if package.name == ParsePackwerk::ROOT_PACKAGE_NAME
|
26
|
+
rubocop_todo = package.directory.join('.rubocop_todo.yml')
|
27
|
+
else
|
28
|
+
rubocop_todo = package.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML)
|
29
|
+
end
|
30
|
+
|
26
31
|
if rubocop_todo.exist?
|
27
32
|
loaded_rubocop_todo = YAML.load_file(rubocop_todo)
|
28
33
|
cop_config = loaded_rubocop_todo.fetch(protection.cop_name, {})
|
@@ -12,6 +12,9 @@ module PackageProtections
|
|
12
12
|
sig { void }
|
13
13
|
def bust_cache!; end
|
14
14
|
|
15
|
+
sig { returns(::PackageProtections::Private::Configuration) }
|
16
|
+
def config; end
|
17
|
+
|
15
18
|
sig { params(blk: T.proc.params(arg0: ::PackageProtections::Private::Configuration).void).void }
|
16
19
|
def configure(&blk); end
|
17
20
|
|
@@ -23,9 +26,6 @@ module PackageProtections
|
|
23
26
|
end
|
24
27
|
def get_offenses(packages:, new_violations:); end
|
25
28
|
|
26
|
-
sig { params(identifier: ::String).returns(T::Hash[T.untyped, T.untyped]) }
|
27
|
-
def private_cop_config(identifier); end
|
28
|
-
|
29
29
|
sig { params(root_pathname: ::Pathname).returns(::String) }
|
30
30
|
def rubocop_yml(root_pathname: T.unsafe(nil)); end
|
31
31
|
|
@@ -38,6 +38,9 @@ module PackageProtections
|
|
38
38
|
end
|
39
39
|
def set_defaults!(packages, protection_identifiers: T.unsafe(nil), verbose: T.unsafe(nil)); end
|
40
40
|
|
41
|
+
sig { returns(T::Array[::String]) }
|
42
|
+
def validate!; end
|
43
|
+
|
41
44
|
sig { params(identifier: ::String).returns(::PackageProtections::ProtectionInterface) }
|
42
45
|
def with_identifier(identifier); end
|
43
46
|
end
|
@@ -97,9 +100,6 @@ module PackageProtections::Private
|
|
97
100
|
sig { void }
|
98
101
|
def bust_cache!; end
|
99
102
|
|
100
|
-
sig { returns(::PackageProtections::Private::Configuration) }
|
101
|
-
def config; end
|
102
|
-
|
103
103
|
sig do
|
104
104
|
params(
|
105
105
|
packages: T::Array[::ParsePackwerk::Package],
|
@@ -111,8 +111,8 @@ module PackageProtections::Private
|
|
111
111
|
sig { params(name: ::String).returns(::PackageProtections::ProtectedPackage) }
|
112
112
|
def get_package_with_name(name); end
|
113
113
|
|
114
|
-
sig {
|
115
|
-
def
|
114
|
+
sig { void }
|
115
|
+
def load_client_configuration; end
|
116
116
|
|
117
117
|
sig { params(root_pathname: ::Pathname).returns(::String) }
|
118
118
|
def rubocop_yml(root_pathname:); end
|
@@ -189,17 +189,26 @@ class PackageProtections::Private::Configuration
|
|
189
189
|
sig { void }
|
190
190
|
def initialize; end
|
191
191
|
|
192
|
+
sig { returns(T::Array[::String]) }
|
193
|
+
def acceptable_parent_classes; end
|
194
|
+
|
195
|
+
def acceptable_parent_classes=(_arg0); end
|
196
|
+
|
192
197
|
sig { void }
|
193
198
|
def bust_cache!; end
|
194
199
|
|
195
200
|
sig { returns(T::Array[::PackageProtections::ProtectionInterface]) }
|
196
201
|
def default_protections; end
|
197
202
|
|
203
|
+
sig { returns(T::Array[::String]) }
|
204
|
+
def globally_permitted_namespaces; end
|
205
|
+
|
206
|
+
def globally_permitted_namespaces=(_arg0); end
|
207
|
+
|
198
208
|
sig { returns(T::Array[::PackageProtections::ProtectionInterface]) }
|
199
209
|
def protections; end
|
200
210
|
|
201
|
-
|
202
|
-
def protections=(protections); end
|
211
|
+
def protections=(_arg0); end
|
203
212
|
end
|
204
213
|
|
205
214
|
class PackageProtections::Private::IncomingPrivacyProtection
|
@@ -321,57 +330,6 @@ class PackageProtections::Private::Output
|
|
321
330
|
end
|
322
331
|
end
|
323
332
|
|
324
|
-
class PackageProtections::Private::VisibilityProtection
|
325
|
-
include ::PackageProtections::ProtectionInterface
|
326
|
-
|
327
|
-
sig { returns(::PackageProtections::ViolationBehavior) }
|
328
|
-
def default_behavior; end
|
329
|
-
|
330
|
-
sig do
|
331
|
-
override
|
332
|
-
.params(
|
333
|
-
protected_packages: T::Array[::PackageProtections::ProtectedPackage]
|
334
|
-
).returns(T::Array[::PackageProtections::Offense])
|
335
|
-
end
|
336
|
-
def get_offenses_for_existing_violations(protected_packages); end
|
337
|
-
|
338
|
-
sig do
|
339
|
-
override
|
340
|
-
.params(
|
341
|
-
new_violations: T::Array[::PackageProtections::PerFileViolation]
|
342
|
-
).returns(T::Array[::PackageProtections::Offense])
|
343
|
-
end
|
344
|
-
def get_offenses_for_new_violations(new_violations); end
|
345
|
-
|
346
|
-
sig { override.returns(::String) }
|
347
|
-
def humanized_protection_description; end
|
348
|
-
|
349
|
-
sig { override.returns(::String) }
|
350
|
-
def humanized_protection_name; end
|
351
|
-
|
352
|
-
sig { override.returns(::String) }
|
353
|
-
def identifier; end
|
354
|
-
|
355
|
-
sig do
|
356
|
-
override
|
357
|
-
.params(
|
358
|
-
behavior: ::PackageProtections::ViolationBehavior,
|
359
|
-
package: ::ParsePackwerk::Package
|
360
|
-
).returns(T.nilable(::String))
|
361
|
-
end
|
362
|
-
def unmet_preconditions_for_behavior(behavior, package); end
|
363
|
-
|
364
|
-
private
|
365
|
-
|
366
|
-
sig { params(per_file_violation: ::PackageProtections::PerFileViolation).returns(::String) }
|
367
|
-
def message_for_fail_on_any(per_file_violation); end
|
368
|
-
|
369
|
-
sig { params(per_file_violation: ::PackageProtections::PerFileViolation).returns(::String) }
|
370
|
-
def message_for_fail_on_new(per_file_violation); end
|
371
|
-
end
|
372
|
-
|
373
|
-
PackageProtections::Private::VisibilityProtection::IDENTIFIER = T.let(T.unsafe(nil), String)
|
374
|
-
|
375
333
|
class PackageProtections::ProtectedPackage < ::T::Struct
|
376
334
|
const :deprecated_references, ::ParsePackwerk::DeprecatedReferences
|
377
335
|
const :original_package, ::ParsePackwerk::Package
|
@@ -392,9 +350,6 @@ class PackageProtections::ProtectedPackage < ::T::Struct
|
|
392
350
|
sig { returns(T::Array[::ParsePackwerk::Violation]) }
|
393
351
|
def violations; end
|
394
352
|
|
395
|
-
sig { returns(T::Set[::String]) }
|
396
|
-
def visible_to; end
|
397
|
-
|
398
353
|
sig { returns(::Pathname) }
|
399
354
|
def yml; end
|
400
355
|
|
@@ -489,8 +444,8 @@ module PackageProtections::RubocopProtectionInterface
|
|
489
444
|
sig { abstract.returns(::String) }
|
490
445
|
def cop_name; end
|
491
446
|
|
492
|
-
sig {
|
493
|
-
def custom_cop_config
|
447
|
+
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
448
|
+
def custom_cop_config; end
|
494
449
|
|
495
450
|
sig do
|
496
451
|
override
|
@@ -522,25 +477,13 @@ module PackageProtections::RubocopProtectionInterface
|
|
522
477
|
).returns(T.nilable(::String))
|
523
478
|
end
|
524
479
|
def unmet_preconditions_for_behavior(behavior, package); end
|
525
|
-
|
526
|
-
private
|
527
|
-
|
528
|
-
sig { params(rule: ::String).returns(T::Set[::String]) }
|
529
|
-
def exclude_for_rule(rule); end
|
530
|
-
|
531
|
-
class << self
|
532
|
-
sig { void }
|
533
|
-
def bust_rubocop_todo_yml_cache; end
|
534
|
-
|
535
|
-
sig { returns(T.untyped) }
|
536
|
-
def rubocop_todo_yml; end
|
537
|
-
end
|
538
480
|
end
|
539
481
|
|
540
482
|
class PackageProtections::RubocopProtectionInterface::CopConfig < ::T::Struct
|
541
483
|
const :enabled, T::Boolean, default: T.unsafe(nil)
|
542
484
|
const :exclude_paths, T::Array[::String], default: T.unsafe(nil)
|
543
485
|
const :include_paths, T::Array[::String], default: T.unsafe(nil)
|
486
|
+
const :metadata, T.untyped, default: T.unsafe(nil)
|
544
487
|
const :name, ::String
|
545
488
|
|
546
489
|
sig { returns(::String) }
|
@@ -579,3 +522,5 @@ end
|
|
579
522
|
module RuboCop; end
|
580
523
|
module RuboCop::Cop; end
|
581
524
|
module RuboCop::Cop::PackageProtections; end
|
525
|
+
|
526
|
+
RuboCop::Cop::PackageProtections::OnlyClassMethods::IDENTIFIER = T.let(T.unsafe(nil), String)
|
@@ -0,0 +1,141 @@
|
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modularization_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.42.0
|
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-11-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_teams
|
@@ -193,9 +193,10 @@ files:
|
|
193
193
|
- sorbet/rbi/gems/code_teams@1.0.0.rbi
|
194
194
|
- sorbet/rbi/gems/dogapi@1.45.0.rbi
|
195
195
|
- sorbet/rbi/gems/manual.rbi
|
196
|
-
- sorbet/rbi/gems/package_protections@
|
196
|
+
- sorbet/rbi/gems/package_protections@4.0.1.rbi
|
197
197
|
- sorbet/rbi/gems/parse_packwerk@0.14.0.rbi
|
198
198
|
- sorbet/rbi/gems/rspec@3.10.0.rbi
|
199
|
+
- sorbet/rbi/gems/rubocop-packs@0.0.20.rbi
|
199
200
|
- sorbet/rbi/todo.rbi
|
200
201
|
homepage: https://github.com/rubyatscale/modularization_statistics
|
201
202
|
licenses:
|