modularization_statistics 1.36.0 → 1.37.0

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: 3684ee2e07b5f3cba3bb7093be91b88725808a8a3d203e4ede46c7aa116d920c
4
- data.tar.gz: 7872ee6e03ff44a158e2274861c0de2700227e976078e3c905dc8f102d58cfaa
3
+ metadata.gz: 252db0bdd5ec50e555d34ce4c7468df4a5bf731274fafd137a319eaf1a1100b9
4
+ data.tar.gz: 8983a207179da6a93b34464f98c3b478a23087b34946f63d4c1cf95992d10f9e
5
5
  SHA512:
6
- metadata.gz: c6d080bc0c7e9c199e37262c8949a9227510eae2e7cac98d8c90121f788aca0b5123da006ba4a3ade27b512b3a7373ea06f789f82d108d51dc6d83cdf3378291
7
- data.tar.gz: 3333265a294391652a0d07199c897e6ff02f2e40536e9a3654f7cfa2c21d1bf91c4f6cff0d5771eeea581b3f17740621d317c7f2a4a058960fd1328a9a801457
6
+ metadata.gz: cebc018b3841416b6194e3cef53779f3529f2d56463bbd8c6d79a6fb322f9c1c1a81d0a357fb8140cd48853abe6d5d1de160e707414b2d71eccbdbbb36dc9993
7
+ data.tar.gz: d837d652fed0baca80bfc6e1613d1ab75e1ac5b5b7d798c7df544a53e3c27c5c20ab82d8d39891aa29034541086d0e6a6b3e806d22b5b575c836951a1f96cac7
@@ -6,6 +6,7 @@ require 'modularization_statistics/private/metrics'
6
6
  require 'modularization_statistics/private/metrics/files'
7
7
  require 'modularization_statistics/private/metrics/public_usage'
8
8
  require 'modularization_statistics/private/metrics/protection_usage'
9
+ require 'modularization_statistics/private/metrics/rubocop_protections_exclusions'
9
10
  require 'modularization_statistics/private/metrics/packages'
10
11
  require 'modularization_statistics/private/metrics/packages_by_team'
11
12
  require 'modularization_statistics/private/metrics/nested_packs'
@@ -34,6 +34,7 @@ module ModularizationStatistics
34
34
  all_metrics << GaugeMetric.for('all_packages.has_readme.count', packages.count { |package| Metrics.has_readme?(package) }, package_tags)
35
35
 
36
36
  all_metrics += Metrics::ProtectionUsage.get_protections_metrics('all_packages', protected_packages, package_tags)
37
+ all_metrics += Metrics::RubocopProtectionsExclusions.get_rubocop_exclusions('all_packages', protected_packages, package_tags)
37
38
  all_metrics << GaugeMetric.for('all_packages.package_based_file_ownership.count', packages.count { |package| !package.metadata['owner'].nil? }, package_tags)
38
39
 
39
40
  inbound_violations_by_package = protected_packages.flat_map(&:violations).group_by(&:to_package_name)
@@ -0,0 +1,34 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module ModularizationStatistics
5
+ module Private
6
+ module Metrics
7
+ class RubocopProtectionsExclusions
8
+ extend T::Sig
9
+
10
+ sig { params(prefix: String, protected_packages: T::Array[PackageProtections::ProtectedPackage], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) }
11
+ def self.get_rubocop_exclusions(prefix, protected_packages, package_tags)
12
+ rubocop_based_package_protections = T.cast(PackageProtections.all.select { |p| p.is_a?(PackageProtections::RubocopProtectionInterface) }, T::Array[PackageProtections::RubocopProtectionInterface])
13
+ rubocop_based_package_protections.flat_map do |rubocop_based_package_protection|
14
+ metric_name = "#{prefix}.#{rubocop_based_package_protection.identifier}.rubocop_exclusions.count"
15
+ all_exclusions_count = ParsePackwerk.all.sum { |package| exclude_count_for_package_and_protection(package, rubocop_based_package_protection)}
16
+ GaugeMetric.for(metric_name, all_exclusions_count, package_tags)
17
+ end
18
+ end
19
+
20
+ sig { params(package: ParsePackwerk::Package, protection: PackageProtections::RubocopProtectionInterface).returns(Integer) }
21
+ def self.exclude_count_for_package_and_protection(package, protection)
22
+ rubocop_todo = package.directory.join('.rubocop_todo.yml')
23
+ if rubocop_todo.exist?
24
+ loaded_rubocop_todo = YAML.load_file(rubocop_todo)
25
+ cop_config = loaded_rubocop_todo.fetch(protection.cop_name, {})
26
+ cop_config.fetch('Exclude', []).count
27
+ else
28
+ 0
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
data/sorbet/config CHANGED
@@ -1,3 +1,4 @@
1
1
  --dir
2
2
  .
3
3
  --ignore=/vendor/bundle
4
+ --enable-experimental-requires-ancestor
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.36.0
4
+ version: 1.37.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-08-23 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams
@@ -184,6 +184,7 @@ files:
184
184
  - lib/modularization_statistics/private/metrics/packages_by_team.rb
185
185
  - lib/modularization_statistics/private/metrics/protection_usage.rb
186
186
  - lib/modularization_statistics/private/metrics/public_usage.rb
187
+ - lib/modularization_statistics/private/metrics/rubocop_protections_exclusions.rb
187
188
  - lib/modularization_statistics/private/source_code_file.rb
188
189
  - lib/modularization_statistics/tag.rb
189
190
  - lib/modularization_statistics/tags.rb