package_protections 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rubocop/cop/package_protections/namespaced_under_package_name.rb +13 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 217ae8f6eee7f084ff39ce7c4cf0bb06a08c361abff49e411d730a3a79592b71
|
4
|
+
data.tar.gz: 21a4eea2876078f531a67d3705e7a0d38c11b3bf87cd265e552bda9e8661638a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1633812b257db230cf9f0244c8dd397197d4feb98f37abcd9906e5660adbfb7985c82fc6758254f99771726d49d3796c2e30438a54bd14a75c9ed3b64dbca1a0
|
7
|
+
data.tar.gz: e1aafb82c4a5a93425cbfc28135bae436b792681f6cbd8257f95e2d51d985a436e80d191313d2959a3e9c37423f970608109bca773a5ffe0ad01af3d6214b6da
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ This protection only looks at files in `packs/your_pack/app` (it ignores spec fi
|
|
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
57
|
Lastly – this protection can be configured by setting `globally_permitted_namespaces`, e.g.:
|
58
58
|
```ruby
|
59
|
-
|
59
|
+
RuboCop::Packs.configure do |config|
|
60
60
|
config.globally_permitted_namespaces = ['SomeGlobalNamespace']
|
61
61
|
end
|
62
62
|
```
|
@@ -34,7 +34,7 @@ module RuboCop
|
|
34
34
|
enabled: include_packs.any?,
|
35
35
|
metadata: {
|
36
36
|
'IncludePacks' => include_packs,
|
37
|
-
'GloballyPermittedNamespaces' => ::
|
37
|
+
'GloballyPermittedNamespaces' => ::RuboCop::Packs.config.globally_permitted_namespaces
|
38
38
|
}
|
39
39
|
)
|
40
40
|
]
|
@@ -57,23 +57,19 @@ module RuboCop
|
|
57
57
|
|
58
58
|
sig { override.params(behavior: ::PackageProtections::ViolationBehavior, package: ParsePackwerk::Package).returns(T.nilable(String)) }
|
59
59
|
def unmet_preconditions_for_behavior(behavior, package)
|
60
|
-
if
|
61
|
-
|
62
|
-
else
|
63
|
-
# We don't need to validate if the behavior is currentely fail_never
|
64
|
-
return if behavior.fail_never?
|
60
|
+
# We don't need to validate if the behavior is currentely fail_never
|
61
|
+
return if behavior.fail_never?
|
65
62
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
63
|
+
# The reason for this is precondition is the `MultipleNamespacesProtection` assumes this to work properly.
|
64
|
+
# To remove this precondition, we need to modify `MultipleNamespacesProtection` to be more generalized!
|
65
|
+
is_root_package = package.name == ParsePackwerk::ROOT_PACKAGE_NAME
|
66
|
+
in_allowed_directory = ::PackageProtections::EXPECTED_PACK_DIRECTORIES.any? do |expected_package_directory|
|
67
|
+
package.directory.to_s.start_with?(expected_package_directory)
|
68
|
+
end
|
69
|
+
if in_allowed_directory || is_root_package
|
70
|
+
nil
|
71
|
+
else
|
72
|
+
"Package #{package.name} must be located in one of #{::PackageProtections::EXPECTED_PACK_DIRECTORIES.join(', ')} (or be the root) to use this protection"
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
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: 3.
|
4
|
+
version: 3.1.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-
|
11
|
+
date: 2022-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|