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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c09fbdc359d1dc28d4168fc0041dc385ea8a5b78c77436c598d5f6fd3eb24d6
4
- data.tar.gz: 7ab7d9d30955c98c8213434b80923a96602a2489e2b822b9e8f75f3ff25145e8
3
+ metadata.gz: 217ae8f6eee7f084ff39ce7c4cf0bb06a08c361abff49e411d730a3a79592b71
4
+ data.tar.gz: 21a4eea2876078f531a67d3705e7a0d38c11b3bf87cd265e552bda9e8661638a
5
5
  SHA512:
6
- metadata.gz: 0027653c627faaacdc1e7dfe57342d10130b93cd833a5083091c54fbc48ba106366768671ce703cdf5c4576dcd53db10a39cc59f0262fc18b06153d00ddcc284
7
- data.tar.gz: 1494769fd3a1120add3da651cba6b0c826cc990890669810eb1532404ef1e2820470628bc89a77794589b819ed557da9cb3127910deebe2780854d560760ad9d
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
- PackageProtections.configure do |config|
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' => ::PackageProtections.config.globally_permitted_namespaces
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 !behavior.enabled? && !package.metadata['global_namespaces'].nil?
61
- "Invalid configuration for package `#{package.name}`. `#{identifier}` must be turned on to use `global_namespaces` configuration."
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
- # The reason for this is precondition is the `MultipleNamespacesProtection` assumes this to work properly.
67
- # To remove this precondition, we need to modify `MultipleNamespacesProtection` to be more generalized!
68
- is_root_package = package.name == ParsePackwerk::ROOT_PACKAGE_NAME
69
- in_allowed_directory = ::PackageProtections::EXPECTED_PACK_DIRECTORIES.any? do |expected_package_directory|
70
- package.directory.to_s.start_with?(expected_package_directory)
71
- end
72
- if in_allowed_directory || is_root_package
73
- nil
74
- else
75
- "Package #{package.name} must be located in one of #{::PackageProtections::EXPECTED_PACK_DIRECTORIES.join(', ')} (or be the root) to use this protection"
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.0.0
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-10-24 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport