rubocop-packs 0.0.34 → 0.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +0 -3
- data/lib/rubocop/packs/private.rb +2 -0
- data/lib/rubocop/packs.rb +3 -49
- metadata +2 -3
- data/config/pack_config.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d8ba7aa60a4c1be7d8958da1e4653ec7fc1c6435885ed66bbc5e7c47850043e
|
4
|
+
data.tar.gz: b7b3a20d9ddfeefc92464b8695d834b4a9fa740ff7683faab48fbe2ff2e437b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
data/lib/rubocop/packs.rb
CHANGED
@@ -7,17 +7,11 @@ module RuboCop
|
|
7
7
|
module Packs
|
8
8
|
extend T::Sig
|
9
9
|
|
10
|
-
|
11
|
-
|
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)
|
20
|
-
CONFIG = T.let(YAML.safe_load(CONFIG_DEFAULT.read).freeze, T.untyped)
|
21
15
|
|
22
16
|
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
23
17
|
|
@@ -59,7 +53,7 @@ module RuboCop
|
|
59
53
|
offenses_for_pack.group_by(&:filepath).each do |filepath, offenses_by_filepath|
|
60
54
|
offenses_by_filepath.map(&:cop_name).uniq.each do |cop_name|
|
61
55
|
rubocop_todo[cop_name] ||= { 'Exclude' => [] }
|
62
|
-
rubocop_todo[cop_name]['Exclude'] << filepath
|
56
|
+
rubocop_todo[cop_name]['Exclude'] << Pathname.new(filepath).relative_path_from(pack.relative_path).to_s
|
63
57
|
end
|
64
58
|
end
|
65
59
|
|
@@ -93,46 +87,6 @@ module RuboCop
|
|
93
87
|
end
|
94
88
|
end
|
95
89
|
|
96
|
-
sig { params(root_pathname: String).returns(String) }
|
97
|
-
# It would be great if rubocop (upstream) could take in a glob for `inherit_from`, which
|
98
|
-
# would allow us to delete this method and this additional complexity.
|
99
|
-
def self.pack_based_rubocop_config(root_pathname: Bundler.root)
|
100
|
-
rubocop_config = {}
|
101
|
-
# We do this because when the ERB is evaluated Dir.pwd is at the directory containing the YML.
|
102
|
-
# Ideally rubocop wouldn't change the PWD before invoking this method.
|
103
|
-
Dir.chdir(root_pathname) do
|
104
|
-
::Packs.all.each do |package|
|
105
|
-
rubocop_todo = package.relative_path.join(PACK_LEVEL_RUBOCOP_TODO_YML)
|
106
|
-
if rubocop_todo.exist?
|
107
|
-
loaded_rubocop_todo = YAML.load_file(rubocop_todo)
|
108
|
-
loaded_rubocop_todo.each do |cop_name, key_config|
|
109
|
-
rubocop_config[cop_name] ||= {}
|
110
|
-
rubocop_config[cop_name]['Exclude'] ||= []
|
111
|
-
rubocop_config[cop_name]['Exclude'] += key_config['Exclude']
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
pack_rubocop = package.relative_path.join(PACK_LEVEL_RUBOCOP_YML)
|
116
|
-
next unless pack_rubocop.exist?
|
117
|
-
|
118
|
-
loaded_pack_rubocop = YAML.load_file(pack_rubocop)
|
119
|
-
loaded_pack_rubocop.each do |cop_name, key_config|
|
120
|
-
rubocop_config[cop_name] ||= {}
|
121
|
-
|
122
|
-
if key_config['Enabled']
|
123
|
-
rubocop_config[cop_name]['Include'] ||= []
|
124
|
-
rubocop_config[cop_name]['Include'] << package.relative_path.join('**/*').to_s
|
125
|
-
else
|
126
|
-
rubocop_config[cop_name]['Exclude'] ||= []
|
127
|
-
rubocop_config[cop_name]['Exclude'] << package.relative_path.join('**/*').to_s
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
YAML.dump(rubocop_config)
|
134
|
-
end
|
135
|
-
|
136
90
|
sig { void }
|
137
91
|
def self.bust_cache!
|
138
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.
|
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-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -201,7 +201,6 @@ extra_rdoc_files: []
|
|
201
201
|
files:
|
202
202
|
- README.md
|
203
203
|
- config/default.yml
|
204
|
-
- config/pack_config.yml
|
205
204
|
- lib/rubocop-packs.rb
|
206
205
|
- lib/rubocop/cop/packs/class_methods_as_public_apis.rb
|
207
206
|
- lib/rubocop/cop/packs/documented_public_apis.rb
|
data/config/pack_config.yml
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
# Relevant documentation:
|
2
|
-
# - Inheriting config from a gem:
|
3
|
-
# - https://docs.rubocop.org/rubocop/configuration.html#inheriting-configuration-from-a-dependency-gem
|
4
|
-
# - ERB in a .rubocop.yml file
|
5
|
-
# - https://docs.rubocop.org/rubocop/configuration.html#pre-processing
|
6
|
-
<%= RuboCop::Packs.pack_based_rubocop_config %>
|