rubocop-packs 0.0.26 → 0.0.27

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: b087fdd5a5ae2a9a51a04d24966313c19a2892153d656beac60bdb15e959726e
4
- data.tar.gz: e4ff803bc9a2a37dd68867da260df1f68c7d8adc666a9cb141dcc95a6ac1e448
3
+ metadata.gz: e25f6b7faaf75d2877d830e784211d96ba5d6cb29b442c959552e1de28c5adbd
4
+ data.tar.gz: eff6ee7fe761edb2bb142f4cf543557b4d17a160990dccc364972bd87208ccd8
5
5
  SHA512:
6
- metadata.gz: 234d22b504eb15892fd02bdab4783e475ab12ec0b6024f5d36519aca0efc1feaa5ac8616f8ba8f242086e5ac100d76edd282c282045136df26b5035954f6306d
7
- data.tar.gz: 56056baf7a26ab3c2bc21038de1f34e418d01d2f0851fe1eb1234d7ec63e069a930505cf8e858fe6ac913ba5556b8ec230a024efbd7e97b0743756f3fac90c3f
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).returns(String) }
151
+ sig { params(args: T.untyped).void }
152
152
  def self.execute_rubocop(args)
153
- with_captured_stdout do
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
- json = JSON.parse(Private.execute_rubocop(args))
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
- # If the user is passing in packs, then regenerate from scratch.
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 = {}
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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers