rubocop-packs 0.0.16 → 0.0.17

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/rubocop/packs.rb +25 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82853530c4d01d7eb8f804f48eeb8b9558eb5d0fb006d5841c2c22f6265d5a38
4
- data.tar.gz: 55fdebf202b61a5c09b6f2e125fe2821c756f0c7aa7f4b03e383750992c62764
3
+ metadata.gz: 36151891d908f1db1ea404ec0890094a874ad30cd49bafe4ba6be84cc07f3234
4
+ data.tar.gz: d9cd4893c8bc730407e7cc777947a03b0f52290ea11c98d84f74cbafbbb23d41
5
5
  SHA512:
6
- metadata.gz: 350a4b8cff981e078f6c87e3fece33ba40c678be475f305702398033b3856817ac7eb60e98268f8f10e58b7098f05bb622f77089cca1d20ce64d1faba37db663
7
- data.tar.gz: bbc768b93c9f41cc886cdb8b1514d41cf8688a622ec4d6d4573eff06ef347eaf602751afc5ca6de663ff0564c33e263778b2eeae3933142b5831027518e8c776
6
+ metadata.gz: 9949c24590b6afe33471b75e71319ff6070e1b1040cb62652299f31af2fb9381603250e20e182b7ef0fdacd016e82282aea6c779e5ee242e17a23eac9a8e2459
7
+ data.tar.gz: ba7cf7c051c6f4e0306e8215e6e3d8cb33f9fb4095ce0634ddb79297a57cc9963323f74b1f69b88a74560f67dfe8342a27fde53d819b46e665a238c011bc6175
data/README.md CHANGED
@@ -52,9 +52,9 @@ To add a per-pack `.rubocop.yml`, you just need to create a `packs/your_pack/.ru
52
52
  inherit_from: '../../.rubocop.yml'
53
53
  ```
54
54
 
55
- Note though that inherited paths are relative to your pack-level `.rubocop.yml`. To avoid that, you can rename your `.rubocop.yml` to `.inherited_rubocop.yml`, set `.rubocop.yml` to:
55
+ Note though that inherited paths are relative to your pack-level `.rubocop.yml`. To avoid that, you can rename your `.rubocop.yml` to `.base_rubocop.yml`, set `.rubocop.yml` to:
56
56
  ```
57
- inherit_from: '.inherited_rubocop.yml'
57
+ inherit_from: '.base_rubocop.yml'
58
58
  ```
59
59
  And then similarly change the `inherit_from` in `packs/your_pack/.rubocop.yml`.
60
60
 
data/lib/rubocop/packs.rb CHANGED
@@ -64,6 +64,31 @@ module RuboCop
64
64
  end
65
65
  end
66
66
 
67
+ #
68
+ # Ideally, this is API that is available to us via `rubocop` itself.
69
+ # That is: the ability to preserve the location of `.rubocop_todo.yml` files and associate
70
+ # exclusions with the closest ancestor `.rubocop_todo.yml`
71
+ #
72
+ sig { params(packs: T::Array[ParsePackwerk::Package]).void }
73
+ def self.set_default_rubocop_yml(packs:)
74
+ packs.each do |pack|
75
+ rubocop_yml = Pathname.new(pack.directory.join('.rubocop.yml'))
76
+ rubocop_yml_hash = {}
77
+ rubocop_yml_hash['inherit_from'] = '../../.base_rubocop.yml'
78
+ config.required_pack_level_cops.each do |cop|
79
+ rubocop_yml_hash[cop] = { 'Enabled' => true }
80
+ end
81
+
82
+ formatted_yml = YAML.dump(rubocop_yml_hash).
83
+ # Remove the `---` header at the top of the file
84
+ gsub("---\n", '').
85
+ # Find lines of the form \nCopDepartment/CopName: and add a new line before it.
86
+ gsub(%r{^(\w+/\w+:)}, "\n\\1")
87
+
88
+ rubocop_yml.write(formatted_yml)
89
+ end
90
+ end
91
+
67
92
  sig { params(root_pathname: String).returns(String) }
68
93
  # It would be great if rubocop (upstream) could take in a glob for `inherit_from`, which
69
94
  # would allow us to delete this method and this additional complexity.
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.16
4
+ version: 0.0.17
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-08 00:00:00.000000000 Z
11
+ date: 2022-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport