rubocop-packs 0.0.14 → 0.0.15

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: be0363ed2023527b2c25a80a934abac48fd8e75c5c9b8f3882e0391305f2544c
4
- data.tar.gz: 3a082b0eb17b5bf25a2cbba0fbe01322b7d56598512102551c87635bbaea2df9
3
+ metadata.gz: 36726c94e4904ac2823f941a57fb7f5f725b28bb73fc2e837c7d75d41d55dfbe
4
+ data.tar.gz: cc6d345f6e81eb66edfaefece8a2c9727d471bbd3b86164ded3baf20d3989378
5
5
  SHA512:
6
- metadata.gz: 06a8046673579208dbe40a4f46b9cb11ff7360af8712736b794b0e66cfc9ec0411f9cdf837bf2acfd03c2f11cbeb82b6ff9291ca768824ffe2fc19f0d15d7e17
7
- data.tar.gz: 9debb88541b7c1e9506078c4de88ca6507d6f2b3fab95226269c70265a438c15533f1fae6dfc7a13b0707a93ec269093ec3fe0561a06047c83d05ed7e635fa18
6
+ metadata.gz: 80d9e6eb7777118a44a813c88cdca22eb67281723e1dad9d995db9f7d557fde5cf48da9a4dd6596803a667c6622c714c93137e1bc7e2deae5d4d46c3a1f81849
7
+ data.tar.gz: 31e23a78b39d7e776c398cfe55f89e78d3d58bc761a69d3d1abc1298120b109c939eef96ce0653ec0337a1f4d05dc40b40b636dde0bb25ce0916b036ada526c1
data/README.md CHANGED
@@ -23,59 +23,68 @@ You need to tell RuboCop to load the Packs extension. There are three ways to do
23
23
 
24
24
  Put this into your `.rubocop.yml`:
25
25
 
26
- ```yaml
27
- require: rubocop-packs
28
- ```
29
-
30
- Alternatively, use the following array notation when specifying multiple extensions:
31
-
32
26
  ```yaml
33
27
  require:
34
- - rubocop-other-extension
35
28
  - rubocop-packs
36
29
  ```
37
30
 
38
31
  Now you can run `rubocop` and it will automatically load the RuboCop Packs cops together with the standard cops.
39
32
 
40
- ### Command line
41
-
42
- ```sh
43
- rubocop --require rubocop-packs
44
- ```
45
-
46
- ### Rake task
47
-
48
- ```ruby
49
- RuboCop::RakeTask.new do |task|
50
- task.requires << 'rubocop-packs'
51
- end
52
- ```
53
-
54
33
  ## The Cops
55
34
  All cops are located under [`lib/rubocop/cop/packs`](lib/rubocop/cop/packs), and contain examples/documentation.
56
35
 
57
36
  In your `.rubocop.yml`, you may treat the Packs cops just like any other cop. For example:
58
37
 
59
38
  ```yaml
60
- Packs/NamespacedUnderPackageName:
39
+ Packs/NamespaceConvention:
61
40
  Exclude:
62
41
  - lib/example.rb
63
42
  ```
64
43
 
65
- ## Other Utilities
44
+ ## Pack-Level `.rubocop.yml` and `.rubocop_todo.yml` files
66
45
  `rubocop-packs` also has some API that help you use rubocop in a pack-based context.
67
46
 
68
- ### `RuboCop::Packs.auto_generate_rubocop_todo(packs: ParsePackwerk.all)`
69
- This API will auto-generate a `packs/some_pack/.rubocop_todo.yml`. This allows a pack to own its own exception list. Note that you need to configure `rubocop-packs` with an allow list of cops that can live in per-pack `.rubocop_todo.yml` files:
47
+ ### Per-pack `.rubocop.yml`
48
+ While `rubocop-packs` can be used like any other `rubocop` by configuring in your top-level `.rubocop.yml` file, we also have a number of tools to support per-pack configuration.
49
+
50
+ To add a per-pack `.rubocop.yml`, you just need to create a `packs/your_pack/.rubocop.yml` and then include:
51
+ ```yml
52
+ inherit_from: '../../.rubocop.yml'
53
+ ```
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:
56
+ ```
57
+ inherit_from: '.inherited_rubocop.yml'
58
+ ```
59
+ And then similarly change the `inherit_from` in `packs/your_pack/.rubocop.yml`.
60
+
61
+ ### Per-pack `.rubocop_todo.yml`
62
+ To create a per-pack `.rubocop_todo.yml`, you can use the following API from `rubocop-packs`:
63
+ ```ruby
64
+ RuboCop::Packs.auto_generate_rubocop_todo(packs: ParsePackwerk.all)
70
65
  ```
71
- # `config/rubocop_packs.rb`
66
+ This API will auto-generate a `packs/some_pack/.rubocop_todo.yml`. This allows a pack to own its own exception list.
67
+
68
+ ### Configuration and Validation
69
+ To use per-pack `.rubocop.yml` and `.rubocop_todo.yml` files, you need to configure `rubocop-packs`:
70
+ ```ruby
71
+ # config/rubocop_packs.rb
72
72
  RuboCop::Packs.configure do |config|
73
- # For example:
74
73
  config.permitted_pack_level_cops = ['Packs/NamespaceConvention']
74
+ config.required_pack_level_cops = ['Packs/NamespaceConvention']
75
+ end
76
+ ```
77
+
78
+ The above two settings have associated validations that run with `RuboCop::Packs.validate`, which returns an array of errors. We recommend validating this in your test suite, for example:
79
+ ```ruby
80
+ RSpec.describe 'rubocop-packs validations' do
81
+ it { expect(RuboCop::Packs.validate).to be_empty }
75
82
  end
76
83
  ```
77
84
 
78
- There is a supporting validation to ensure these `packs/*/.rubocop_todo.yml` files only add exceptions to the allow listed set of rules. Run this validation with `RuboCop::packs.validate`, which returns an array of errors.
85
+ Validations include:
86
+ - Ensuring that `packs/*/.rubocop_todo.yml` files only contain exceptions for the allow-list of `permitted_pack_level_cops`
87
+ - Ensuring that `packs/*/.rubocop.yml` files contain all of the cops listed in `required_pack_level_cops` and no other cops. This is to ensure that these files are only used to turn on and off an allow-list of cops, as most users would not want packs to configure most `rubocop` rules in a way that is different from the rest of the application.
79
88
 
80
89
  ## Contributing
81
90
 
@@ -20,7 +20,7 @@ module RuboCop
20
20
  return if @loaded_client_configuration
21
21
 
22
22
  @loaded_client_configuration = true
23
- client_configuration = Pathname.pwd.join('config/rubocop_packs.rb')
23
+ client_configuration = Bundler.root.join('config/rubocop_packs.rb')
24
24
  require client_configuration.to_s if client_configuration.exist?
25
25
  end
26
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-packs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers