rubocop-packs 0.0.15 → 0.0.17

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: 36726c94e4904ac2823f941a57fb7f5f725b28bb73fc2e837c7d75d41d55dfbe
4
- data.tar.gz: cc6d345f6e81eb66edfaefece8a2c9727d471bbd3b86164ded3baf20d3989378
3
+ metadata.gz: 36151891d908f1db1ea404ec0890094a874ad30cd49bafe4ba6be84cc07f3234
4
+ data.tar.gz: d9cd4893c8bc730407e7cc777947a03b0f52290ea11c98d84f74cbafbbb23d41
5
5
  SHA512:
6
- metadata.gz: 80d9e6eb7777118a44a813c88cdca22eb67281723e1dad9d995db9f7d557fde5cf48da9a4dd6596803a667c6622c714c93137e1bc7e2deae5d4d46c3a1f81849
7
- data.tar.gz: 31e23a78b39d7e776c398cfe55f89e78d3d58bc761a69d3d1abc1298120b109c939eef96ce0653ec0337a1f4d05dc40b40b636dde0bb25ce0916b036ada526c1
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
 
@@ -85,6 +85,8 @@ module RuboCop
85
85
  end
86
86
 
87
87
  loaded_rubocop_yml.each_key do |key|
88
+ next if key.to_s == 'inherit_from'
89
+
88
90
  if !Packs.config.permitted_pack_level_cops.include?(key)
89
91
  errors << <<~ERROR_MESSAGE
90
92
  #{rubocop_yml} contains invalid configuration for #{key}.
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.15
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-01 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