brakeman 5.1.1 → 5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +9 -1
  3. data/README.md +1 -1
  4. data/bundle/load.rb +5 -5
  5. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
  6. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
  7. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
  8. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
  9. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
  10. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
  11. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
  12. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
  13. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
  14. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
  15. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
  17. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
  18. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
  19. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
  20. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
  21. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
  22. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
  23. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
  24. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
  25. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
  26. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
  27. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
  28. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
  29. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
  30. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
  31. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
  32. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
  33. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
  34. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
  35. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
  37. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
  39. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
  41. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
  42. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
  43. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
  44. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
  45. data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/MIT-LICENSE.txt +0 -0
  46. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
  47. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
  48. data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/lib/parallel.rb +52 -43
  49. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/History.rdoc +76 -0
  50. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/Manifest.txt +3 -0
  51. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/README.rdoc +1 -0
  52. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/compare/normalize.rb +6 -1
  53. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/debugging.md +0 -0
  54. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/gauntlet.md +106 -0
  55. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/rp_extensions.rb +15 -36
  56. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/rp_stringscanner.rb +33 -0
  57. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby20_parser.rb +7122 -0
  58. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby20_parser.y +326 -249
  59. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby21_parser.rb +7176 -0
  60. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby21_parser.y +321 -246
  61. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby22_parser.rb +7222 -0
  62. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby22_parser.y +325 -248
  63. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby23_parser.rb +7231 -0
  64. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby24_parser.y → ruby_parser-3.18.0/lib/ruby23_parser.y} +326 -257
  65. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby24_parser.rb +7262 -0
  66. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.0/lib/ruby24_parser.y} +327 -302
  67. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby25_parser.rb +7262 -0
  68. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.0/lib/ruby25_parser.y} +326 -264
  69. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby26_parser.rb +7281 -0
  70. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.0/lib/ruby26_parser.y} +325 -285
  71. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby27_parser.rb +8511 -0
  72. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.0/lib/ruby27_parser.y} +897 -377
  73. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby30_parser.rb +8741 -0
  74. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby30_parser.y +3463 -0
  75. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby3_parser.yy +3467 -0
  76. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rb +261 -609
  77. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rex +27 -20
  78. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rex.rb +59 -23
  79. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby_lexer_strings.rb +638 -0
  80. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_parser.rb +0 -0
  81. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby_parser.yy +3481 -0
  82. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_parser_extras.rb +296 -115
  83. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/tools/munge.rb +34 -6
  84. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/tools/ripper.rb +44 -0
  85. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
  86. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
  87. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
  88. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
  89. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
  90. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
  91. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
  92. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
  93. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
  94. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
  95. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
  96. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
  97. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
  98. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  99. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
  100. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
  101. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  102. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
  103. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
  104. data/lib/brakeman/app_tree.rb +1 -1
  105. data/lib/brakeman/checks/check_json_parsing.rb +1 -1
  106. data/lib/brakeman/processors/alias_processor.rb +7 -1
  107. data/lib/brakeman/processors/haml_template_processor.rb +9 -0
  108. data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
  109. data/lib/brakeman/processors/model_processor.rb +1 -0
  110. data/lib/brakeman/report/ignore/config.rb +1 -1
  111. data/lib/brakeman/report/report_csv.rb +1 -1
  112. data/lib/brakeman/report/report_sarif.rb +1 -1
  113. data/lib/brakeman/report/report_text.rb +1 -1
  114. data/lib/brakeman/scanner.rb +12 -12
  115. data/lib/brakeman/version.rb +1 -1
  116. data/lib/brakeman.rb +2 -2
  117. data/lib/ruby_parser/bm_sexp.rb +11 -1
  118. metadata +101 -98
  119. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
  120. data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
  121. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
  122. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
  123. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
  124. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
  125. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
  126. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
  127. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
  128. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
  129. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
  130. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
  131. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
  132. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
  133. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
  134. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rbconfig'
2
3
  require 'parallel/version'
3
4
  require 'parallel/processor_count'
@@ -12,7 +13,9 @@ module Parallel
12
13
 
13
14
  class Break < StandardError
14
15
  attr_reader :value
16
+
15
17
  def initialize(value = nil)
18
+ super()
16
19
  @value = value
17
20
  end
18
21
  end
@@ -22,6 +25,7 @@ module Parallel
22
25
 
23
26
  class UndumpableException < StandardError
24
27
  attr_reader :backtrace
28
+
25
29
  def initialize(original)
26
30
  super "#{original.class}: #{original.message}"
27
31
  @backtrace = original.backtrace
@@ -30,6 +34,7 @@ module Parallel
30
34
 
31
35
  class ExceptionWrapper
32
36
  attr_reader :exception
37
+
33
38
  def initialize(exception)
34
39
  # Remove the bindings stack added by the better_errors gem,
35
40
  # because it cannot be marshalled
@@ -40,7 +45,7 @@ module Parallel
40
45
  @exception =
41
46
  begin
42
47
  Marshal.dump(exception) && exception
43
- rescue
48
+ rescue StandardError
44
49
  UndumpableException.new(exception)
45
50
  end
46
51
  end
@@ -49,8 +54,11 @@ module Parallel
49
54
  class Worker
50
55
  attr_reader :pid, :read, :write
51
56
  attr_accessor :thread
57
+
52
58
  def initialize(read, write, pid)
53
- @read, @write, @pid = read, write, pid
59
+ @read = read
60
+ @write = write
61
+ @pid = pid
54
62
  end
55
63
 
56
64
  def stop
@@ -77,7 +85,7 @@ module Parallel
77
85
  rescue EOFError
78
86
  raise DeadWorker
79
87
  end
80
- raise result.exception if ExceptionWrapper === result
88
+ raise result.exception if result.is_a?(ExceptionWrapper)
81
89
  result
82
90
  end
83
91
 
@@ -144,7 +152,7 @@ module Parallel
144
152
  end
145
153
 
146
154
  def queue_wrapper(array)
147
- array.respond_to?(:num_waiting) && array.respond_to?(:pop) && lambda { array.pop(false) }
155
+ array.respond_to?(:num_waiting) && array.respond_to?(:pop) && -> { array.pop(false) }
148
156
  end
149
157
  end
150
158
 
@@ -160,7 +168,7 @@ module Parallel
160
168
 
161
169
  if @to_be_killed.empty?
162
170
  old_interrupt = trap_interrupt(signal) do
163
- $stderr.puts 'Parallel execution interrupted, exiting ...'
171
+ warn 'Parallel execution interrupted, exiting ...'
164
172
  @to_be_killed.flatten.each { |pid| kill(pid) }
165
173
  end
166
174
  end
@@ -204,32 +212,30 @@ module Parallel
204
212
  end
205
213
 
206
214
  class << self
207
- def in_threads(options={:count => 2})
215
+ def in_threads(options = { count: 2 })
208
216
  threads = []
209
- count, _ = extract_count_from_options(options)
217
+ count, = extract_count_from_options(options)
210
218
 
211
219
  Thread.handle_interrupt(Exception => :never) do
212
- begin
213
- Thread.handle_interrupt(Exception => :immediate) do
214
- count.times do |i|
215
- threads << Thread.new { yield(i) }
216
- end
217
- threads.map(&:value)
220
+ Thread.handle_interrupt(Exception => :immediate) do
221
+ count.times do |i|
222
+ threads << Thread.new { yield(i) }
218
223
  end
219
- ensure
220
- threads.each(&:kill)
224
+ threads.map(&:value)
221
225
  end
226
+ ensure
227
+ threads.each(&:kill)
222
228
  end
223
229
  end
224
230
 
225
231
  def in_processes(options = {}, &block)
226
232
  count, options = extract_count_from_options(options)
227
233
  count ||= processor_count
228
- map(0...count, options.merge(:in_processes => count), &block)
234
+ map(0...count, options.merge(in_processes: count), &block)
229
235
  end
230
236
 
231
- def each(array, options={}, &block)
232
- map(array, options.merge(:preserve_results => false), &block)
237
+ def each(array, options = {}, &block)
238
+ map(array, options.merge(preserve_results: false), &block)
233
239
  end
234
240
 
235
241
  def any?(*args, &block)
@@ -242,8 +248,8 @@ module Parallel
242
248
  !!each(*args) { |*a| raise Kill unless block.call(*a) }
243
249
  end
244
250
 
245
- def each_with_index(array, options={}, &block)
246
- each(array, options.merge(:with_index => true), &block)
251
+ def each_with_index(array, options = {}, &block)
252
+ each(array, options.merge(with_index: true), &block)
247
253
  end
248
254
 
249
255
  def map(source, options = {}, &block)
@@ -251,8 +257,8 @@ module Parallel
251
257
  options[:mutex] = Mutex.new
252
258
 
253
259
  if options[:in_processes] && options[:in_threads]
254
- raise ArgumentError.new("Please specify only one of `in_processes` or `in_threads`.")
255
- elsif RUBY_PLATFORM =~ /java/ and not options[:in_processes]
260
+ raise ArgumentError, "Please specify only one of `in_processes` or `in_threads`."
261
+ elsif RUBY_PLATFORM =~ (/java/) && !(options[:in_processes])
256
262
  method = :in_threads
257
263
  size = options[method] || processor_count
258
264
  elsif options[:in_threads]
@@ -278,9 +284,9 @@ module Parallel
278
284
  if size == 0
279
285
  work_direct(job_factory, options, &block)
280
286
  elsif method == :in_threads
281
- work_in_threads(job_factory, options.merge(:count => size), &block)
287
+ work_in_threads(job_factory, options.merge(count: size), &block)
282
288
  else
283
- work_in_processes(job_factory, options.merge(:count => size), &block)
289
+ work_in_processes(job_factory, options.merge(count: size), &block)
284
290
  end
285
291
 
286
292
  return result.value if result.is_a?(Break)
@@ -288,8 +294,8 @@ module Parallel
288
294
  options[:return_results] ? result : source
289
295
  end
290
296
 
291
- def map_with_index(array, options={}, &block)
292
- map(array, options.merge(:with_index => true), &block)
297
+ def map_with_index(array, options = {}, &block)
298
+ map(array, options.merge(with_index: true), &block)
293
299
  end
294
300
 
295
301
  def flat_map(*args, &block)
@@ -343,7 +349,7 @@ module Parallel
343
349
  call_with_index(item, index, options, &block)
344
350
  end
345
351
  end
346
- rescue
352
+ rescue StandardError
347
353
  exception = $!
348
354
  end
349
355
  exception || results
@@ -367,7 +373,7 @@ module Parallel
367
373
  call_with_index(item, index, options, &block)
368
374
  end
369
375
  results_mutex.synchronize { results[index] = result }
370
- rescue
376
+ rescue StandardError
371
377
  exception = $!
372
378
  end
373
379
  end
@@ -407,9 +413,9 @@ module Parallel
407
413
  results_mutex.synchronize { results[index] = result } # arrays are not threads safe on jRuby
408
414
  rescue StandardError => e
409
415
  exception = e
410
- if Kill === exception
416
+ if exception.is_a?(Kill)
411
417
  (workers - [worker]).each do |w|
412
- w.thread.kill if w.thread
418
+ w.thread&.kill
413
419
  UserInterruptHandler.kill(w.pid)
414
420
  end
415
421
  end
@@ -423,15 +429,15 @@ module Parallel
423
429
  exception || results
424
430
  end
425
431
 
426
- def replace_worker(job_factory, workers, i, options, blk)
432
+ def replace_worker(job_factory, workers, index, options, blk)
427
433
  options[:mutex].synchronize do
428
434
  # old worker is no longer used ... stop it
429
- worker = workers[i]
435
+ worker = workers[index]
430
436
  worker.stop
431
437
 
432
438
  # create a new replacement worker
433
439
  running = workers - [worker]
434
- workers[i] = worker(job_factory, options.merge(started_workers: running, worker_number: i), &blk)
440
+ workers[index] = worker(job_factory, options.merge(started_workers: running, worker_number: index), &blk)
435
441
  end
436
442
  end
437
443
 
@@ -473,14 +479,17 @@ module Parallel
473
479
  until read.eof?
474
480
  data = Marshal.load(read)
475
481
  item, index = job_factory.unpack(data)
476
- result = begin
477
- call_with_index(item, index, options, &block)
478
- # https://github.com/rspec/rspec-support/blob/673133cdd13b17077b3d88ece8d7380821f8d7dc/lib/rspec/support.rb#L132-L140
479
- rescue NoMemoryError, SignalException, Interrupt, SystemExit
480
- raise $!
481
- rescue Exception
482
- ExceptionWrapper.new($!)
483
- end
482
+
483
+ result =
484
+ begin
485
+ call_with_index(item, index, options, &block)
486
+ # https://github.com/rspec/rspec-support/blob/673133cdd13b17077b3d88ece8d7380821f8d7dc/lib/rspec/support.rb#L132-L140
487
+ rescue NoMemoryError, SignalException, Interrupt, SystemExit # rubocop:disable Lint/ShadowedException
488
+ raise $!
489
+ rescue Exception # # rubocop:disable Lint/RescueException
490
+ ExceptionWrapper.new($!)
491
+ end
492
+
484
493
  begin
485
494
  Marshal.dump(result, write)
486
495
  rescue Errno::EPIPE
@@ -503,10 +512,10 @@ module Parallel
503
512
  def call_with_index(item, index, options, &block)
504
513
  args = [item]
505
514
  args << index if options[:with_index]
515
+ results = block.call(*args)
506
516
  if options[:return_results]
507
- block.call(*args)
517
+ results
508
518
  else
509
- block.call(*args)
510
519
  nil # avoid GC overhead of passing large results around
511
520
  end
512
521
  end
@@ -1,3 +1,79 @@
1
+ === 3.18.0 / 2021-10-27
2
+
3
+ Holy crap... 58 commits! 2.7 and 3.0 are feature complete. Strings
4
+ & heredocs have been rewritten.
5
+
6
+ * 9 major enhancements:
7
+
8
+ * !!! Rewrote lexer (and friends) for strings, heredocs, and %*[] constructs.
9
+ * Massive overhaul on line numbers.
10
+ * Freeze input! Finally!!! No more modifying the input string for heredocs.
11
+ * Overhauled RPStringScanner. Removed OLD compatibility methods!
12
+ * Removed Sexp methods: value, to_sym, add, add_all, node_type, values.
13
+ * value moved to sexp_processor.
14
+ * Removed String#grep monkey-patch.
15
+ * Removed String#lineno monkey-patch.
16
+ * Removed string_to_pos, charpos, etc hacks for ancient ruby versions.
17
+ * Removed unread_many... NO! NO EDITING THE INPUT STRING!
18
+
19
+ * 31 minor enhancements:
20
+
21
+ * 2.7/3.0: many more pattern edge cases
22
+ * 2.7: Added `mlhs = rhs rescue expr`
23
+ * 2.7: refactored destructured args (`|(k,v)|`) and unfactored(?!) case_body/args.
24
+ * 3.0: excessed_comma
25
+ * 3.0: finished most everything: endless methods, patterns, etc.
26
+ * 3.0: refactored / added new pattern changes
27
+ * Added RubyLexer#in_heredoc? (ie, is there old_ss ?)
28
+ * Added RubyLexer#old_ss and old_lineno and removed much of SSStack(ish).
29
+ * Added Symbol#end_with? when necessary
30
+ * Added TALLY and DEBUG options for ss.getch and ss.scan
31
+ * Added ignore_body_comments to make parser productions more clear.
32
+ * Added support for no_kwarg (eg `def f(**nil)`).
33
+ * Added support for no_kwarg in blocks (eg `f { |**nil| }`).
34
+ * Augmented generated parser files to have frozen_string_literal comments and fixed tests.
35
+ * Broke out 3.0 parser into its own to ease development.
36
+ * Bumped dependencies on sexp_processor and oedipus_lex.
37
+ * Clean generated 3.x files.
38
+ * Extracted all string scanner methods to their own module.
39
+ * Fixed some precedence decls.
40
+ * Implemented most of pattern matching for 2.7+.
41
+ * Improve lex_state= to report location in verbose debug mode.
42
+ * Made it easier to debug with a particular version of ruby via rake.
43
+ * Make sure ripper uses the same version of ruby we specified.
44
+ * Moved all string/heredoc/etc code to ruby_lexer_strings.rb
45
+ * Remove warning from newer bisons.
46
+ * Sprinkled in some frozen_string_literal, but mostly helped by oedipus bump.
47
+ * Switch to comparing against ruby binary since ripper is buggy.
48
+ * bugs task should try both bug*.rb and bad*.rb.
49
+ * endless methods
50
+ * f_any_kwrest refactoring.
51
+ * refactored defn/defs
52
+
53
+ * 15 bug fixes:
54
+
55
+ * Cleaned a bunch of old hacks. Initializing RubyLexer w/ Parser is cleaner now.
56
+ * Corrected some lex_state errors in process_token_keyword.
57
+ * Fixed ancient ruby2 change (use #lines) in ruby_parse_extract_error.
58
+ * Fixed bug where else without rescue only raises on 2.6+
59
+ * Fixed caller for getch and scan when DEBUG=1
60
+ * Fixed comments in the middle of message cascades.
61
+ * Fixed differences w/ symbol productions against ruby 2.7.
62
+ * Fixed dsym to use string_contents production.
63
+ * Fixed error in bdot2/3 in some edge cases. Fixed p_alt line.
64
+ * Fixed heredoc dedenting in the presence of empty lines. (mvz)
65
+ * Fixed some leading whitespace / comment processing
66
+ * Fixed up how class/module/defn/defs comments were collected.
67
+ * Overhauled ripper.rb to deal with buggy ripper w/ yydebug.
68
+ * Removed dsym from literal.
69
+ * Removed tUBANG lexeme but kept it distinct as a method name (eg: `def !@`).
70
+
71
+ === 3.17.0 / 2021-08-03
72
+
73
+ * 1 minor enhancement:
74
+
75
+ * Added support for arg forwarding (eg `def f(...); m(...); end`) (presidentbeef)
76
+
1
77
  === 3.16.0 / 2021-05-15
2
78
 
3
79
  * 1 major enhancement:
@@ -7,6 +7,7 @@ bin/ruby_parse
7
7
  bin/ruby_parse_extract_error
8
8
  compare/normalize.rb
9
9
  debugging.md
10
+ gauntlet.md
10
11
  lib/.document
11
12
  lib/rp_extensions.rb
12
13
  lib/rp_stringscanner.rb
@@ -28,9 +29,11 @@ lib/ruby27_parser.rb
28
29
  lib/ruby27_parser.y
29
30
  lib/ruby30_parser.rb
30
31
  lib/ruby30_parser.y
32
+ lib/ruby3_parser.yy
31
33
  lib/ruby_lexer.rb
32
34
  lib/ruby_lexer.rex
33
35
  lib/ruby_lexer.rex.rb
36
+ lib/ruby_lexer_strings.rb
34
37
  lib/ruby_parser.rb
35
38
  lib/ruby_parser.yy
36
39
  lib/ruby_parser_extras.rb
@@ -32,6 +32,7 @@ Tested against 801,039 files from the latest of all rubygems (as of 2013-05):
32
32
  * 1.8 parser is at 99.9739% accuracy, 3.651 sigma
33
33
  * 1.9 parser is at 99.9940% accuracy, 4.013 sigma
34
34
  * 2.0 parser is at 99.9939% accuracy, 4.008 sigma
35
+ * 2.6 parser is at 99.9972% accuracy, 4.191 sigma
35
36
 
36
37
  == FEATURES/PROBLEMS:
37
38
 
@@ -84,6 +84,7 @@ def munge s
84
84
 
85
85
  "' '", "tSPACE", # needs to be later to avoid bad hits
86
86
 
87
+ "%empty", "none", # newer bison
87
88
  "/* empty */", "none",
88
89
  /^\s*$/, "none",
89
90
 
@@ -140,6 +141,7 @@ def munge s
140
141
  '"do for block"', "kDO_BLOCK",
141
142
  '"do for condition"', "kDO_COND",
142
143
  '"do for lambda"', "kDO_LAMBDA",
144
+ "tLABEL", "kLABEL",
143
145
 
144
146
  # UGH
145
147
  "k_LINE__", "k__LINE__",
@@ -155,7 +157,10 @@ def munge s
155
157
  /\"(\w+) \(?modifier\)?\"/, proc { |x| "k#{$1.upcase}_MOD" },
156
158
  /\"(\w+)\"/, proc { |x| "k#{$1.upcase}" },
157
159
 
158
- /@(\d+)(\s+|$)/, "",
160
+ /\$?@(\d+)(\s+|$)/, "", # newer bison
161
+
162
+ # TODO: remove for 3.0 work:
163
+ "lex_ctxt ", "" # 3.0 production that's mostly noise right now
159
164
  ]
160
165
 
161
166
  renames.each_slice(2) do |(a, b)|
@@ -0,0 +1,106 @@
1
+ # Running the Gauntlet
2
+
3
+ ## Maintaining a Gem Mirror
4
+
5
+ I use rubygems-mirror to keep an archive of all the latest rubygems on
6
+ an external disk. Here is the config:
7
+
8
+ ```
9
+ ---
10
+ - from: https://rubygems.org
11
+ to: /Volumes/StuffA/gauntlet/mirror
12
+ parallelism: 10
13
+ retries: 3
14
+ delete: true
15
+ skiperror: true
16
+ hashdir: true
17
+ ```
18
+
19
+ And I update using rake:
20
+
21
+ ```
22
+ % cd ~/Work/git/rubygems/rubygems-mirror
23
+ % git down
24
+ % rake mirror:latest
25
+ % /Volumes/StuffA/gauntlet/bin/cleanup.rb
26
+ ```
27
+
28
+ This rather quickly updates my mirror to the latest versions of
29
+ everything and then deletes all old versions. I then run a cleanup
30
+ script that fixes the file dates to their publication date and deletes
31
+ any gems that have invalid specs. This can argue with the mirror a
32
+ bit, but it is pretty minimal (currently ~20 bad gems).
33
+
34
+ ## Curating an Archive of Ruby Files
35
+
36
+ Next, I process the gem mirror into a much more digestable structure
37
+ using `hash.rb` (TODO: needs a better name):
38
+
39
+ ```
40
+ % cd RP
41
+ % /Volumes/StuffA/gauntlet/bin/unpack_gems.rb
42
+ ... waaaait ...
43
+ % mv hashed.noindex gauntlet.$(today).noindex
44
+ % lrztar gauntlet.$(today).noindex
45
+ % mv gauntlet.$(today).noindex.lrz /Volumes/StuffA/gauntlet/
46
+ ```
47
+
48
+ This script filters all the newer gems (TODO: WHY?), unpacks them,
49
+ finds all the files that look like they're valid ruby, ensures they're
50
+ valid ruby (using the current version of ruby to compile them), and
51
+ then moves them into a SHA dir structure that looks something like
52
+ this:
53
+
54
+ ```
55
+ hashed.noindex/a/b/c/<full_file_sha>.rb
56
+ ```
57
+
58
+ This removes all duplicates and puts everything in a fairly even,
59
+ wide, flat directory layout.
60
+
61
+ This process takes a very long time, even with a lot of
62
+ parallelization. There are currently about 160k gems in the mirror.
63
+ Unpacking, validating, SHA'ing everything is disk and CPU intensive.
64
+ The `.noindex` extension stops spotlight from indexing the continous
65
+ churn of files being unpacked and moved and saves time.
66
+
67
+ Finally, I rename and archive it all up (currently using lrztar, but
68
+ I'm not in love with it).
69
+
70
+ ### Stats
71
+
72
+ ```
73
+ 9696 % find gauntlet.$(today).noindex -type f | lc
74
+ 561270
75
+ 3.5G gauntlet.2021-08-06.noindex
76
+ 239M gauntlet.2021-08-06.noindex.tar.lrz
77
+ ```
78
+
79
+ So I wind up with a little over half a million unique ruby files to
80
+ parse. It's about 3.5g but compresses very nicely down to 240m
81
+
82
+ ## Running the Gauntlet
83
+
84
+ Assuming you're starting from scratch, unpack the archive once:
85
+
86
+ ```
87
+ % lrzuntar gauntlet.$(today).noindex.lrz
88
+ ```
89
+
90
+ Then, either run a single process (easier to read):
91
+
92
+ ```
93
+ % ./gauntlet/bin/gauntlet.rb gauntlet/*.noindex/?
94
+ ```
95
+
96
+ Or max out your machine using xargs (note the `-P 16` and choose accordingly):
97
+
98
+ ```
99
+ % ls -d gauntlet/*.noindex/?/? | xargs -n 1 -P 16 ./gauntlet/bin/gauntlet.rb
100
+ ```
101
+
102
+ In another terminal I usually monitor the progress like so:
103
+
104
+ ```
105
+ % while true ; do clear; fd . -t d -t e gauntlet/*.noindex -X rmdir -p 2> /dev/null ; for D in gauntlet/*.noindex/? ; do echo -n "$D: "; fd .rb $D | wc -l ; done ; echo ; sleep 30 ; done
106
+ ```
@@ -12,26 +12,24 @@ class Regexp
12
12
  end
13
13
  # :startdoc:
14
14
 
15
- ############################################################
16
- # HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
17
-
18
- unless "".respond_to?(:grep) then
19
- class String
20
- def grep re
21
- lines.grep re
22
- end
15
+ class Array
16
+ def prepend *vals
17
+ self[0,0] = vals
23
18
  end
24
- end
19
+ end unless [].respond_to?(:prepend)
25
20
 
26
- class String
27
- ##
28
- # This is a hack used by the lexer to sneak in line numbers at the
29
- # identifier level. This should be MUCH smaller than making
30
- # process_token return [value, lineno] and modifying EVERYTHING that
31
- # reduces tIDENTIFIER.
21
+ # :stopdoc:
22
+ class Symbol
23
+ def end_with? o
24
+ self.to_s.end_with? o
25
+ end
26
+ end unless :woot.respond_to?(:end_with?)
27
+ # :startdoc:
32
28
 
33
- attr_accessor :lineno
29
+ ############################################################
30
+ # HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
34
31
 
32
+ class String
35
33
  def clean_caller
36
34
  self.sub(File.dirname(__FILE__), "./lib").sub(/:in.*/, "")
37
35
  end if $DEBUG
@@ -40,34 +38,15 @@ end
40
38
  require "sexp"
41
39
 
42
40
  class Sexp
43
- attr_writer :paren
41
+ attr_writer :paren # TODO: retire
44
42
 
45
43
  def paren
46
44
  @paren ||= false
47
45
  end
48
46
 
49
- def value
50
- raise "multi item sexp" if size > 2
51
- last
52
- end
53
-
54
- def to_sym
55
- raise "no: #{self.inspect}.to_sym is a bug"
56
- self.value.to_sym
57
- end
58
-
59
- alias :add :<<
60
-
61
- def add_all x
62
- self.concat x.sexp_body
63
- end
64
-
65
47
  def block_pass?
66
48
  any? { |s| Sexp === s && s.sexp_type == :block_pass }
67
49
  end
68
-
69
- alias :node_type :sexp_type
70
- alias :values :sexp_body # TODO: retire
71
50
  end
72
51
 
73
52
  # END HACK
@@ -0,0 +1,33 @@
1
+ require "strscan"
2
+
3
+ class RPStringScanner < StringScanner
4
+ if ENV["DEBUG"] || ENV["TALLY"] then
5
+ def getch
6
+ c = super
7
+ where = caller.drop_while { |s| s =~ /(getch|nextc).$/ }.first
8
+ where = where.split(/:/).first(2).join(":")
9
+ if ENV["TALLY"] then
10
+ d getch:where
11
+ else
12
+ d getch:[c, where]
13
+ end
14
+ c
15
+ end
16
+
17
+ def scan re
18
+ s = super
19
+ where = caller.drop_while { |x| x =~ /scan.$/ }.first
20
+ where = where.split(/:/).first(2).join(":")
21
+ if ENV["TALLY"] then
22
+ d scan:[where]
23
+ else
24
+ d scan:[s, where] if s
25
+ end
26
+ s
27
+ end
28
+
29
+ def d o
30
+ STDERR.puts o.inspect
31
+ end
32
+ end
33
+ end