rubocop-packs 0.0.35 → 0.0.36

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: 70a81aaeac4498d122b9386a684f03850bf3493f16d8214d72d9b49a8e3d6b66
4
- data.tar.gz: 4a620b25ea514911cb80a74ff7b6c1afccc6d5145c3da11422bb3d1f97bdd8f8
3
+ metadata.gz: 0d8ba7aa60a4c1be7d8958da1e4653ec7fc1c6435885ed66bbc5e7c47850043e
4
+ data.tar.gz: b7b3a20d9ddfeefc92464b8695d834b4a9fa740ff7683faab48fbe2ff2e437b3
5
5
  SHA512:
6
- metadata.gz: 7b31d9f3dd7706aee30acd3bc13127bacc8fad829cf7216cc58fd48b5c2443ae4c582d13de8508f17304dfde885f58c01693c3d5b5861df4419fbd574889e2ab
7
- data.tar.gz: b696f3b449ddc0fa0300104fdc7fd9402a7c8a7db2d43d282b56a3aaa31d5c41569a0917e7e93d39188a88e068b1ae3cdd4bca45eac5a6feee1d542331cad211
6
+ metadata.gz: 53cc68843262c7688c051446ad996d4962e6e1ca0215b9d600d6633e2c8043f2daf6fe24b4315ce7979f01a824332fe25076d862818af5ea01853ed989ee7e45
7
+ data.tar.gz: '09a74c8fd5f4e14aa53a8376af093f9ce414b1689e6ac21a22dd3c894a967fbc5a5c8368a50e4e6ced576e8c014f8394e31365f039abc6df8e1ea676573d0e6d'
data/README.md CHANGED
@@ -41,7 +41,7 @@ Packs/RootNamespaceIsPackName:
41
41
  - lib/example.rb
42
42
  ```
43
43
 
44
- ## Pack-Level `package_rubocop.yml` and `package_rubocop_todo.yml` files
44
+ ## Pack-Level `.rubocop.yml` and `.rubocop_todo.yml` files
45
45
  See [ADVANCED_USAGE.md](ADVANCED_USAGE.md)
46
46
 
47
47
  ## Contributing
data/config/default.yml CHANGED
@@ -27,11 +27,3 @@ PackwerkLite/Privacy:
27
27
  PackwerkLite/Dependency:
28
28
  # It is recommended to use packwerk
29
29
  Enabled: false
30
-
31
- # We do this inherit *after* setting the defaults so that pack-specific rubocops can override the defaults
32
- # Relevant documentation:
33
- # - Inheriting config from a gem:
34
- # - https://docs.rubocop.org/rubocop/configuration.html#inheriting-configuration-from-a-dependency-gem
35
- # - ERB in a .rubocop.yml file
36
- # - https://docs.rubocop.org/rubocop/configuration.html#pre-processing
37
- <%= RuboCop::Packs.pack_based_rubocop_config %>
@@ -87,6 +87,8 @@ module RuboCop
87
87
  end
88
88
 
89
89
  loaded_rubocop_yml.each_key do |key|
90
+ next if key == 'inherit_from'
91
+
90
92
  if !Packs.config.permitted_pack_level_cops.include?(key)
91
93
  errors << <<~ERROR_MESSAGE
92
94
  #{rubocop_yml} contains invalid configuration for #{key}.
data/lib/rubocop/packs.rb CHANGED
@@ -7,13 +7,8 @@ module RuboCop
7
7
  module Packs
8
8
  extend T::Sig
9
9
 
10
- # Pack-level rubocop and rubocop_todo YML files are named differently because they are not integrated
11
- # into rubocop in the standard way. For example, we could call these the standard `.rubocop.yml` and
12
- # `.rubocop_todo.yml`. However, this introduces a number of path relativity issues (https://docs.rubocop.org/rubocop/configuration.html#path-relativity)
13
- # that make this approach not possible. Therefore, for pack level rubocops, we name them in a way that mirrors packwerk `package_todo.yml` files
14
- # for consistency and to ensure that thes are not read by rubocop except via the ERB templating mechanism.
15
- PACK_LEVEL_RUBOCOP_YML = 'package_rubocop.yml'
16
- PACK_LEVEL_RUBOCOP_TODO_YML = 'package_rubocop_todo.yml'
10
+ PACK_LEVEL_RUBOCOP_YML = '.rubocop.yml'
11
+ PACK_LEVEL_RUBOCOP_TODO_YML = '.rubocop_todo.yml'
17
12
 
18
13
  PROJECT_ROOT = T.let(Pathname.new(__dir__).parent.parent.expand_path.freeze, Pathname)
19
14
  CONFIG_DEFAULT = T.let(PROJECT_ROOT.join('config', 'default.yml').freeze, Pathname)
@@ -58,7 +53,7 @@ module RuboCop
58
53
  offenses_for_pack.group_by(&:filepath).each do |filepath, offenses_by_filepath|
59
54
  offenses_by_filepath.map(&:cop_name).uniq.each do |cop_name|
60
55
  rubocop_todo[cop_name] ||= { 'Exclude' => [] }
61
- rubocop_todo[cop_name]['Exclude'] << filepath
56
+ rubocop_todo[cop_name]['Exclude'] << Pathname.new(filepath).relative_path_from(pack.relative_path).to_s
62
57
  end
63
58
  end
64
59
 
@@ -92,46 +87,6 @@ module RuboCop
92
87
  end
93
88
  end
94
89
 
95
- sig { params(root_pathname: String).returns(String) }
96
- # It would be great if rubocop (upstream) could take in a glob for `inherit_from`, which
97
- # would allow us to delete this method and this additional complexity.
98
- def self.pack_based_rubocop_config(root_pathname: Bundler.root)
99
- rubocop_config = {}
100
- # We do this because when the ERB is evaluated Dir.pwd is at the directory containing the YML.
101
- # Ideally rubocop wouldn't change the PWD before invoking this method.
102
- Dir.chdir(root_pathname) do
103
- ::Packs.all.each do |package|
104
- rubocop_todo = package.relative_path.join(PACK_LEVEL_RUBOCOP_TODO_YML)
105
- if rubocop_todo.exist?
106
- loaded_rubocop_todo = YAML.load_file(rubocop_todo)
107
- loaded_rubocop_todo.each do |cop_name, key_config|
108
- rubocop_config[cop_name] ||= {}
109
- rubocop_config[cop_name]['Exclude'] ||= []
110
- rubocop_config[cop_name]['Exclude'] += key_config['Exclude']
111
- end
112
- end
113
-
114
- pack_rubocop = package.relative_path.join(PACK_LEVEL_RUBOCOP_YML)
115
- next unless pack_rubocop.exist?
116
-
117
- loaded_pack_rubocop = YAML.load_file(pack_rubocop)
118
- loaded_pack_rubocop.each do |cop_name, key_config|
119
- rubocop_config[cop_name] ||= {}
120
-
121
- if key_config['Enabled']
122
- rubocop_config[cop_name]['Include'] ||= []
123
- rubocop_config[cop_name]['Include'] << package.relative_path.join('**/*').to_s
124
- else
125
- rubocop_config[cop_name]['Exclude'] ||= []
126
- rubocop_config[cop_name]['Exclude'] << package.relative_path.join('**/*').to_s
127
- end
128
- end
129
- end
130
- end
131
-
132
- YAML.dump(rubocop_config)
133
- end
134
-
135
90
  sig { void }
136
91
  def self.bust_cache!
137
92
  config.bust_cache!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-packs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-17 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport