rubocop-packs 0.0.14 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -28
- data/lib/rubocop/packs/private.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82853530c4d01d7eb8f804f48eeb8b9558eb5d0fb006d5841c2c22f6265d5a38
|
4
|
+
data.tar.gz: 55fdebf202b61a5c09b6f2e125fe2821c756f0c7aa7f4b03e383750992c62764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 350a4b8cff981e078f6c87e3fece33ba40c678be475f305702398033b3856817ac7eb60e98268f8f10e58b7098f05bb622f77089cca1d20ce64d1faba37db663
|
7
|
+
data.tar.gz: bbc768b93c9f41cc886cdb8b1514d41cf8688a622ec4d6d4573eff06ef347eaf602751afc5ca6de663ff0564c33e263778b2eeae3933142b5831027518e8c776
|
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/
|
39
|
+
Packs/NamespaceConvention:
|
61
40
|
Exclude:
|
62
41
|
- lib/example.rb
|
63
42
|
```
|
64
43
|
|
65
|
-
##
|
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
|
-
###
|
69
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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
|
|
@@ -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}.
|
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.
|
4
|
+
version: 0.0.16
|
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-
|
11
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|