package_protections 2.1.1 → 2.2.1

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: f503d714980699ad618258d74bb41489328aedce9e8201bfc7e1a5a086e0bdf9
4
- data.tar.gz: d3cc2f5d197322d29dff1b794f889bc74b2a79e431e8bf7b70ec1d4e81cfabd4
3
+ metadata.gz: 6797406abd58b1f207223519e6351b0c26ee54c7c79d7400f74400b71a16e556
4
+ data.tar.gz: e7a583cebe8634d730f665c31aaee955d6d1d2b83e5322a07c0d1c1f917abda1
5
5
  SHA512:
6
- metadata.gz: 6198bc334e103a52eeac5110fab05a21a72b6ed22f33b7ef455b23cb6cbb93fea9ed0b9f2a9ff122ad80ddc587d21fdbb7b7398ed6aef94ad9ad5470666932da
7
- data.tar.gz: c1fd8d5e56cd37b29304dd467effef8a8cb062ed059ffa434cfff6a4c1300a191612042457139b8715737b7b2a732b44b2d2a0b1c961e934773ae9e4da093544
6
+ metadata.gz: f40cb6189fc8d3b4364fce64e2933f929af1ad35a2a956cc9cea4ff46042cf2719379e0e8f8e6e82e1df68dcf1cf07a3326733c68e55bfe50a2d1914a9a3b34b
7
+ data.tar.gz: ff10108a8577060d176820a74a939da8897bc566117a9f68e5c6f7c832cbd7047448a216913972bb7b47801c524dddd088c10a6f55a750b60ffd2b915a6d0764
@@ -35,8 +35,6 @@ module PackageProtections
35
35
 
36
36
  sig { returns(T::Array[ProtectionInterface]) }
37
37
  def default_protections
38
- require 'rubocop/cop/package_protections'
39
-
40
38
  [
41
39
  Private::OutgoingDependencyProtection.new,
42
40
  Private::IncomingPrivacyProtection.new,
@@ -117,6 +117,9 @@ module PackageProtections
117
117
  @protected_packages_indexed_by_name = nil
118
118
  @private_cop_config = nil
119
119
  PackageProtections.config.bust_cache!
120
+ # This comes explicitly after `PackageProtections.config.bust_cache!` because
121
+ # otherwise `PackageProtections.config` will attempt to reload the client configuratoin.
122
+ @loaded_client_configuration = false
120
123
  end
121
124
 
122
125
  sig { params(identifier: Identifier).returns(T::Hash[T.untyped, T.untyped]) }
@@ -150,6 +153,8 @@ module PackageProtections
150
153
  excludes = T.let(Set.new, T::Set[String])
151
154
 
152
155
  Private.rubocop_todo_ymls.each do |todo_yml|
156
+ next if !todo_yml
157
+
153
158
  config = todo_yml[rule]
154
159
  next if config.nil?
155
160
 
@@ -161,6 +166,16 @@ module PackageProtections
161
166
 
162
167
  excludes
163
168
  end
169
+
170
+ sig { void }
171
+ def self.load_client_configuration
172
+ @loaded_client_configuration ||= T.let(false, T.nilable(T::Boolean))
173
+ return if @loaded_client_configuration
174
+
175
+ @loaded_client_configuration = true
176
+ client_configuration = Pathname.pwd.join('config/package_protections.rb')
177
+ require client_configuration.to_s if client_configuration.exist?
178
+ end
164
179
  end
165
180
 
166
181
  private_constant :Private
@@ -1,23 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # typed: strict
4
-
5
4
  require 'sorbet-runtime'
6
-
7
5
  require 'open3'
8
6
  require 'set'
9
7
  require 'parse_packwerk'
8
+ require 'rubocop'
9
+ require 'rubocop-sorbet'
10
10
 
11
- require 'zeitwerk'
12
- loader = T.unsafe(Zeitwerk::Loader).for_gem
13
- loader.ignore("#{__dir__}/rubocop")
14
- loader.setup
15
-
11
+ #
16
12
  # Welcome to PackageProtections!
17
13
  # See https://github.com/rubyatscale/package_protections#readme for more info
18
14
  #
19
15
  # This file is a reference for the available API to `package_protections`, but all implementation details are private
20
16
  # (which is why we delegate to `Private` for the actual implementation).
17
+ #
21
18
  module PackageProtections
22
19
  extend T::Sig
23
20
 
@@ -30,6 +27,18 @@ module PackageProtections
30
27
  # This is currently the only handled exception that `PackageProtections` will throw.
31
28
  class IncorrectPublicApiUsageError < StandardError; end
32
29
 
30
+ require 'package_protections/offense'
31
+ require 'package_protections/violation_behavior'
32
+ require 'package_protections/protected_package'
33
+ require 'package_protections/per_file_violation'
34
+ require 'package_protections/protection_interface'
35
+ require 'package_protections/rubocop_protection_interface'
36
+ require 'package_protections/private'
37
+
38
+ # Implementation of rubocop-based protections
39
+ require 'rubocop/cop/package_protections/namespaced_under_package_name'
40
+ require 'rubocop/cop/package_protections/typed_public_api'
41
+
33
42
  class << self
34
43
  extend T::Sig
35
44
 
@@ -46,6 +55,7 @@ module PackageProtections
46
55
 
47
56
  sig { returns(Private::Configuration) }
48
57
  def self.config
58
+ Private.load_client_configuration
49
59
  @config = T.let(@config, T.nilable(Private::Configuration))
50
60
  @config ||= Private::Configuration.new
51
61
  end
@@ -119,7 +129,3 @@ module PackageProtections
119
129
  RubocopProtectionInterface.bust_rubocop_todo_yml_cache
120
130
  end
121
131
  end
122
-
123
- if defined?(Rubocop)
124
- require 'rubocop/cop/package_protections'
125
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: package_protections
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.1
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-09-22 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: zeitwerk
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: rake
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -205,7 +191,6 @@ files:
205
191
  - lib/package_protections/rspec/support.rb
206
192
  - lib/package_protections/rubocop_protection_interface.rb
207
193
  - lib/package_protections/violation_behavior.rb
208
- - lib/rubocop/cop/package_protections.rb
209
194
  - lib/rubocop/cop/package_protections/namespaced_under_package_name.rb
210
195
  - lib/rubocop/cop/package_protections/namespaced_under_package_name/desired_zeitwerk_api.rb
211
196
  - lib/rubocop/cop/package_protections/typed_public_api.rb
@@ -1,13 +0,0 @@
1
- require 'rubocop'
2
- require 'rubocop-sorbet'
3
-
4
- module RuboCop
5
- module Cop
6
- module PackageProtections
7
- autoload :NamespacedUnderPackageName, 'rubocop/cop/package_protections/namespaced_under_package_name'
8
- autoload :TypedPublicApi, 'rubocop/cop/package_protections/typed_public_api'
9
- end
10
- end
11
- end
12
-
13
- # Implementation of rubocop-based protections