diff --git a/Gemfile.lock b/Gemfile.lock index 29b3c20..1d56dc0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - pack_stats (0.1.2) + pack_stats (0.1.3) code_ownership code_teams dogapi @@ -42,11 +42,13 @@ GEM parallel (1.23.0) parse_packwerk (0.19.1) sorbet-runtime - parser (3.2.2.1) + parser (3.2.2.3) ast (~> 2.4.1) + racc pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) + racc (1.7.1) rainbow (3.1.1) rake (13.0.6) rbi (0.0.16) @@ -81,7 +83,7 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.28.0) parser (>= 3.2.1.0) - rubocop-packs (0.0.38) + rubocop-packs (0.0.41) activesupport packs parse_packwerk diff --git a/lib/pack_stats/private/datadog_reporter.rb b/lib/pack_stats/private/datadog_reporter.rb index d04d075..35d7051 100644 --- a/lib/pack_stats/private/datadog_reporter.rb +++ b/lib/pack_stats/private/datadog_reporter.rb @@ -6,7 +6,6 @@ require 'pack_stats/private/metrics/files' require 'pack_stats/private/metrics/public_usage' require 'pack_stats/private/metrics/packwerk_checker_usage' -require 'pack_stats/private/metrics/rubocop_usage' require 'pack_stats/private/metrics/dependencies' require 'pack_stats/private/metrics/packages' require 'pack_stats/private/metrics/packages_by_team' diff --git a/lib/pack_stats/private/metrics/packages.rb b/lib/pack_stats/private/metrics/packages.rb index 910ad2c..71cf029 100644 --- a/lib/pack_stats/private/metrics/packages.rb +++ b/lib/pack_stats/private/metrics/packages.rb @@ -31,7 +31,6 @@ def self.get_package_metrics(packages, app_name) all_metrics << GaugeMetric.for('all_packages.has_readme.count', packages.count { |package| Metrics.has_readme?(package) }, package_tags) all_metrics += Metrics::PackwerkCheckerUsage.get_checker_metrics('all_packages', packages, package_tags) - all_metrics += Metrics::RubocopUsage.get_metrics('all_packages', packages, package_tags) all_metrics << GaugeMetric.for('all_packages.package_based_file_ownership.count', packages.count { |package| !package.metadata['owner'].nil? }, package_tags) inbound_violations_by_package = packages.flat_map(&:violations).group_by(&:to_package_name) diff --git a/lib/pack_stats/private/metrics/rubocop_usage.rb b/lib/pack_stats/private/metrics/rubocop_usage.rb deleted file mode 100644 index ce9981a..0000000 --- a/lib/pack_stats/private/metrics/rubocop_usage.rb +++ /dev/null @@ -1,98 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -module PackStats - module Private - module Metrics - class RubocopUsage - extend T::Sig - - sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) } - def self.get_metrics(prefix, packages, package_tags) - [ - *get_rubocop_exclusions(prefix, packages, package_tags), - *get_rubocop_usage_metrics(prefix, packages, package_tags) - ] - end - - sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) } - def self.get_rubocop_usage_metrics(prefix, packages, package_tags) - metrics = T.let([], T::Array[GaugeMetric]) - - rubocops.each do |cop_name| - ['false', 'true', 'strict'].each do |enabled_mode| - count_of_packages = ParsePackwerk.all.count do |package| - # We will likely want a rubocop-packs API for this, to be able to ask if a cop is enabled for a pack. - # It's possible we will want to allow these to be enabled at the top-level `.rubocop.yml`, - # in which case we wouldn't get the right metrics with this approach. However, we can also accept - # that as a current limitation. - rubocop_yml_file = package.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_YML) - next false if !rubocop_yml_file.exist? - rubocop_yml = YAML.load_file(rubocop_yml_file) - cop_config = rubocop_yml[cop_name] - - strict_mode = cop_config && cop_config['FailureMode'] == 'strict' - enabled = cop_config && cop_config['Enabled'] - case enabled_mode - when 'false' - !enabled - when 'true' - enabled && !strict_mode - when 'strict' - !!strict_mode - end - end - - metric_name = "#{prefix}.rubocops.#{to_tag_name(cop_name)}.#{enabled_mode}.count" - metrics << GaugeMetric.for(metric_name, count_of_packages, package_tags) - end - end - - metrics - end - - sig { params(prefix: String, packages: T::Array[ParsePackwerk::Package], package_tags: T::Array[Tag]).returns(T::Array[GaugeMetric]) } - def self.get_rubocop_exclusions(prefix, packages, package_tags) - rubocops.flat_map do |cop_name| - metric_name = "#{prefix}.rubocops.#{to_tag_name(cop_name)}.exclusions.count" - all_exclusions_count = ParsePackwerk.all.sum { |package| exclude_count_for_package_and_protection(package, cop_name)} - GaugeMetric.for(metric_name, all_exclusions_count, package_tags) - end - end - - # TODO: `rubocop-packs` may want to expose API for this - sig { params(package: ParsePackwerk::Package, cop_name: String).returns(Integer) } - def self.exclude_count_for_package_and_protection(package, cop_name) - if package.name == ParsePackwerk::ROOT_PACKAGE_NAME - rubocop_todo = package.directory.join('.rubocop_todo.yml') - else - rubocop_todo = package.directory.join(RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML) - end - - if rubocop_todo.exist? - loaded_rubocop_todo = YAML.load_file(rubocop_todo) - cop_config = loaded_rubocop_todo.fetch(cop_name, {}) - cop_config.fetch('Exclude', []).count - else - 0 - end - end - - sig { returns(T::Array[String])} - def self.rubocops - [ - 'Packs/ClassMethodsAsPublicApis', - 'Packs/RootNamespaceIsPackName', - 'Packs/TypedPublicApis', - 'Packs/DocumentedPublicApis', - ] - end - - sig { params(cop_name: String).returns(String) } - def self.to_tag_name(cop_name) - cop_name.gsub('/', '_').downcase - end - end - end - end -end diff --git a/pack_stats.gemspec b/pack_stats.gemspec index 72951df..578185a 100644 --- a/pack_stats.gemspec +++ b/pack_stats.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'pack_stats' - spec.version = '0.1.2' + spec.version = '0.1.3' spec.authors = ['Gusto Engineers'] spec.email = ['dev@gusto.com'] diff --git a/sorbet/rbi/gems/rubocop-packs@0.0.30.rbi b/sorbet/rbi/gems/rubocop-packs@0.0.30.rbi deleted file mode 100644 index 76a14d5..0000000 --- a/sorbet/rbi/gems/rubocop-packs@0.0.30.rbi +++ /dev/null @@ -1,272 +0,0 @@ -# typed: true - -# DO NOT EDIT MANUALLY -# This is an autogenerated file for types exported from the `rubocop-packs` gem. -# Please instead update this file by running `bin/tapioca gem rubocop-packs`. - -# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#4 -module RuboCop; end - -# source://rubocop-packs//lib/rubocop/cop/packwerk_lite/private.rb#4 -module RuboCop::Cop; end - -# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#5 -module RuboCop::Cop::Packs; end - -# This is a private class that represents API that we would prefer to be available somehow in Zeitwerk. -# However, the boundaries between systems (packwerk/zeitwerk, rubocop/zeitwerk) are poor in this class, so -# that would need to be separated prior to proposing any API changes in zeitwerk. -# -# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#12 -class RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi - # For now, this API includes `package_for_path` - # If this were truly zeitwerk API, it wouldn't include any mention of packs and it would likely not need the package at all - # Since it could get the actual namespace without knowing anything about packs. - # However, we would need to pass to it the desired namespace based on the pack name for it to be able to suggest - # a desired filepath. - # Likely this means that our own cop should determine the desired namespace and pass that in - # and this can determine actual namespace and how to get to expected. - # - # source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#32 - sig do - params( - relative_filename: ::String, - package_for_path: ::ParsePackwerk::Package - ).returns(T.nilable(::RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi::NamespaceContext)) - end - def for_file(relative_filename, package_for_path); end - - # source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#86 - sig { params(pack: ::ParsePackwerk::Package).returns(::String) } - def get_pack_based_namespace(pack); end - - private - - # source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#103 - sig { params(remaining_file_path: ::String, package_name: ::String).returns(::String) } - def get_actual_namespace(remaining_file_path, package_name); end - - # source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#98 - sig { params(pack: ::ParsePackwerk::Package).returns(::String) } - def get_package_last_name(pack); end - - # source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#93 - sig { returns(::Pathname) } - def root_pathname; end -end - -# source://rubocop-packs//lib/rubocop/cop/packs/root_namespace_is_pack_name/desired_zeitwerk_api.rb#15 -class RuboCop::Cop::Packs::RootNamespaceIsPackName::DesiredZeitwerkApi::NamespaceContext < ::T::Struct - const :current_fully_qualified_constant, ::String - const :current_namespace, ::String - const :expected_filepath, ::String - const :expected_namespace, ::String - - class << self - # source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13 - def inherited(s); end - end -end - -# source://rubocop-packs//lib/rubocop/cop/packwerk_lite/private.rb#5 -module RuboCop::Cop::PackwerkLite; end - -# This is a private class that represents API that we would prefer to be available somehow in Zeitwerk. -# However, the boundaries between systems (packwerk/zeitwerk, rubocop/zeitwerk) are poor in this class, so -# that would need to be separated prior to proposing any API changes in zeitwerk. -# -# source://rubocop-packs//lib/rubocop/cop/packwerk_lite/constant_resolver.rb#11 -class RuboCop::Cop::PackwerkLite::ConstantResolver; end - -# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#5 -module RuboCop::Packs - class << self - # source://rubocop-packs//lib/rubocop/packs.rb#135 - sig { void } - def bust_cache!; end - - # source://rubocop-packs//lib/rubocop/packs.rb#146 - sig { returns(::RuboCop::Packs::Private::Configuration) } - def config; end - - # @yield [config] - # - # source://rubocop-packs//lib/rubocop/packs.rb#141 - sig { params(blk: T.proc.params(arg0: ::RuboCop::Packs::Private::Configuration).void).void } - def configure(&blk); end - - # We can remove this function once package_protections is fully deprecated - # - # source://rubocop-packs//lib/rubocop/packs.rb#154 - sig { params(rule: ::String).returns(T::Set[::String]) } - def exclude_for_rule(rule); end - - # source://rubocop-packs//lib/rubocop/packs.rb#99 - sig { params(root_pathname: ::String).returns(::String) } - def pack_based_rubocop_config(root_pathname: T.unsafe(nil)); end - - # Ideally, this is API that is available to us via `rubocop` itself. - # That is: the ability to preserve the location of `.rubocop_todo.yml` files and associate - # exclusions with the closest ancestor `.rubocop_todo.yml` - # - # source://rubocop-packs//lib/rubocop/packs.rb#30 - sig { params(packs: T::Array[::ParsePackwerk::Package], files: T::Array[::String]).void } - def regenerate_todo(packs: T.unsafe(nil), files: T.unsafe(nil)); end - - # Ideally, this is API that is available to us via `rubocop` itself. - # That is: the ability to preserve the location of `.rubocop_todo.yml` files and associate - # exclusions with the closest ancestor `.rubocop_todo.yml` - # - # source://rubocop-packs//lib/rubocop/packs.rb#78 - sig { params(packs: T::Array[::ParsePackwerk::Package]).void } - def set_default_rubocop_yml(packs:); end - - # Note: when we add per-pack `.rubocop.yml` files, we'll want to add some validations here - # to restrict what cops are permitted to be configured in those files. - # We might also want further (configurable?) constraints *requiring* that the "permitted pack level cops" be specified explicitly. - # - # source://rubocop-packs//lib/rubocop/packs.rb#164 - sig { returns(T::Array[::String]) } - def validate; end - end -end - -# source://rubocop-packs//lib/rubocop/packs.rb#20 -RuboCop::Packs::CONFIG = T.let(T.unsafe(nil), Hash) - -# source://rubocop-packs//lib/rubocop/packs.rb#19 -RuboCop::Packs::CONFIG_DEFAULT = T.let(T.unsafe(nil), Pathname) - -# Because RuboCop doesn't yet support plugins, we have to monkey patch in a -# bit of our configuration. -# -# source://rubocop-packs//lib/rubocop/packs/inject.rb#10 -module RuboCop::Packs::Inject - class << self - # source://rubocop-packs//lib/rubocop/packs/inject.rb#14 - sig { void } - def defaults!; end - end -end - -# source://rubocop-packs//lib/rubocop/packs.rb#16 -RuboCop::Packs::PACK_LEVEL_RUBOCOP_TODO_YML = T.let(T.unsafe(nil), String) - -# Pack-level rubocop and rubocop_todo YML files are named differently because they are not integrated -# into rubocop in the standard way. For example, we could call these the standard `.rubocop.yml` and -# `.rubocop_todo.yml`. However, this introduces a number of path relativity issues (https://docs.rubocop.org/rubocop/configuration.html#path-relativity) -# that make this approach not possible. Therefore, for pack level rubocops, we name them in a way that mirrors packwerk `package_todo.yml` files -# for consistency and to ensure that thes are not read by rubocop except via the ERB templating mechanism. -# -# source://rubocop-packs//lib/rubocop/packs.rb#15 -RuboCop::Packs::PACK_LEVEL_RUBOCOP_YML = T.let(T.unsafe(nil), String) - -# source://rubocop-packs//lib/rubocop/packs.rb#18 -RuboCop::Packs::PROJECT_ROOT = T.let(T.unsafe(nil), Pathname) - -# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#6 -module RuboCop::Packs::Private - class << self - # source://rubocop-packs//lib/rubocop/packs/private.rb#13 - sig { void } - def bust_cache!; end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#107 - sig { params(rule: ::String).returns(T::Set[::String]) } - def exclude_for_rule(rule); end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#152 - sig { params(args: T.untyped).void } - def execute_rubocop(args); end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#19 - sig { void } - def load_client_configuration; end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#157 - sig do - params( - paths: T::Array[::String], - cop_names: T::Array[::String] - ).returns(T::Array[::RuboCop::Packs::Private::Offense]) - end - def offenses_for(paths:, cop_names:); end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#29 - sig { returns(T::Array[T::Hash[T.untyped, T.untyped]]) } - def rubocop_todo_ymls; end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#126 - sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) } - def validate_failure_mode_strict(package); end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#40 - sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) } - def validate_rubocop_todo_yml(package); end - - # source://rubocop-packs//lib/rubocop/packs/private.rb#75 - sig { params(package: ::ParsePackwerk::Package).returns(T::Array[::String]) } - def validate_rubocop_yml(package); end - end -end - -# source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#7 -class RuboCop::Packs::Private::Configuration - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#20 - sig { void } - def initialize; end - - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#27 - sig { void } - def bust_cache!; end - - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#17 - sig { returns(T::Array[::String]) } - def globally_permitted_namespaces; end - - # @return [Array] - # - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#17 - def globally_permitted_namespaces=(_arg0); end - - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#11 - sig { returns(T::Array[::String]) } - def permitted_pack_level_cops; end - - # @return [Array] - # - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#11 - def permitted_pack_level_cops=(_arg0); end - - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#14 - sig { returns(T::Array[::String]) } - def required_pack_level_cops; end - - # @return [Array] - # - # source://rubocop-packs//lib/rubocop/packs/private/configuration.rb#14 - def required_pack_level_cops=(_arg0); end -end - -# source://rubocop-packs//lib/rubocop/packs/private/offense.rb#6 -class RuboCop::Packs::Private::Offense < ::T::Struct - const :cop_name, ::String - const :filepath, ::String - - # source://rubocop-packs//lib/rubocop/packs/private/offense.rb#13 - sig { returns(::ParsePackwerk::Package) } - def pack; end - - class << self - # source://sorbet-runtime/0.5.9924/lib/types/struct.rb#13 - def inherited(s); end - end -end - -# See docs/packwerk_lite.md -# -# source://rubocop-packs//lib/rubocop/packwerk_lite.rb#11 -module RuboCop::PackwerkLite; end - -# source://rubocop-packs//lib/rubocop/packwerk_lite.rb#12 -class RuboCop::PackwerkLite::Error < ::StandardError; end diff --git a/spec/pack_stats_spec.rb b/spec/pack_stats_spec.rb index 75c1099..e06780b 100644 --- a/spec/pack_stats_spec.rb +++ b/spec/pack_stats_spec.rb @@ -83,12 +83,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.false.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.false.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.false.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.all_files.count', 0, Tags.for(['app:MyApp'])) @@ -96,8 +90,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping end it 'emits no metrics about rubocop exclusions' do - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.exclusions.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.exclusions.count', 0, Tags.for(['app:MyApp'])) end end @@ -130,9 +122,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['package:packs/only_package', 'app:MyApp', 'team:Unknown', 'violation_type:dependency'])) @@ -182,9 +171,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['package:packs/only_package', 'app:MyApp', 'team:Unknown', 'violation_type:dependency'])) @@ -246,9 +232,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['package:packs/package_2', 'app:MyApp', 'team:Unknown', 'violation_type:dependency'])) @@ -392,9 +375,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 2, Tags.for(['app:MyApp', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 1, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 2, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['package:packs/package_2', 'app:MyApp', 'team:Chefs', 'violation_type:privacy'])) @@ -595,22 +575,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping modularization.all_packages.packwerk_checkers.strict.count modularization.all_packages.packwerk_checkers.true.count modularization.all_packages.public_files.count - modularization.all_packages.rubocops.packs_classmethodsaspublicapis.exclusions.count - modularization.all_packages.rubocops.packs_classmethodsaspublicapis.false.count - modularization.all_packages.rubocops.packs_classmethodsaspublicapis.strict.count - modularization.all_packages.rubocops.packs_classmethodsaspublicapis.true.count - modularization.all_packages.rubocops.packs_documentedpublicapis.exclusions.count - modularization.all_packages.rubocops.packs_documentedpublicapis.false.count - modularization.all_packages.rubocops.packs_documentedpublicapis.strict.count - modularization.all_packages.rubocops.packs_documentedpublicapis.true.count - modularization.all_packages.rubocops.packs_rootnamespaceispackname.exclusions.count - modularization.all_packages.rubocops.packs_rootnamespaceispackname.false.count - modularization.all_packages.rubocops.packs_rootnamespaceispackname.strict.count - modularization.all_packages.rubocops.packs_rootnamespaceispackname.true.count - modularization.all_packages.rubocops.packs_typedpublicapis.exclusions.count - modularization.all_packages.rubocops.packs_typedpublicapis.false.count - modularization.all_packages.rubocops.packs_typedpublicapis.strict.count - modularization.all_packages.rubocops.packs_typedpublicapis.true.count modularization.all_packages.using_public_directory.count modularization.all_packages.violations.count modularization.by_package.all_files.count @@ -662,9 +626,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 3, Tags.for(['app:MyApp', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 0, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 2, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 0, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 4, Tags.for(['package:packs/package_2', 'app:MyApp', 'team:Unknown', 'violation_type:dependency'])) @@ -746,9 +707,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 2, Tags.for(['app:MyApp', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.strict.count', 2, Tags.for(['app:MyApp', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.packwerk_checkers.true.count', 2, Tags.for(['app:MyApp', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.strict.count', 1, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.true.count', 1, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.strict.count', 1, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.package_based_file_ownership.count', 0, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('all_packages.using_public_directory.count', 1, Tags.for(['app:MyApp'])) expect(metrics).to include_metric GaugeMetric.for('by_package.violations.count', 0, Tags.for(['package:packs/package_2', 'app:MyApp', 'team:Unknown', 'violation_type:dependency'])) @@ -963,8 +921,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping end it 'emits metrics about rubocop exclusions' do - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_typedpublicapis.exclusions.count', 6, Tags.for(['app:MyApp'])) - expect(metrics).to include_metric GaugeMetric.for('all_packages.rubocops.packs_rootnamespaceispackname.exclusions.count', 6, Tags.for(['app:MyApp'])) end end @@ -1006,9 +962,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.packwerk_checkers.true.count', count: 2, tags: Tags.for(['app:MyApp', 'max_enforcements:true', 'violation_type:dependency'])) expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.packwerk_checkers.strict.count', count: 0, tags: Tags.for(['app:MyApp', 'max_enforcements:true', 'violation_type:privacy'])) expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.packwerk_checkers.true.count', count: 2, tags: Tags.for(['app:MyApp', 'max_enforcements:true', 'violation_type:privacy'])) - expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.rubocops.packs_typedpublicapis.strict.count', count: 0, tags: Tags.for(['app:MyApp', 'max_enforcements:true'])) - expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.rubocops.packs_typedpublicapis.true.count', count: 0, tags: Tags.for(['app:MyApp', 'max_enforcements:true'])) - expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.rubocops.packs_rootnamespaceispackname.strict.count', count: 0, tags: Tags.for(['app:MyApp', 'max_enforcements:true'])) expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.package_based_file_ownership.count', count: 0, tags: Tags.for(['app:MyApp', 'max_enforcements:true'])) expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.all_packages.using_public_directory.count', count: 0, tags: Tags.for(['app:MyApp', 'max_enforcements:true'])) expect(metrics).to include_metric GaugeMetric.new(name: 'modularization.by_package.violations.count', count: 0, tags: Tags.for(['package:packs/only_package', 'app:MyApp', 'team:Unknown', 'max_enforcements:true', 'violation_type:dependency']))