pack_stats 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f060837410e7daee8e07d54e9bbee788401954480eeb0f9f3b2a8222e6216ae6
|
4
|
+
data.tar.gz: a72d940a47cb17e98efcb0d658799853a3f295674326caf2f6eca22ee23bacec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc898c2c55afc4ebb1dc19c7f538cde5667d5bc8e64b7d06163a5d04baf9f6dc867e6038a7e9fa19bc6785b935e86e05499bebe364c5586fec1d56febbb6d53
|
7
|
+
data.tar.gz: c16aec135614d559e053410961a74bcbc1ad9d7a25ac02173b72153235a8639fc1a898f0579239840dca39084ad0c35a924075b99da64c2e6aa75ffca986bf49
|
@@ -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)
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gusto Engineers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_teams
|
@@ -198,7 +198,6 @@ files:
|
|
198
198
|
- lib/pack_stats/private/metrics/packages_by_team.rb
|
199
199
|
- lib/pack_stats/private/metrics/packwerk_checker_usage.rb
|
200
200
|
- lib/pack_stats/private/metrics/public_usage.rb
|
201
|
-
- lib/pack_stats/private/metrics/rubocop_usage.rb
|
202
201
|
- lib/pack_stats/private/source_code_file.rb
|
203
202
|
- lib/pack_stats/tag.rb
|
204
203
|
- lib/pack_stats/tags.rb
|
@@ -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
|