package_protections 3.0.0 → 3.2.0

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: 0c09fbdc359d1dc28d4168fc0041dc385ea8a5b78c77436c598d5f6fd3eb24d6
4
- data.tar.gz: 7ab7d9d30955c98c8213434b80923a96602a2489e2b822b9e8f75f3ff25145e8
3
+ metadata.gz: aabad25e536a226f791248e858e8db7fc67410b2d623879326165630bfd0922d
4
+ data.tar.gz: 64b1d4b5ab05315e9c5ecefdd3105af7485a6f2ed0ba59b9ae456c306b824d72
5
5
  SHA512:
6
- metadata.gz: 0027653c627faaacdc1e7dfe57342d10130b93cd833a5083091c54fbc48ba106366768671ce703cdf5c4576dcd53db10a39cc59f0262fc18b06153d00ddcc284
7
- data.tar.gz: 1494769fd3a1120add3da651cba6b0c826cc990890669810eb1532404ef1e2820470628bc89a77794589b819ed557da9cb3127910deebe2780854d560760ad9d
6
+ metadata.gz: 58aea344a1b283458d878b224c02fd339e27ca541f2ee025a65970ca94fc717ad5b95137e577760cb512fabf4c5657ccb15f8bc57f78330960294a47c2ad1898
7
+ data.tar.gz: 2700f4963e5fe0c5b987aede413458a7181ee8e471b9689bf0dcd0659bd535e99ffee83487ae88c1acfbcc245e8f62da91c070a77bcbea060a4a59bc00b21e19
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
  ```
@@ -10,36 +10,6 @@ module RuboCop
10
10
  extend T::Sig
11
11
  include ::PackageProtections::RubocopProtectionInterface
12
12
 
13
- # We override `cop_configs` for this protection.
14
- # The default behavior disables cops when a package has turned off a protection.
15
- # However: namespace violations can occur even when one package has TURNED OFF their namespace protection
16
- # but another package has it turned on. Therefore, all packages must always be opted in no matter what.
17
- #
18
- sig do
19
- params(packages: T::Array[::PackageProtections::ProtectedPackage])
20
- .returns(T::Array[::PackageProtections::RubocopProtectionInterface::CopConfig])
21
- end
22
- def cop_configs(packages)
23
- include_packs = T.let([], T::Array[String])
24
- packages.each do |p|
25
- enabled_for_pack = !p.violation_behavior_for(NamespacedUnderPackageName::IDENTIFIER).fail_never?
26
- if enabled_for_pack
27
- include_packs << p.name
28
- end
29
- end
30
-
31
- [
32
- ::PackageProtections::RubocopProtectionInterface::CopConfig.new(
33
- name: cop_name,
34
- enabled: include_packs.any?,
35
- metadata: {
36
- 'IncludePacks' => include_packs,
37
- 'GloballyPermittedNamespaces' => ::PackageProtections.config.globally_permitted_namespaces
38
- }
39
- )
40
- ]
41
- end
42
-
43
13
  sig { override.returns(T::Array[String]) }
44
14
  def included_globs_for_pack
45
15
  [
@@ -57,23 +27,19 @@ module RuboCop
57
27
 
58
28
  sig { override.params(behavior: ::PackageProtections::ViolationBehavior, package: ParsePackwerk::Package).returns(T.nilable(String)) }
59
29
  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?
30
+ # We don't need to validate if the behavior is currentely fail_never
31
+ return if behavior.fail_never?
65
32
 
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
33
+ # The reason for this is precondition is the `MultipleNamespacesProtection` assumes this to work properly.
34
+ # To remove this precondition, we need to modify `MultipleNamespacesProtection` to be more generalized!
35
+ is_root_package = package.name == ParsePackwerk::ROOT_PACKAGE_NAME
36
+ in_allowed_directory = ::PackageProtections::EXPECTED_PACK_DIRECTORIES.any? do |expected_package_directory|
37
+ package.directory.to_s.start_with?(expected_package_directory)
38
+ end
39
+ if in_allowed_directory || is_root_package
40
+ nil
41
+ else
42
+ "Package #{package.name} must be located in one of #{::PackageProtections::EXPECTED_PACK_DIRECTORIES.join(', ')} (or be the root) to use this protection"
77
43
  end
78
44
  end
79
45
 
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.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-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