rubocop-packs 0.0.25 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/packs/private.rb +8 -17
- 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,21 +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
|
-
path_arguments = paths.join(' ')
|
161
158
|
cop_arguments = cop_names.join(',')
|
162
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
|
163
|
-
args = [
|
160
|
+
args = [*paths, "--only=#{cop_arguments}", '--format=json', '--out=tmp/rubocop-output']
|
161
|
+
FileUtils.mkdir_p('tmp')
|
164
162
|
puts "Executing: bundle exec rubocop #{args.join(' ')}"
|
165
|
-
|
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
|
166
167
|
offenses = T.let([], T::Array[Offense])
|
167
168
|
json['files'].each do |file_hash|
|
168
169
|
filepath = file_hash['path']
|
@@ -176,16 +177,6 @@ module RuboCop
|
|
176
177
|
|
177
178
|
offenses
|
178
179
|
end
|
179
|
-
|
180
|
-
sig { params(block: T.untyped).returns(String) }
|
181
|
-
def self.with_captured_stdout(&block)
|
182
|
-
original_stdout = $stdout # capture previous value of $stdout
|
183
|
-
$stdout = StringIO.new # assign a string buffer to $stdout
|
184
|
-
yield # perform the body of the user code
|
185
|
-
$stdout.string # return the contents of the string buffer
|
186
|
-
ensure
|
187
|
-
$stdout = original_stdout # restore $stdout to its previous value
|
188
|
-
end
|
189
180
|
end
|
190
181
|
|
191
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 = {}
|