package_protections 2.5.0 → 2.5.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db265db203f34615ababcc47b7c18ac926cc2dde00c87ff6e7e88ada45eca909
|
4
|
+
data.tar.gz: 9a4d401d4b3c6806e047cf34ee37e92a68c53f59cbf3a18b2a048233388e18e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d89ef740b11b54d759cc4548279a45bf4c924ed215ef7cb07b0203cf8cf14aaff8b33d363f3e50c58a440fc71fa35d93dc7443ee965999d3c95c7be53fe0eb39
|
7
|
+
data.tar.gz: d0abae5dfc74ab2b66b9e32ef9f22b31cd5ad1c2d3e37c42a779d7b1d773aaa3cccc8099d298cad36a219c18b693fe17f997db1f0f929207793f25bc16ab27b0
|
data/README.md
CHANGED
@@ -54,21 +54,14 @@ This protection ensures that all files within `app/public` are typed at level `s
|
|
54
54
|
This helps ensure that your package is only creating one namespace (based on folder hierarchy). This helps organize the public API of your pack into one place.
|
55
55
|
This protection only looks at files in `packs/your_pack/app` (it ignores spec files).
|
56
56
|
This protection is implemented via Rubocop -- expect to see results for this when running `rubocop` however you normally do. To add to the TODO list, add to `.rubocop_todo.yml`
|
57
|
-
Lastly – this protection can be configured by setting `
|
58
|
-
```
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
protections:
|
63
|
-
# ... nothing changes here
|
64
|
-
global_namespaces:
|
65
|
-
- MyNamespace
|
66
|
-
- MyOtherNamespace
|
67
|
-
- MyThirdNamespace
|
68
|
-
# ... etc.
|
57
|
+
Lastly – this protection can be configured by setting `globally_permitted_namespaces`, e.g.:
|
58
|
+
```ruby
|
59
|
+
PackageProtections.configure do |config|
|
60
|
+
config.globally_permitted_namespaces = ['SomeGlobalNamespace']
|
61
|
+
end
|
69
62
|
```
|
70
63
|
|
71
|
-
|
64
|
+
If you've worked through all of the TODOs for this cop and are able to set the value to `fail_on_any`, you can also set `automatic_pack_namespace` which will support your pack having one global namespace without extra subdirectories. That is, instead of `packs/foo/app/services/foo/bar.rb`, you can use `packs/foo/app/services/bar.rb` and still have it define `Foo::Bar`. [See the `stimpack` README.md](https://github.com/rubyatscale/stimpack#readme) for more information.
|
72
65
|
|
73
66
|
### `prevent_other_packages_from_using_this_package_without_explicit_visibility`
|
74
67
|
*This is only available if your package has `enforce_privacy` set to `true`!*
|
@@ -115,58 +115,12 @@ module PackageProtections
|
|
115
115
|
sig { void }
|
116
116
|
def self.bust_cache!
|
117
117
|
@protected_packages_indexed_by_name = nil
|
118
|
-
@private_cop_config = nil
|
119
118
|
PackageProtections.config.bust_cache!
|
120
119
|
# This comes explicitly after `PackageProtections.config.bust_cache!` because
|
121
120
|
# otherwise `PackageProtections.config` will attempt to reload the client configuratoin.
|
122
121
|
@loaded_client_configuration = false
|
123
122
|
end
|
124
123
|
|
125
|
-
sig { params(identifier: Identifier).returns(T::Hash[T.untyped, T.untyped]) }
|
126
|
-
def self.private_cop_config(identifier)
|
127
|
-
@private_cop_config ||= T.let(@private_cop_config, T.nilable(T::Hash[T.untyped, T.untyped]))
|
128
|
-
@private_cop_config ||= begin
|
129
|
-
protected_packages = all_protected_packages
|
130
|
-
protection = T.cast(PackageProtections.with_identifier(identifier), PackageProtections::RubocopProtectionInterface)
|
131
|
-
protected_packages.to_h { |p| [p.name, protection.custom_cop_config(p)] }
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
sig { returns(T::Array[T::Hash[T.untyped, T.untyped]]) }
|
136
|
-
def self.rubocop_todo_ymls
|
137
|
-
@rubocop_todo_ymls = T.let(@rubocop_todo_ymls, T.nilable(T::Array[T::Hash[T.untyped, T.untyped]]))
|
138
|
-
@rubocop_todo_ymls ||= begin
|
139
|
-
todo_files = Pathname.glob('**/.rubocop_todo.yml')
|
140
|
-
todo_files.map do |todo_file|
|
141
|
-
YAML.load_file(todo_file)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
sig { void }
|
147
|
-
def self.bust_rubocop_todo_yml_cache
|
148
|
-
@rubocop_todo_ymls = nil
|
149
|
-
end
|
150
|
-
|
151
|
-
sig { params(rule: String).returns(T::Set[String]) }
|
152
|
-
def self.exclude_for_rule(rule)
|
153
|
-
excludes = T.let(Set.new, T::Set[String])
|
154
|
-
|
155
|
-
Private.rubocop_todo_ymls.each do |todo_yml|
|
156
|
-
next if !todo_yml
|
157
|
-
|
158
|
-
config = todo_yml[rule]
|
159
|
-
next if config.nil?
|
160
|
-
|
161
|
-
exclude_list = config['Exclude']
|
162
|
-
next if exclude_list.nil?
|
163
|
-
|
164
|
-
excludes += exclude_list
|
165
|
-
end
|
166
|
-
|
167
|
-
excludes
|
168
|
-
end
|
169
|
-
|
170
124
|
sig { void }
|
171
125
|
def self.load_client_configuration
|
172
126
|
@loaded_client_configuration ||= T.let(false, T.nilable(T::Boolean))
|
@@ -57,9 +57,9 @@ module PackageProtections
|
|
57
57
|
# but a default is provided.
|
58
58
|
############################################################################
|
59
59
|
sig do
|
60
|
-
|
60
|
+
returns(T::Hash[T.untyped, T.untyped])
|
61
61
|
end
|
62
|
-
def custom_cop_config
|
62
|
+
def custom_cop_config
|
63
63
|
{}
|
64
64
|
end
|
65
65
|
|
@@ -75,18 +75,13 @@ module PackageProtections
|
|
75
75
|
[]
|
76
76
|
end
|
77
77
|
|
78
|
-
sig { void }
|
79
|
-
def self.bust_rubocop_todo_yml_cache
|
80
|
-
Private.bust_rubocop_todo_yml_cache
|
81
|
-
end
|
82
|
-
|
83
78
|
sig do
|
84
79
|
override.params(
|
85
80
|
protected_packages: T::Array[ProtectedPackage]
|
86
81
|
).returns(T::Array[Offense])
|
87
82
|
end
|
88
83
|
def get_offenses_for_existing_violations(protected_packages)
|
89
|
-
exclude_list =
|
84
|
+
exclude_list = RuboCop::Packs.exclude_for_rule(cop_name)
|
90
85
|
offenses = []
|
91
86
|
|
92
87
|
protected_packages.each do |package|
|
@@ -135,7 +130,8 @@ module PackageProtections
|
|
135
130
|
CopConfig.new(
|
136
131
|
name: cop_name,
|
137
132
|
enabled: include_paths.any?,
|
138
|
-
include_paths: include_paths
|
133
|
+
include_paths: include_paths,
|
134
|
+
metadata: custom_cop_config
|
139
135
|
)
|
140
136
|
]
|
141
137
|
end
|
data/lib/package_protections.rb
CHANGED
@@ -118,18 +118,9 @@ module PackageProtections
|
|
118
118
|
Private.rubocop_yml(root_pathname: root_pathname)
|
119
119
|
end
|
120
120
|
|
121
|
-
#
|
122
|
-
# Do not use this method -- it's meant to be used by Rubocop cops to get directory-specific
|
123
|
-
# parameters without needing to have directory-specific .rubocop.yml files.
|
124
|
-
#
|
125
|
-
sig { params(identifier: Identifier).returns(T::Hash[T.untyped, T.untyped]) }
|
126
|
-
def self.private_cop_config(identifier)
|
127
|
-
Private.private_cop_config(identifier)
|
128
|
-
end
|
129
|
-
|
130
121
|
sig { void }
|
131
122
|
def self.bust_cache!
|
132
123
|
Private.bust_cache!
|
133
|
-
|
124
|
+
RuboCop::Packs.bust_cache!
|
134
125
|
end
|
135
126
|
end
|
@@ -33,6 +33,15 @@ module RuboCop
|
|
33
33
|
]
|
34
34
|
end
|
35
35
|
|
36
|
+
sig do
|
37
|
+
override.returns(T::Hash[T.untyped, T.untyped])
|
38
|
+
end
|
39
|
+
def custom_cop_config
|
40
|
+
{
|
41
|
+
'AcceptableParentClasses' => ::PackageProtections.config.acceptable_parent_classes
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
36
45
|
sig { override.returns(String) }
|
37
46
|
def identifier
|
38
47
|
IDENTIFIER
|
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.5.
|
4
|
+
version: 2.5.2
|
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-10-
|
11
|
+
date: 2022-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|