pack_stats 0.1.2 → 0.2.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257c72796b9a65f1d67e0f6f96998fcd2929717ff09526a95e4bea8f144bb903
|
4
|
+
data.tar.gz: 79cf5e5557eb13cd286a2724e1c7b9fdb9308845830c3327ec9d99e6a0c4b27a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8456c2d22795b7ac537a4d64dc4e52607b44642f2a7e1af6d059863de5805ce1ad8f735ff5122f2ac876632ea6bef1bbbaab58c458b310a74dbb2b2083aa4698
|
7
|
+
data.tar.gz: 42d5b073d4771726a0f15b8622894e07c58b348d571a5b1ca3b0e478e5b8580fb37a4b88922ed18951fbcb9c3f6d6f482e0435b93350c2b820d87e10aabd1726
|
data/README.md
CHANGED
@@ -103,4 +103,5 @@ Right now this tool sends metrics to DataDog only. However, if you want to use t
|
|
103
103
|
|
104
104
|
We recommend the use of the dashboard that is shipped with this gem. You can create a new dashboard and then click "import dashboard JSON" to get a jump start on tracking your metrics. Note you may want to make some tweaks to these dashboards to better fit your organization's circumstances and goals.
|
105
105
|
|
106
|
-
[Dashboard JSON](docs/dashboard.json)
|
106
|
+
- [Dashboard JSON](docs/dashboard.json)
|
107
|
+
- [Screenshots](docs/screenshots.md)
|
@@ -6,7 +6,6 @@ require 'pack_stats/private/metrics'
|
|
6
6
|
require 'pack_stats/private/metrics/files'
|
7
7
|
require 'pack_stats/private/metrics/public_usage'
|
8
8
|
require 'pack_stats/private/metrics/packwerk_checker_usage'
|
9
|
-
require 'pack_stats/private/metrics/rubocop_usage'
|
10
9
|
require 'pack_stats/private/metrics/dependencies'
|
11
10
|
require 'pack_stats/private/metrics/packages'
|
12
11
|
require 'pack_stats/private/metrics/packages_by_team'
|
@@ -31,7 +31,6 @@ module PackStats
|
|
31
31
|
all_metrics << GaugeMetric.for('all_packages.has_readme.count', packages.count { |package| Metrics.has_readme?(package) }, package_tags)
|
32
32
|
|
33
33
|
all_metrics += Metrics::PackwerkCheckerUsage.get_checker_metrics('all_packages', packages, package_tags)
|
34
|
-
all_metrics += Metrics::RubocopUsage.get_metrics('all_packages', packages, package_tags)
|
35
34
|
all_metrics << GaugeMetric.for('all_packages.package_based_file_ownership.count', packages.count { |package| !package.metadata['owner'].nil? }, package_tags)
|
36
35
|
|
37
36
|
inbound_violations_by_package = packages.flat_map(&:violations).group_by(&:to_package_name)
|
@@ -9,7 +9,7 @@ module PackStats
|
|
9
9
|
class PackwerkCheckerUsage
|
10
10
|
extend T::Sig
|
11
11
|
|
12
|
-
# Some violations (e.g. dependency, visibility,
|
12
|
+
# Some violations (e.g. dependency, visibility, layer) matter for the referencing (outbound) package.
|
13
13
|
# Other violations (e.g. privacy) matter for the referenced (inbound) package.
|
14
14
|
class Direction < T::Enum
|
15
15
|
enums do
|
@@ -38,7 +38,7 @@ module PackStats
|
|
38
38
|
CHECKERS = T.let([
|
39
39
|
PackwerkChecker.new(key: 'enforce_dependencies', violation_type: 'dependency', direction: Direction::Outbound),
|
40
40
|
PackwerkChecker.new(key: 'enforce_privacy', violation_type: 'privacy', direction: Direction::Inbound),
|
41
|
-
PackwerkChecker.new(key: '
|
41
|
+
PackwerkChecker.new(key: 'enforce_layers', violation_type: 'layer', direction: Direction::Outbound),
|
42
42
|
PackwerkChecker.new(key: 'enforce_visibility', violation_type: 'visibility', direction: Direction::Outbound),
|
43
43
|
], T::Array[PackwerkChecker])
|
44
44
|
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_teams
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: base64
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rspec
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,7 +212,6 @@ files:
|
|
198
212
|
- lib/pack_stats/private/metrics/packages_by_team.rb
|
199
213
|
- lib/pack_stats/private/metrics/packwerk_checker_usage.rb
|
200
214
|
- lib/pack_stats/private/metrics/public_usage.rb
|
201
|
-
- lib/pack_stats/private/metrics/rubocop_usage.rb
|
202
215
|
- lib/pack_stats/private/source_code_file.rb
|
203
216
|
- lib/pack_stats/tag.rb
|
204
217
|
- lib/pack_stats/tags.rb
|
@@ -210,7 +223,7 @@ metadata:
|
|
210
223
|
source_code_uri: https://github.com/rubyatscale/pack_stats
|
211
224
|
changelog_uri: https://github.com/rubyatscale/pack_stats/releases
|
212
225
|
allowed_push_host: https://rubygems.org
|
213
|
-
post_install_message:
|
226
|
+
post_install_message:
|
214
227
|
rdoc_options: []
|
215
228
|
require_paths:
|
216
229
|
- lib
|
@@ -225,8 +238,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
238
|
- !ruby/object:Gem::Version
|
226
239
|
version: '0'
|
227
240
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
229
|
-
signing_key:
|
241
|
+
rubygems_version: 3.5.11
|
242
|
+
signing_key:
|
230
243
|
specification_version: 4
|
231
244
|
summary: A gem to collect statistics about modularization progress in a Rails application
|
232
245
|
using packwerk.
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module PackStats
|
5
|
-
module Private
|
6
|
-
module Metrics
|
7
|
-
class RubocopUsage
|
8
|
-
extend T::Sig
|
9
|
-
|
10
|
-
sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) }
|
11
|
-
def self.get_metrics(prefix, packages, package_tags)
|
12
|
-
[
|
13
|
-
*get_rubocop_exclusions(prefix, packages, package_tags),
|
14
|
-
*get_rubocop_usage_metrics(prefix, packages, package_tags)
|
15
|
-
]
|
16
|
-
end
|
17
|
-
|
18
|
-
sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) }
|
19
|
-
def self.get_rubocop_usage_metrics(prefix, packages, package_tags)
|
20
|
-
metrics = T.let([], T::Array[GaugeMetric])
|
21
|
-
|
22
|
-
rubocops.each do |cop_name|
|
23
|
-
['false', 'true', 'strict'].each do |enabled_mode|
|
24
|
-
count_of_packages = ParsePackwerk.all.count do |package|
|
25
|
-
# We will likely want a rubocop-packs API for this, to be able to ask if a cop is enabled for a pack.
|
26
|
-
# It's possible we will want to allow these to be enabled at the top-level `.rubocop.yml`,
|
27
|
-
# in which case we wouldn't get the right metrics with this approach. However, we can also accept
|
28
|
-
# that as a current limitation.
|
29
|
-
rubocop_yml_file = package.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_YML)
|
30
|
-
next false if !rubocop_yml_file.exist?
|
31
|
-
rubocop_yml = YAML.load_file(rubocop_yml_file)
|
32
|
-
cop_config = rubocop_yml[cop_name]
|
33
|
-
|
34
|
-
strict_mode = cop_config && cop_config['FailureMode'] == 'strict'
|
35
|
-
enabled = cop_config && cop_config['Enabled']
|
36
|
-
case enabled_mode
|
37
|
-
when 'false'
|
38
|
-
!enabled
|
39
|
-
when 'true'
|
40
|
-
enabled && !strict_mode
|
41
|
-
when 'strict'
|
42
|
-
!!strict_mode
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
metric_name = "#{prefix}.rubocops.#{to_tag_name(cop_name)}.#{enabled_mode}.count"
|
47
|
-
metrics << GaugeMetric.for(metric_name, count_of_packages, package_tags)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
metrics
|
52
|
-
end
|
53
|
-
|
54
|
-
sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) }
|
55
|
-
def self.get_rubocop_exclusions(prefix, packages, package_tags)
|
56
|
-
rubocops.flat_map do |cop_name|
|
57
|
-
metric_name = "#{prefix}.rubocops.#{to_tag_name(cop_name)}.exclusions.count"
|
58
|
-
all_exclusions_count = ParsePackwerk.all.sum { |package| exclude_count_for_package_and_protection(package, cop_name)}
|
59
|
-
GaugeMetric.for(metric_name, all_exclusions_count, package_tags)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# TODO: `rubocop-packs` may want to expose API for this
|
64
|
-
sig { params(package: ParsePackwerk::Package, cop_name: String).returns(Integer) }
|
65
|
-
def self.exclude_count_for_package_and_protection(package, cop_name)
|
66
|
-
if package.name == ParsePackwerk::ROOT_PACKAGE_NAME
|
67
|
-
rubocop_todo = package.directory.join('.rubocop_todo.yml')
|
68
|
-
else
|
69
|
-
rubocop_todo = package.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML)
|
70
|
-
end
|
71
|
-
|
72
|
-
if rubocop_todo.exist?
|
73
|
-
loaded_rubocop_todo = YAML.load_file(rubocop_todo)
|
74
|
-
cop_config = loaded_rubocop_todo.fetch(cop_name, {})
|
75
|
-
cop_config.fetch('Exclude', []).count
|
76
|
-
else
|
77
|
-
0
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
sig { returns(T::Array[String])}
|
82
|
-
def self.rubocops
|
83
|
-
[
|
84
|
-
'Packs/ClassMethodsAsPublicApis',
|
85
|
-
'Packs/RootNamespaceIsPackName',
|
86
|
-
'Packs/TypedPublicApis',
|
87
|
-
'Packs/DocumentedPublicApis',
|
88
|
-
]
|
89
|
-
end
|
90
|
-
|
91
|
-
sig { params(cop_name: String).returns(String) }
|
92
|
-
def self.to_tag_name(cop_name)
|
93
|
-
cop_name.gsub('/', '_').downcase
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|