package_protections 2.1.1 → 2.2.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: f503d714980699ad618258d74bb41489328aedce9e8201bfc7e1a5a086e0bdf9
4
- data.tar.gz: d3cc2f5d197322d29dff1b794f889bc74b2a79e431e8bf7b70ec1d4e81cfabd4
3
+ metadata.gz: 209662f8b4bb58c12b998627275107715b1b92f72250dd57275a830db2b3ee28
4
+ data.tar.gz: 72dfeeca3bc2e0d83af7d7274fb7574b9d50fa41df594a56673a997b7ca5c63f
5
5
  SHA512:
6
- metadata.gz: 6198bc334e103a52eeac5110fab05a21a72b6ed22f33b7ef455b23cb6cbb93fea9ed0b9f2a9ff122ad80ddc587d21fdbb7b7398ed6aef94ad9ad5470666932da
7
- data.tar.gz: c1fd8d5e56cd37b29304dd467effef8a8cb062ed059ffa434cfff6a4c1300a191612042457139b8715737b7b2a732b44b2d2a0b1c961e934773ae9e4da093544
6
+ metadata.gz: f21c828d5523d288a4b4bbc297efc15ef54cbc8e34871d3338cbeccf12254b5c21e20613a22f7a950edaf27f4052b27db4ffc86d34378eb254760618895245d2
7
+ data.tar.gz: 6cf01a48f348a4d297a3153b6129bb139f78206d46daf29bc5b543a84debc309780645ddb6979e8375b8cdf8affcdd4f70af3eea02eb33d07a2445b3ec8f1ba9
@@ -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]) }
@@ -161,6 +164,16 @@ module PackageProtections
161
164
 
162
165
  excludes
163
166
  end
167
+
168
+ sig { void }
169
+ def self.load_client_configuration
170
+ @loaded_client_configuration ||= T.let(false, T.nilable(T::Boolean))
171
+ return if @loaded_client_configuration
172
+
173
+ @loaded_client_configuration = true
174
+ client_configuration = Pathname.pwd.join('config/package_protections.rb')
175
+ require client_configuration.to_s if client_configuration.exist?
176
+ end
164
177
  end
165
178
 
166
179
  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.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-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