rubocop-packs 0.0.26 → 0.0.27
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.
- checksums.yaml +4 -4
- data/lib/rubocop/packs/private.rb +8 -16
- data/lib/rubocop/packs.rb +7 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25f6b7faaf75d2877d830e784211d96ba5d6cb29b442c959552e1de28c5adbd
|
4
|
+
data.tar.gz: eff6ee7fe761edb2bb142f4cf543557b4d17a160990dccc364972bd87208ccd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd2ffeb81ef84b49be4ae73216d3318f45d1bf9ad70bcc77061509bbae0f848a1ff0a87ba12082c6091f32b00fef0a1a303d360dba7d07a8c2de60e255186888
|
7
|
+
data.tar.gz: 52163c30ba8037b43c0aaa1659bf42723e4dcd0b570b5b6e7d0f2e72e526a2e3fab6456ed3c9e934bad894b3aed9b9e3103b908dbe9d012be2081c5d42312022
|
@@ -148,20 +148,22 @@ module RuboCop
|
|
148
148
|
errors
|
149
149
|
end
|
150
150
|
|
151
|
-
sig { params(args: T.untyped).
|
151
|
+
sig { params(args: T.untyped).void }
|
152
152
|
def self.execute_rubocop(args)
|
153
|
-
|
154
|
-
RuboCop::CLI.new.run(args)
|
155
|
-
end
|
153
|
+
RuboCop::CLI.new.run(args)
|
156
154
|
end
|
157
155
|
|
158
156
|
sig { params(paths: T::Array[String], cop_names: T::Array[String]).returns(T::Array[Offense]) }
|
159
157
|
def self.offenses_for(paths:, cop_names:)
|
160
158
|
cop_arguments = cop_names.join(',')
|
161
159
|
# I think we can potentially use `RuboCop::CLI.new(args)` for this to avoid shelling out and starting another process that needs to reload the bundle
|
162
|
-
args = [*paths, "--only=#{cop_arguments}", '--format=json']
|
160
|
+
args = [*paths, "--only=#{cop_arguments}", '--format=json', '--out=tmp/rubocop-output']
|
161
|
+
FileUtils.mkdir_p('tmp')
|
163
162
|
puts "Executing: bundle exec rubocop #{args.join(' ')}"
|
164
|
-
|
163
|
+
Private.execute_rubocop(args)
|
164
|
+
output = Pathname.new('tmp/rubocop-output')
|
165
|
+
json = JSON.parse(Pathname.new('tmp/rubocop-output').read)
|
166
|
+
output.delete
|
165
167
|
offenses = T.let([], T::Array[Offense])
|
166
168
|
json['files'].each do |file_hash|
|
167
169
|
filepath = file_hash['path']
|
@@ -175,16 +177,6 @@ module RuboCop
|
|
175
177
|
|
176
178
|
offenses
|
177
179
|
end
|
178
|
-
|
179
|
-
sig { params(block: T.untyped).returns(String) }
|
180
|
-
def self.with_captured_stdout(&block)
|
181
|
-
original_stdout = $stdout # capture previous value of $stdout
|
182
|
-
$stdout = StringIO.new # assign a string buffer to $stdout
|
183
|
-
yield # perform the body of the user code
|
184
|
-
$stdout.string # return the contents of the string buffer
|
185
|
-
ensure
|
186
|
-
$stdout = original_stdout # restore $stdout to its previous value
|
187
|
-
end
|
188
180
|
end
|
189
181
|
|
190
182
|
private_constant :Private
|
data/lib/rubocop/packs.rb
CHANGED
@@ -28,6 +28,12 @@ module RuboCop
|
|
28
28
|
#
|
29
29
|
sig { params(packs: T::Array[ParsePackwerk::Package], files: T::Array[String]).void }
|
30
30
|
def self.regenerate_todo(packs: [], files: [])
|
31
|
+
# Delete the old pack-level rubocop todo files so that we can regenerate the new one from scratch
|
32
|
+
packs.each do |pack|
|
33
|
+
rubocop_todo_yml = pack.directory.join(PACK_LEVEL_RUBOCOP_TODO_YML)
|
34
|
+
rubocop_todo_yml.delete if rubocop_todo_yml.exist?
|
35
|
+
end
|
36
|
+
|
31
37
|
paths = packs.empty? ? files : packs.map(&:name).reject { |name| name == ParsePackwerk::ROOT_PACKAGE_NAME }
|
32
38
|
offenses = Private.offenses_for(
|
33
39
|
paths: paths,
|
@@ -39,11 +45,7 @@ module RuboCop
|
|
39
45
|
next if !pack.directory.join(PACK_LEVEL_RUBOCOP_YML).exist?
|
40
46
|
|
41
47
|
rubocop_todo_yml = pack.directory.join(PACK_LEVEL_RUBOCOP_TODO_YML)
|
42
|
-
|
43
|
-
if packs.any? && rubocop_todo_yml.exist?
|
44
|
-
rubocop_todo_yml.delete
|
45
|
-
rubocop_todo = {}
|
46
|
-
elsif rubocop_todo_yml.exist?
|
48
|
+
if rubocop_todo_yml.exist?
|
47
49
|
rubocop_todo = YAML.load_file(rubocop_todo_yml)
|
48
50
|
else
|
49
51
|
rubocop_todo = {}
|