@@ -910,130 +910,6 @@ module PackStats # rubocop:disable RSpec/DescribedClassModuleWrapping
910910 end
911911 end
912912
913- context 'in an app with nested packs' do
914- before do
915- write_package_yml ( '.' )
916- write_package_yml ( 'packs/fruits' )
917- write_package_yml ( 'packs/fruits/apples' )
918- write_package_yml ( 'packs/fruits/pears' )
919-
920- write_package_yml ( 'packs/vegetables' )
921- write_package_yml ( 'packs/vegetables/broccoli' )
922-
923- write_package_yml ( 'packs/peanuts' )
924- write_package_yml ( 'packs/cashews' )
925-
926- # Represents TWO privacy and TWO dependency violations across pack groups
927- write_file ( 'package_todo.yml' , <<~CONTENTS )
928- # This file contains a list of dependencies that are not part of the long term plan for ..
929- # We should generally work to reduce this list, but not at the expense of actually getting work done.
930- #
931- # You can regenerate this file using the following command:
932- #
933- # bundle exec packwerk update-deprecations .
934- ---
935- packs/fruits:
936- "FruitsConstant":
937- violations:
938- - dependency
939- - privacy
940- files:
941- - some_file1.rb
942- - some_file2.rb
943- CONTENTS
944-
945- # Represents ONE privacy and ZERO dependency violations across pack groups
946- write_file ( 'packs/fruits/package_todo.yml' , <<~CONTENTS )
947- # This file contains a list of dependencies that are not part of the long term plan for ..
948- # We should generally work to reduce this list, but not at the expense of actually getting work done.
949- #
950- # You can regenerate this file using the following command:
951- #
952- # bundle exec packwerk update-deprecations .
953- ---
954- packs/fruits/apples:
955- "ApplesConstant":
956- violations:
957- - dependency
958- - privacy
959- files:
960- - some_file1.rb
961- - some_file2.rb
962- packs/peanuts:
963- "PeanutsConstant":
964- violations:
965- - privacy
966- files:
967- - some_file1.rb
968- CONTENTS
969-
970- # Represents ZERO violations across pack groups
971- write_file ( 'packs/fruits/apples/package_todo.yml' , <<~CONTENTS )
972- # This file contains a list of dependencies that are not part of the long term plan for ..
973- # We should generally work to reduce this list, but not at the expense of actually getting work done.
974- #
975- # You can regenerate this file using the following command:
976- #
977- # bundle exec packwerk update-deprecations .
978- ---
979- packs/fruits:
980- "FruitsConstant":
981- violations:
982- - dependency
983- - privacy
984- files:
985- - packs/fruits/apples/some_file1.rb
986- - packs/fruits/apples/some_file2.rb
987- - packs/fruits/apples/some_file3.rb
988- - packs/fruits/apples/some_file4.rb
989- packs/fruits/pears:
990- "PearsConstant":
991- violations:
992- - dependency
993- - privacy
994- files:
995- - packs/fruits/apples/some_file1.rb
996- - packs/fruits/apples/some_file2.rb
997- - packs/fruits/apples/some_file3.rb
998- - packs/fruits/apples/some_file4.rb
999- packs/peanuts:
1000- "PeanutsConstant":
1001- violations:
1002- - dependency
1003- files:
1004- - packs/fruits/apples/some_file1.rb
1005- CONTENTS
1006- end
1007-
1008- it 'emits the right metrics' do
1009- expect ( metrics ) . to include_metric GaugeMetric . for ( 'all_packages.count' , 8 , Tags . for ( [ 'app:MyApp' ] ) )
1010- expect ( metrics ) . to include_metric GaugeMetric . for ( 'all_pack_groups.count' , 5 , Tags . for ( [ 'app:MyApp' ] ) )
1011- expect ( metrics ) . to include_metric GaugeMetric . for ( 'child_packs.count' , 3 , Tags . for ( [ 'app:MyApp' ] ) )
1012- expect ( metrics ) . to include_metric GaugeMetric . for ( 'parent_packs.count' , 2 , Tags . for ( [ 'app:MyApp' ] ) )
1013-
1014- # Notice that this does not use a tag to specify the pack group -- the metric itself only sends information about cross-pack group violations
1015- expect ( metrics ) . to include_metric GaugeMetric . for ( 'all_pack_groups.privacy_violations.count' , 3 , Tags . for ( [ 'app:MyApp' ] ) )
1016- expect ( metrics ) . to include_metric GaugeMetric . for ( 'all_pack_groups.dependency_violations.count' , 3 , Tags . for ( [ 'app:MyApp' ] ) )
1017-
1018- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.count' , 2 , Tags . for ( [ 'app:MyApp' , 'pack_group:root' ] ) )
1019- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.count' , 1 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/fruits' ] ) )
1020- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.count' , 0 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/vegetables' ] ) )
1021- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.count' , 0 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/peanuts' ] ) )
1022- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.count' , 0 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/cashews' ] ) )
1023-
1024- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.inbound_privacy_violations.count' , 0 , Tags . for ( [ 'app:MyApp' , 'pack_group:root' ] ) )
1025- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.inbound_privacy_violations.count' , 2 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/fruits' ] ) )
1026- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.inbound_privacy_violations.count' , 0 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/vegetables' ] ) )
1027- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.inbound_privacy_violations.count' , 1 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/peanuts' ] ) )
1028- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.inbound_privacy_violations.count' , 0 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/cashews' ] ) )
1029-
1030- # This does have a tag for pack group, but the metric itself also only sends information about cross-pack group violations.
1031- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.per_pack_group.count' , 2 , Tags . for ( [ 'app:MyApp' , 'pack_group:root' , 'to_pack_group:packs/fruits' ] ) )
1032- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_privacy_violations.per_pack_group.count' , 2 , Tags . for ( [ 'app:MyApp' , 'pack_group:root' , 'to_pack_group:packs/fruits' ] ) )
1033- expect ( metrics ) . to include_metric GaugeMetric . for ( 'by_pack_group.outbound_dependency_violations.per_pack_group.count' , 1 , Tags . for ( [ 'app:MyApp' , 'pack_group:packs/fruits' , 'to_pack_group:packs/peanuts' ] ) )
1034- end
1035- end
1036-
1037913 context 'in an app with exclusions for rubocop based protections' do
1038914 before do
1039915 write_package_yml ( '.' )
0 commit comments