brakeman 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +18 -1
- data/README.md +1 -1
- data/bundle/load.rb +5 -5
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
- 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
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/lib/parallel.rb +52 -43
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/History.rdoc +88 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/Manifest.txt +3 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/README.rdoc +1 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/compare/normalize.rb +6 -1
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/debugging.md +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby20_parser.y +335 -252
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby21_parser.y +330 -249
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby22_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby23_parser.y} +336 -276
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby24_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +335 -304
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.1/lib/ruby26_parser.y} +334 -288
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby27_parser.y} +906 -380
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +261 -609
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +27 -20
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +59 -23
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +296 -115
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/tools/munge.rb +34 -6
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/tools/ripper.rb +44 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
- 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
- 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
- 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
- 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
- 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
- data/lib/brakeman/app_tree.rb +1 -1
- data/lib/brakeman/checks/base_check.rb +10 -0
- data/lib/brakeman/checks/check_eol_rails.rb +23 -0
- data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
- data/lib/brakeman/checks/check_json_parsing.rb +1 -1
- data/lib/brakeman/checks/check_sql.rb +3 -2
- data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
- data/lib/brakeman/checks/eol_check.rb +47 -0
- data/lib/brakeman/options.rb +8 -0
- data/lib/brakeman/processors/alias_processor.rb +7 -1
- data/lib/brakeman/processors/gem_processor.rb +3 -0
- data/lib/brakeman/processors/haml_template_processor.rb +9 -0
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
- data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
- data/lib/brakeman/processors/model_processor.rb +1 -0
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/report/report_csv.rb +1 -1
- data/lib/brakeman/report/report_sarif.rb +1 -1
- data/lib/brakeman/report/report_text.rb +1 -1
- data/lib/brakeman/scanner.rb +15 -13
- data/lib/brakeman/tracker/config.rb +8 -1
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning_codes.rb +2 -0
- data/lib/brakeman.rb +2 -2
- data/lib/ruby_parser/bm_sexp.rb +11 -1
- metadata +105 -99
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
- 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
|
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
|
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) &&
|
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
|
-
|
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={:
|
215
|
+
def in_threads(options = { count: 2 })
|
208
216
|
threads = []
|
209
|
-
count,
|
217
|
+
count, = extract_count_from_options(options)
|
210
218
|
|
211
219
|
Thread.handle_interrupt(Exception => :never) do
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
-
|
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(:
|
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(:
|
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(:
|
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
|
255
|
-
elsif RUBY_PLATFORM =~ /java/
|
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(:
|
287
|
+
work_in_threads(job_factory, options.merge(count: size), &block)
|
282
288
|
else
|
283
|
-
work_in_processes(job_factory, options.merge(:
|
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(:
|
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
|
416
|
+
if exception.is_a?(Kill)
|
411
417
|
(workers - [worker]).each do |w|
|
412
|
-
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,
|
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[
|
435
|
+
worker = workers[index]
|
430
436
|
worker.stop
|
431
437
|
|
432
438
|
# create a new replacement worker
|
433
439
|
running = workers - [worker]
|
434
|
-
workers[
|
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
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
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
|
-
|
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,91 @@
|
|
1
|
+
=== 3.18.1 / 2021-11-10
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* All parser tests are now explicitly testing line numbers at every level.
|
6
|
+
|
7
|
+
* 3 bug fixes:
|
8
|
+
|
9
|
+
* Fixed endless method with noargs. (mitsuru)
|
10
|
+
* Fixed line numbers on some yield forms.
|
11
|
+
* Handle and clearly report if unifdef is missing.
|
12
|
+
|
13
|
+
=== 3.18.0 / 2021-10-27
|
14
|
+
|
15
|
+
Holy crap... 58 commits! 2.7 and 3.0 are feature complete. Strings
|
16
|
+
& heredocs have been rewritten.
|
17
|
+
|
18
|
+
* 9 major enhancements:
|
19
|
+
|
20
|
+
* !!! Rewrote lexer (and friends) for strings, heredocs, and %*[] constructs.
|
21
|
+
* Massive overhaul on line numbers.
|
22
|
+
* Freeze input! Finally!!! No more modifying the input string for heredocs.
|
23
|
+
* Overhauled RPStringScanner. Removed OLD compatibility methods!
|
24
|
+
* Removed Sexp methods: value, to_sym, add, add_all, node_type, values.
|
25
|
+
* value moved to sexp_processor.
|
26
|
+
* Removed String#grep monkey-patch.
|
27
|
+
* Removed String#lineno monkey-patch.
|
28
|
+
* Removed string_to_pos, charpos, etc hacks for ancient ruby versions.
|
29
|
+
* Removed unread_many... NO! NO EDITING THE INPUT STRING!
|
30
|
+
|
31
|
+
* 31 minor enhancements:
|
32
|
+
|
33
|
+
* 2.7/3.0: many more pattern edge cases
|
34
|
+
* 2.7: Added `mlhs = rhs rescue expr`
|
35
|
+
* 2.7: refactored destructured args (`|(k,v)|`) and unfactored(?!) case_body/args.
|
36
|
+
* 3.0: excessed_comma
|
37
|
+
* 3.0: finished most everything: endless methods, patterns, etc.
|
38
|
+
* 3.0: refactored / added new pattern changes
|
39
|
+
* Added RubyLexer#in_heredoc? (ie, is there old_ss ?)
|
40
|
+
* Added RubyLexer#old_ss and old_lineno and removed much of SSStack(ish).
|
41
|
+
* Added Symbol#end_with? when necessary
|
42
|
+
* Added TALLY and DEBUG options for ss.getch and ss.scan
|
43
|
+
* Added ignore_body_comments to make parser productions more clear.
|
44
|
+
* Added support for no_kwarg (eg `def f(**nil)`).
|
45
|
+
* Added support for no_kwarg in blocks (eg `f { |**nil| }`).
|
46
|
+
* Augmented generated parser files to have frozen_string_literal comments and fixed tests.
|
47
|
+
* Broke out 3.0 parser into its own to ease development.
|
48
|
+
* Bumped dependencies on sexp_processor and oedipus_lex.
|
49
|
+
* Clean generated 3.x files.
|
50
|
+
* Extracted all string scanner methods to their own module.
|
51
|
+
* Fixed some precedence decls.
|
52
|
+
* Implemented most of pattern matching for 2.7+.
|
53
|
+
* Improve lex_state= to report location in verbose debug mode.
|
54
|
+
* Made it easier to debug with a particular version of ruby via rake.
|
55
|
+
* Make sure ripper uses the same version of ruby we specified.
|
56
|
+
* Moved all string/heredoc/etc code to ruby_lexer_strings.rb
|
57
|
+
* Remove warning from newer bisons.
|
58
|
+
* Sprinkled in some frozen_string_literal, but mostly helped by oedipus bump.
|
59
|
+
* Switch to comparing against ruby binary since ripper is buggy.
|
60
|
+
* bugs task should try both bug*.rb and bad*.rb.
|
61
|
+
* endless methods
|
62
|
+
* f_any_kwrest refactoring.
|
63
|
+
* refactored defn/defs
|
64
|
+
|
65
|
+
* 15 bug fixes:
|
66
|
+
|
67
|
+
* Cleaned a bunch of old hacks. Initializing RubyLexer w/ Parser is cleaner now.
|
68
|
+
* Corrected some lex_state errors in process_token_keyword.
|
69
|
+
* Fixed ancient ruby2 change (use #lines) in ruby_parse_extract_error.
|
70
|
+
* Fixed bug where else without rescue only raises on 2.6+
|
71
|
+
* Fixed caller for getch and scan when DEBUG=1
|
72
|
+
* Fixed comments in the middle of message cascades.
|
73
|
+
* Fixed differences w/ symbol productions against ruby 2.7.
|
74
|
+
* Fixed dsym to use string_contents production.
|
75
|
+
* Fixed error in bdot2/3 in some edge cases. Fixed p_alt line.
|
76
|
+
* Fixed heredoc dedenting in the presence of empty lines. (mvz)
|
77
|
+
* Fixed some leading whitespace / comment processing
|
78
|
+
* Fixed up how class/module/defn/defs comments were collected.
|
79
|
+
* Overhauled ripper.rb to deal with buggy ripper w/ yydebug.
|
80
|
+
* Removed dsym from literal.
|
81
|
+
* Removed tUBANG lexeme but kept it distinct as a method name (eg: `def !@`).
|
82
|
+
|
83
|
+
=== 3.17.0 / 2021-08-03
|
84
|
+
|
85
|
+
* 1 minor enhancement:
|
86
|
+
|
87
|
+
* Added support for arg forwarding (eg `def f(...); m(...); end`) (presidentbeef)
|
88
|
+
|
1
89
|
=== 3.16.0 / 2021-05-15
|
2
90
|
|
3
91
|
* 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
|
-
|
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)|
|
File without changes
|
@@ -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
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
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
|