brakeman 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of brakeman might be problematic. Click here for more details.

Files changed (362) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/bundle/load.rb +7 -8
  4. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/History.rdoc +8 -0
  5. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/Manifest.txt +0 -0
  6. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/README.rdoc +0 -0
  7. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/lib/ruby2ruby.rb +34 -36
  8. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/History.rdoc +47 -0
  9. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/Manifest.txt +5 -4
  10. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/README.rdoc +0 -0
  11. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/compare/normalize.rb +29 -2
  12. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/debugging.md +18 -0
  13. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_extensions.rb +0 -7
  14. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_stringscanner.rb +0 -0
  15. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby20_parser.rb +6874 -0
  16. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby20_parser.y +284 -201
  17. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby21_parser.rb +6952 -0
  18. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby21_parser.y +281 -197
  19. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby22_parser.rb +6983 -0
  20. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib/ruby_parser.yy → ruby_parser-3.13.0/lib/ruby22_parser.y} +280 -306
  21. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby23_parser.rb +6982 -0
  22. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby23_parser.y +282 -203
  23. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby24_parser.rb +6982 -0
  24. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby24_parser.y +282 -203
  25. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby25_parser.rb +6981 -0
  26. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby25_parser.y +282 -203
  27. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.rb +6999 -0
  28. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.y +2469 -0
  29. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rb +116 -118
  30. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex +10 -8
  31. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex.rb +8 -8
  32. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_parser.rb +5 -7
  33. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser.yy +2571 -0
  34. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser_extras.rb +1360 -0
  35. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/munge.rb +216 -0
  36. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/ripper.rb +23 -0
  37. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +6 -0
  38. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +19 -0
  39. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +54 -0
  40. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +5 -0
  41. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.rb +7 -6
  42. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.y +5 -4
  43. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.rb +7 -6
  44. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.y +5 -4
  45. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +1412 -0
  46. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +179 -0
  47. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +323 -0
  48. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +30 -0
  49. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby_parser_extras.rb +43 -33
  50. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/CHANGES.md +5 -0
  51. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/Gemfile +0 -0
  52. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/LICENSE.txt +0 -0
  53. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/README.md +0 -0
  54. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/bundle_install_all_ruby_versions.sh +0 -0
  55. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml.rb +0 -0
  56. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/deep.rb +0 -0
  57. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/libyaml_checker.rb +0 -0
  58. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/load.rb +0 -0
  59. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/date.rb +2 -0
  60. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/hexadecimal.rb +0 -0
  61. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/sexagesimal.rb +0 -0
  62. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_handler.rb +0 -0
  63. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_resolver.rb +0 -0
  64. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/resolver.rb +0 -0
  65. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -0
  66. data/bundle/ruby/2.5.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +39 -0
  67. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_hack.rb +0 -0
  68. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_node_monkeypatch.rb +0 -0
  69. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_resolver.rb +0 -0
  70. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform.rb +0 -0
  71. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_boolean.rb +0 -0
  72. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_date.rb +0 -0
  73. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_float.rb +0 -0
  74. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_integer.rb +0 -0
  75. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_nil.rb +0 -0
  76. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_symbol.rb +0 -0
  77. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/transformation_map.rb +0 -0
  78. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/version.rb +1 -1
  79. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/run_specs_all_ruby_versions.sh +0 -0
  80. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/safe_yaml.gemspec +0 -0
  81. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/History.rdoc +8 -0
  82. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/Manifest.txt +0 -0
  83. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/README.rdoc +0 -0
  84. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/composite_sexp_processor.rb +0 -0
  85. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/pt_testcase.rb +2 -2
  86. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp.rb +4 -4
  87. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp_processor.rb +1 -1
  88. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/strict_sexp.rb +3 -3
  89. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/unique.rb +0 -0
  90. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/CHANGES +6 -0
  91. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/EXPRESSIONS.md +1 -1
  92. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/Gemfile +0 -0
  93. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/LICENSE +0 -0
  94. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/README.md +1 -1
  95. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple.rb +0 -0
  96. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/engine.rb +0 -0
  97. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/engine.rb +0 -0
  98. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/parser.rb +0 -0
  99. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/template.rb +0 -0
  100. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/trimming.rb +0 -0
  101. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/exceptions.rb +0 -0
  102. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filter.rb +0 -0
  103. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/code_merger.rb +0 -0
  104. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/control_flow.rb +0 -0
  105. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/dynamic_inliner.rb +0 -0
  106. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/encoding.rb +0 -0
  107. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/eraser.rb +0 -0
  108. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/escapable.rb +0 -0
  109. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/multi_flattener.rb +0 -0
  110. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/remove_bom.rb +0 -0
  111. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_analyzer.rb +0 -0
  112. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_merger.rb +0 -0
  113. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/string_splitter.rb +0 -0
  114. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/validator.rb +0 -0
  115. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generator.rb +0 -0
  116. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array.rb +0 -0
  117. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array_buffer.rb +0 -0
  118. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/erb.rb +0 -0
  119. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/rails_output_buffer.rb +0 -0
  120. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/string_buffer.rb +0 -0
  121. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/grammar.rb +0 -0
  122. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_merger.rb +0 -0
  123. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_remover.rb +0 -0
  124. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_sorter.rb +0 -0
  125. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/dispatcher.rb +0 -0
  126. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/fast.rb +0 -0
  127. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/filter.rb +0 -0
  128. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/pretty.rb +0 -0
  129. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/safe.rb +0 -0
  130. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/map.rb +0 -0
  131. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/dispatcher.rb +2 -1
  132. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/engine_dsl.rb +0 -0
  133. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/grammar_dsl.rb +0 -0
  134. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/options.rb +0 -0
  135. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/template.rb +0 -0
  136. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/parser.rb +0 -0
  137. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/static_analyzer.rb +0 -0
  138. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates.rb +0 -0
  139. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/rails.rb +2 -2
  140. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/tilt.rb +0 -0
  141. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/utils.rb +0 -0
  142. data/bundle/ruby/2.5.0/gems/temple-0.8.1/lib/temple/version.rb +3 -0
  143. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/temple.gemspec +0 -0
  144. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/CHANGELOG.md +4 -0
  145. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/MIT-LICENSE.txt +1 -1
  146. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/README.md +10 -10
  147. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.5.0/data/display_width.marshal.gz +0 -0
  148. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width.rb +0 -0
  149. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/constants.rb +2 -2
  150. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/index.rb +0 -0
  151. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  152. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/string_ext.rb +0 -0
  153. data/lib/brakeman/checks/base_check.rb +16 -0
  154. data/lib/brakeman/checks/check_content_tag.rb +12 -0
  155. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -6
  156. data/lib/brakeman/checks/check_evaluation.rb +0 -1
  157. data/lib/brakeman/checks/check_execute.rb +18 -0
  158. data/lib/brakeman/checks/check_send.rb +0 -1
  159. data/lib/brakeman/checks/check_session_manipulation.rb +0 -1
  160. data/lib/brakeman/checks/check_sql.rb +12 -3
  161. data/lib/brakeman/file_parser.rb +8 -4
  162. data/lib/brakeman/parsers/haml_embedded.rb +44 -0
  163. data/lib/brakeman/parsers/slim_embedded.rb +44 -0
  164. data/lib/brakeman/parsers/template_parser.rb +2 -4
  165. data/lib/brakeman/processors/alias_processor.rb +23 -1
  166. data/lib/brakeman/processors/lib/call_conversion_helper.rb +4 -0
  167. data/lib/brakeman/processors/slim_template_processor.rb +16 -0
  168. data/lib/brakeman/processors/template_alias_processor.rb +2 -2
  169. data/lib/brakeman/scanner.rb +11 -10
  170. data/lib/brakeman/tracker.rb +5 -1
  171. data/lib/brakeman/tracker/config.rb +32 -7
  172. data/lib/brakeman/util.rb +17 -0
  173. data/lib/brakeman/version.rb +1 -1
  174. metadata +157 -320
  175. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby20_parser.rb +0 -6687
  176. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby21_parser.rb +0 -6767
  177. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.rb +0 -6803
  178. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.y +0 -2376
  179. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby23_parser.rb +0 -6818
  180. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby24_parser.rb +0 -6818
  181. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby25_parser.rb +0 -6818
  182. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CODE_OF_CONDUCT.md +0 -10
  183. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CONTRIBUTING.md +0 -148
  184. data/bundle/ruby/2.5.0/gems/sass-3.4.25/MIT-LICENSE +0 -20
  185. data/bundle/ruby/2.5.0/gems/sass-3.4.25/README.md +0 -227
  186. data/bundle/ruby/2.5.0/gems/sass-3.4.25/REVISION +0 -1
  187. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION +0 -1
  188. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_DATE +0 -1
  189. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_NAME +0 -1
  190. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/sass-spec-ref.sh +0 -32
  191. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/update_watch.rb +0 -13
  192. data/bundle/ruby/2.5.0/gems/sass-3.4.25/init.rb +0 -18
  193. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass.rb +0 -109
  194. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores.rb +0 -15
  195. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/base.rb +0 -88
  196. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb +0 -34
  197. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/filesystem.rb +0 -60
  198. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/memory.rb +0 -46
  199. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/null.rb +0 -25
  200. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/callbacks.rb +0 -67
  201. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/css.rb +0 -408
  202. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/deprecation.rb +0 -55
  203. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/engine.rb +0 -1226
  204. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/environment.rb +0 -215
  205. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/error.rb +0 -198
  206. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec.rb +0 -9
  207. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/base.rb +0 -199
  208. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_convert.rb +0 -283
  209. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_scss.rb +0 -440
  210. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb +0 -47
  211. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers.rb +0 -23
  212. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/base.rb +0 -182
  213. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/deprecated_path.rb +0 -51
  214. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/filesystem.rb +0 -219
  215. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger.rb +0 -17
  216. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/base.rb +0 -36
  217. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/delayed.rb +0 -50
  218. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/log_level.rb +0 -45
  219. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/media.rb +0 -210
  220. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin.rb +0 -134
  221. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/compiler.rb +0 -582
  222. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/configuration.rb +0 -134
  223. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/generic.rb +0 -15
  224. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/merb.rb +0 -48
  225. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rack.rb +0 -60
  226. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rails.rb +0 -47
  227. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/staleness_checker.rb +0 -199
  228. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/railtie.rb +0 -10
  229. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/repl.rb +0 -57
  230. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/root.rb +0 -7
  231. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script.rb +0 -66
  232. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_lexer.rb +0 -33
  233. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_parser.rb +0 -33
  234. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_variable_warning.rb +0 -52
  235. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/functions.rb +0 -2693
  236. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/lexer.rb +0 -464
  237. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/parser.rb +0 -832
  238. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree.rb +0 -16
  239. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/funcall.rb +0 -313
  240. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/interpolation.rb +0 -223
  241. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/list_literal.rb +0 -104
  242. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/literal.rb +0 -49
  243. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/map_literal.rb +0 -64
  244. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/node.rb +0 -127
  245. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/operation.rb +0 -156
  246. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/selector.rb +0 -26
  247. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/string_interpolation.rb +0 -125
  248. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/unary_operation.rb +0 -69
  249. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/variable.rb +0 -57
  250. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value.rb +0 -11
  251. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/arg_list.rb +0 -36
  252. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/base.rb +0 -241
  253. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/bool.rb +0 -35
  254. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/color.rb +0 -698
  255. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/helpers.rb +0 -272
  256. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/list.rb +0 -113
  257. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/map.rb +0 -70
  258. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/null.rb +0 -44
  259. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/number.rb +0 -563
  260. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/string.rb +0 -138
  261. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss.rb +0 -14
  262. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/css_parser.rb +0 -56
  263. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/parser.rb +0 -1254
  264. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/rx.rb +0 -140
  265. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/static_parser.rb +0 -373
  266. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector.rb +0 -323
  267. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/abstract_sequence.rb +0 -111
  268. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/comma_sequence.rb +0 -191
  269. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/pseudo.rb +0 -266
  270. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/sequence.rb +0 -636
  271. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple.rb +0 -117
  272. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple_sequence.rb +0 -344
  273. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/shared.rb +0 -76
  274. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/map.rb +0 -213
  275. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/position.rb +0 -39
  276. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/range.rb +0 -41
  277. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/stack.rb +0 -120
  278. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/supports.rb +0 -225
  279. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/at_root_node.rb +0 -83
  280. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/charset_node.rb +0 -22
  281. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/comment_node.rb +0 -82
  282. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/content_node.rb +0 -9
  283. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/css_import_node.rb +0 -68
  284. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/debug_node.rb +0 -18
  285. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/directive_node.rb +0 -59
  286. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/each_node.rb +0 -24
  287. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/error_node.rb +0 -18
  288. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/extend_node.rb +0 -43
  289. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/for_node.rb +0 -36
  290. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/function_node.rb +0 -44
  291. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb +0 -52
  292. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/import_node.rb +0 -75
  293. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/keyframe_rule_node.rb +0 -15
  294. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/media_node.rb +0 -48
  295. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_def_node.rb +0 -38
  296. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_node.rb +0 -52
  297. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/node.rb +0 -240
  298. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/prop_node.rb +0 -170
  299. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/return_node.rb +0 -19
  300. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/root_node.rb +0 -44
  301. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/rule_node.rb +0 -155
  302. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/supports_node.rb +0 -38
  303. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/trace_node.rb +0 -33
  304. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/variable_node.rb +0 -36
  305. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb +0 -72
  306. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/check_nesting.rb +0 -173
  307. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/convert.rb +0 -351
  308. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/cssize.rb +0 -373
  309. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/deep_copy.rb +0 -107
  310. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/extend.rb +0 -70
  311. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb +0 -564
  312. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/set_options.rb +0 -139
  313. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/to_css.rb +0 -409
  314. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/warn_node.rb +0 -18
  315. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/while_node.rb +0 -18
  316. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util.rb +0 -1375
  317. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/cross_platform_random.rb +0 -19
  318. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/multibyte_string_scanner.rb +0 -155
  319. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/normalized_map.rb +0 -129
  320. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/ordered_hash.rb +0 -192
  321. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/subset_map.rb +0 -109
  322. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/test.rb +0 -9
  323. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/version.rb +0 -124
  324. data/bundle/ruby/2.5.0/gems/sass-3.4.25/rails/init.rb +0 -1
  325. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CHANGELOG.md +0 -1
  326. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CONTRIBUTING.md +0 -38
  327. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Gemfile +0 -20
  328. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Guardfile +0 -8
  329. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/LICENSE +0 -20
  330. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/README.md +0 -349
  331. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Rakefile +0 -5
  332. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Vagrantfile +0 -96
  333. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen.rb +0 -54
  334. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapter.rb +0 -327
  335. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  336. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  337. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  338. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  339. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  340. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/directory_record.rb +0 -406
  341. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/listener.rb +0 -323
  342. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/turnstile.rb +0 -32
  343. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/version.rb +0 -3
  344. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/listen.gemspec +0 -28
  345. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  346. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  347. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  348. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  349. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  350. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  351. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  352. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/listener_spec.rb +0 -258
  353. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  354. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen_spec.rb +0 -67
  355. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/spec_helper.rb +0 -25
  356. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/adapter_helper.rb +0 -666
  357. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  358. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  359. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/listeners_helper.rb +0 -179
  360. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/platform_helper.rb +0 -15
  361. data/bundle/ruby/2.5.0/gems/temple-0.8.0/lib/temple/version.rb +0 -3
  362. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.4.1/data/display_width.marshal.gz +0 -0
@@ -0,0 +1,1360 @@
1
+ # encoding: ASCII-8BIT
2
+
3
+ require "sexp"
4
+ require "ruby_lexer"
5
+ require "timeout"
6
+ require "rp_extensions"
7
+ require "rp_stringscanner"
8
+
9
+ module RubyParserStuff
10
+ VERSION = "3.13.0"
11
+
12
+ attr_accessor :lexer, :in_def, :in_single, :file
13
+ attr_accessor :in_kwarg
14
+ attr_reader :env, :comments
15
+
16
+ $good20 = []
17
+
18
+ %w[
19
+ ].map(&:to_i).each do |n|
20
+ $good20[n] = n
21
+ end
22
+
23
+ def debug20 n, v = nil, r = nil
24
+ raise "not yet #{n} #{v.inspect} => #{r.inspect}" unless $good20[n]
25
+ end
26
+
27
+ def self.deprecate old, new
28
+ define_method old do |*args|
29
+ warn "DEPRECATED: #{old} -> #{new} from #{caller.first}"
30
+ send new, *args
31
+ end
32
+ end
33
+
34
+ has_enc = "".respond_to? :encoding
35
+
36
+ # This is in sorted order of occurrence according to
37
+ # charlock_holmes against 500k files, with UTF_8 forced
38
+ # to the top.
39
+ #
40
+ # Overwrite this contstant if you need something different.
41
+ ENCODING_ORDER = [
42
+ Encoding::UTF_8, # moved to top to reflect default in 2.0
43
+ Encoding::ISO_8859_1,
44
+ Encoding::ISO_8859_2,
45
+ Encoding::ISO_8859_9,
46
+ Encoding::SHIFT_JIS,
47
+ Encoding::WINDOWS_1252,
48
+ Encoding::EUC_JP
49
+ ] if has_enc
50
+
51
+ def syntax_error msg
52
+ raise RubyParser::SyntaxError, msg
53
+ end
54
+
55
+ def arg_blk_pass node1, node2 # TODO: nuke
56
+ node1 = s(:arglist, node1) unless [:arglist, :call_args, :array, :args].include? node1.sexp_type
57
+ node1 << node2 if node2
58
+ node1
59
+ end
60
+
61
+ def arg_concat node1, node2 # TODO: nuke
62
+ raise "huh" unless node2
63
+ node1 << s(:splat, node2).compact
64
+ node1
65
+ end
66
+
67
+ def clean_mlhs sexp
68
+ case sexp.sexp_type
69
+ when :masgn then
70
+ if sexp.size == 2 and sexp[1].sexp_type == :array then
71
+ s(:masgn, *sexp[1].sexp_body.map { |sub| clean_mlhs sub })
72
+ else
73
+ debug20 5
74
+ sexp
75
+ end
76
+ when :gasgn, :iasgn, :lasgn, :cvasgn then
77
+ if sexp.size == 2 then
78
+ sexp.last
79
+ else
80
+ debug20 7
81
+ sexp # optional value
82
+ end
83
+ else
84
+ raise "unsupported type: #{sexp.inspect}"
85
+ end
86
+ end
87
+
88
+ def block_var *args
89
+ result = self.args args
90
+ result.sexp_type = :masgn
91
+ result
92
+ end
93
+
94
+ def array_to_hash array
95
+ case array.sexp_type
96
+ when :kwsplat then
97
+ array
98
+ else
99
+ s(:hash, *array.sexp_body)
100
+ end
101
+ end
102
+
103
+ def call_args args
104
+ result = s(:call_args)
105
+
106
+ args.each do |arg|
107
+ case arg
108
+ when Sexp then
109
+ case arg.sexp_type
110
+ when :array, :args, :call_args then # HACK? remove array at some point
111
+ result.concat arg.sexp_body
112
+ else
113
+ result << arg
114
+ end
115
+ when Symbol then
116
+ result << arg
117
+ when ",", nil then
118
+ # ignore
119
+ else
120
+ raise "unhandled: #{arg.inspect} in #{args.inspect}"
121
+ end
122
+ end
123
+
124
+ result
125
+ end
126
+
127
+ def args args
128
+ result = s(:args)
129
+
130
+ args.each do |arg|
131
+ case arg
132
+ when Sexp then
133
+ case arg.sexp_type
134
+ when :args, :block, :array, :call_args then # HACK call_args mismatch
135
+ result.concat arg.sexp_body
136
+ when :block_arg then
137
+ result << :"&#{arg.last}"
138
+ when :shadow then
139
+ name = arg.last
140
+ self.env[name] = :lvar
141
+ if Sexp === result.last and result.last.sexp_type == :shadow then
142
+ result.last << name
143
+ else
144
+ result << arg
145
+ end
146
+ when :masgn, :block_pass, :hash then # HACK: remove. prolly call_args
147
+ result << arg
148
+ else
149
+ raise "unhandled: #{arg.sexp_type} in #{args.inspect}"
150
+ end
151
+ when Symbol then
152
+ name = arg.to_s.delete("&*")
153
+ self.env[name.to_sym] = :lvar unless name.empty?
154
+ result << arg
155
+ when ",", "|", ";", "(", ")", nil then
156
+ # ignore
157
+ else
158
+ raise "unhandled: #{arg.inspect} in #{args.inspect}"
159
+ end
160
+ end
161
+
162
+ result
163
+ end
164
+
165
+ def aryset receiver, index
166
+ index ||= s()
167
+ s(:attrasgn, receiver, :"[]=", *index.sexp_body).compact # [].sexp_body => nil
168
+ end
169
+
170
+ def assignable(lhs, value = nil)
171
+ id = lhs.to_sym unless Sexp === lhs
172
+ id = id.to_sym if Sexp === id
173
+
174
+ raise "write a test 1" if id.to_s =~ /^(?:self|nil|true|false|__LINE__|__FILE__)$/
175
+
176
+ raise SyntaxError, "Can't change the value of #{id}" if
177
+ id.to_s =~ /^(?:self|nil|true|false|__LINE__|__FILE__)$/
178
+
179
+ result = case id.to_s
180
+ when /^@@/ then
181
+ asgn = in_def || in_single > 0
182
+ s((asgn ? :cvasgn : :cvdecl), id)
183
+ when /^@/ then
184
+ s(:iasgn, id)
185
+ when /^\$/ then
186
+ s(:gasgn, id)
187
+ when /^[A-Z]/ then
188
+ s(:cdecl, id)
189
+ else
190
+ case self.env[id]
191
+ when :lvar, :dvar, nil then
192
+ s(:lasgn, id)
193
+ else
194
+ raise "wtf? unknown type: #{self.env[id]}"
195
+ end
196
+ end
197
+
198
+ self.env[id] ||= :lvar if result.sexp_type == :lasgn
199
+
200
+ result << value if value
201
+
202
+ return result
203
+ end
204
+
205
+ def block_append(head, tail)
206
+ return head if tail.nil?
207
+ return tail if head.nil?
208
+
209
+ line = [head.line, tail.line].compact.min
210
+
211
+ head = remove_begin(head)
212
+ head = s(:block, head) unless head.node_type == :block
213
+
214
+ head.line = line
215
+ head << tail
216
+ end
217
+
218
+ def cond node
219
+ return nil if node.nil?
220
+ node = value_expr node
221
+
222
+ case node.sexp_type
223
+ when :lit then
224
+ if Regexp === node.last then
225
+ return s(:match, node)
226
+ else
227
+ return node
228
+ end
229
+ when :and then
230
+ return s(:and, cond(node[1]), cond(node[2]))
231
+ when :or then
232
+ return s(:or, cond(node[1]), cond(node[2]))
233
+ when :dot2 then
234
+ label = "flip#{node.hash}"
235
+ env[label] = :lvar
236
+ _, lhs, rhs = node
237
+ return s(:flip2, lhs, rhs)
238
+ when :dot3 then
239
+ label = "flip#{node.hash}"
240
+ env[label] = :lvar
241
+ _, lhs, rhs = node
242
+ return s(:flip3, lhs, rhs)
243
+ else
244
+ return node
245
+ end
246
+ end
247
+
248
+ ##
249
+ # for pure ruby systems only
250
+
251
+ def do_parse
252
+ _racc_do_parse_rb(_racc_setup, false)
253
+ end if ENV['PURE_RUBY']
254
+
255
+ def new_match lhs, rhs
256
+ if lhs then
257
+ case lhs.sexp_type
258
+ when :dregx, :dregx_once then
259
+ return s(:match2, lhs, rhs).line(lhs.line)
260
+ when :lit then
261
+ return s(:match2, lhs, rhs).line(lhs.line) if Regexp === lhs.last
262
+ end
263
+ end
264
+
265
+ if rhs then
266
+ case rhs.sexp_type
267
+ when :dregx, :dregx_once then
268
+ return s(:match3, rhs, lhs).line(lhs.line)
269
+ when :lit then
270
+ return s(:match3, rhs, lhs).line(lhs.line) if Regexp === rhs.last
271
+ end
272
+ end
273
+
274
+ return new_call(lhs, :"=~", argl(rhs)).line(lhs.line)
275
+ end
276
+
277
+ def gettable(id)
278
+ lineno = id.lineno if id.respond_to? :lineno
279
+ id = id.to_sym if String === id
280
+
281
+ result = case id.to_s
282
+ when /^@@/ then
283
+ s(:cvar, id)
284
+ when /^@/ then
285
+ s(:ivar, id)
286
+ when /^\$/ then
287
+ s(:gvar, id)
288
+ when /^[A-Z]/ then
289
+ s(:const, id)
290
+ else
291
+ type = env[id]
292
+ if type then
293
+ s(type, id)
294
+ else
295
+ new_call(nil, id)
296
+ end
297
+ end
298
+
299
+ result.line lineno if lineno
300
+
301
+ raise "identifier #{id.inspect} is not valid" unless result
302
+
303
+ result
304
+ end
305
+
306
+ ##
307
+ # Canonicalize conditionals. Eg:
308
+ #
309
+ # not x ? a : b
310
+ #
311
+ # becomes:
312
+ #
313
+ # x ? b : a
314
+
315
+ attr_accessor :canonicalize_conditions
316
+
317
+ def initialize(options = {})
318
+ super()
319
+
320
+ v = self.class.name[/2\d/]
321
+ raise "Bad Class name #{self.class}" unless v
322
+
323
+ self.lexer = RubyLexer.new v && v.to_i
324
+ self.lexer.parser = self
325
+ self.in_kwarg = false
326
+
327
+ @env = RubyParserStuff::Environment.new
328
+ @comments = []
329
+
330
+ @canonicalize_conditions = true
331
+
332
+ self.reset
333
+ end
334
+
335
+ def list_append list, item # TODO: nuke me *sigh*
336
+ return s(:array, item) unless list
337
+ list = s(:array, list) unless Sexp === list && list.sexp_type == :array
338
+ list << item
339
+ end
340
+
341
+ def list_prepend item, list # TODO: nuke me *sigh*
342
+ list = s(:array, list) unless Sexp === list && list.sexp_type == :array
343
+ list.insert 1, item
344
+ list
345
+ end
346
+
347
+ def literal_concat head, tail # TODO: ugh. rewrite
348
+ return tail unless head
349
+ return head unless tail
350
+
351
+ htype, ttype = head.sexp_type, tail.sexp_type
352
+
353
+ head = s(:dstr, '', head) if htype == :evstr
354
+
355
+ case ttype
356
+ when :str then
357
+ if htype == :str
358
+ head.last << tail.last
359
+ elsif htype == :dstr and head.size == 2 then
360
+ head.last << tail.last
361
+ else
362
+ head << tail
363
+ end
364
+ when :dstr then
365
+ if htype == :str then
366
+ lineno = head.line
367
+ tail[1] = head.last + tail[1]
368
+ head = tail
369
+ head.line = lineno
370
+ else
371
+ tail.sexp_type = :array
372
+ tail[1] = s(:str, tail[1])
373
+ tail.delete_at 1 if tail[1] == s(:str, '')
374
+
375
+ head.push(*tail.sexp_body)
376
+ end
377
+ when :evstr then
378
+ if htype == :str then
379
+ f, l = head.file, head.line
380
+ head = s(:dstr, *head.sexp_body)
381
+ head.file = f
382
+ head.line = l
383
+ end
384
+
385
+ if head.size == 2 and tail.size > 1 and tail[1].sexp_type == :str then
386
+ head.last << tail[1].last
387
+ head.sexp_type = :str if head.size == 2 # HACK ?
388
+ else
389
+ head.push(tail)
390
+ end
391
+ else
392
+ x = [head, tail]
393
+ raise "unknown type: #{x.inspect}"
394
+ end
395
+
396
+ return head
397
+ end
398
+
399
+ def logical_op type, left, right
400
+ left = value_expr left
401
+
402
+ if left and left.sexp_type == type and not left.paren then
403
+ node, rhs = left, nil
404
+
405
+ loop do
406
+ _, _lhs, rhs = node
407
+ break unless rhs && rhs.sexp_type == type and not rhs.paren
408
+ node = rhs
409
+ end
410
+
411
+ node[2] = s(type, rhs, right)
412
+
413
+ return left
414
+ end
415
+
416
+ return s(type, left, right)
417
+ end
418
+
419
+ def new_aref val
420
+ val[2] ||= s(:arglist)
421
+ val[2].sexp_type = :arglist if val[2].sexp_type == :array # REFACTOR
422
+ new_call val[0], :"[]", val[2]
423
+ end
424
+
425
+ def new_body val
426
+ body, resbody, elsebody, ensurebody = val
427
+
428
+ result = body
429
+
430
+ if resbody then
431
+ result = s(:rescue)
432
+ result << body if body
433
+
434
+ res = resbody
435
+
436
+ while res do
437
+ result << res
438
+ res = res.resbody(true)
439
+ end
440
+
441
+ result << elsebody if elsebody
442
+
443
+ result.line = (body || resbody).line
444
+ end
445
+
446
+ if elsebody and not resbody then
447
+ warning("else without rescue is useless")
448
+ result = s(:begin, result) if result
449
+ result = block_append(result, elsebody)
450
+ end
451
+
452
+ result = s(:ensure, result, ensurebody).compact if ensurebody
453
+
454
+ result
455
+ end
456
+
457
+ def new_brace_body args, body, lineno
458
+ new_iter(nil, args, body).line(lineno)
459
+ end
460
+
461
+ def argl x
462
+ x = s(:arglist, x) if x and x.sexp_type == :array
463
+ x
464
+ end
465
+
466
+ def backref_assign_error ref
467
+ # TODO: need a test for this... obviously
468
+ case ref.sexp_type
469
+ when :nth_ref then
470
+ raise "write a test 2"
471
+ raise SyntaxError, "Can't set variable %p" % ref.last
472
+ when :back_ref then
473
+ raise "write a test 3"
474
+ raise SyntaxError, "Can't set back reference %p" % ref.last
475
+ else
476
+ raise "Unknown backref type: #{ref.inspect}"
477
+ end
478
+ end
479
+
480
+ def new_call recv, meth, args = nil, call_op = :'.'
481
+ result = case call_op.to_sym
482
+ when :'.'
483
+ s(:call, recv, meth)
484
+ when :'&.'
485
+ s(:safe_call, recv, meth)
486
+ else
487
+ raise "unknown call operator: `#{type.inspect}`"
488
+ end
489
+
490
+ # TODO: need a test with f(&b) to produce block_pass
491
+ # TODO: need a test with f(&b) { } to produce warning
492
+
493
+ if args
494
+ if [:arglist, :args, :array, :call_args].include? args.sexp_type
495
+ result.concat args.sexp_body
496
+ else
497
+ result << args
498
+ end
499
+ end
500
+
501
+ line = result.grep(Sexp).map(&:line).compact.min
502
+ result.line = line if line
503
+
504
+ result
505
+ end
506
+
507
+ def new_attrasgn recv, meth, call_op
508
+ meth = :"#{meth}="
509
+
510
+ result = case call_op.to_sym
511
+ when :'.'
512
+ s(:attrasgn, recv, meth)
513
+ when :'&.'
514
+ s(:safe_attrasgn, recv, meth)
515
+ else
516
+ raise "unknown call operator: `#{type.inspect}`"
517
+ end
518
+
519
+ result.line = recv.line
520
+ result
521
+ end
522
+
523
+ def new_case expr, body, line
524
+ result = s(:case, expr)
525
+
526
+ while body and body.node_type == :when
527
+ result << body
528
+ body = body.delete_at 3
529
+ end
530
+
531
+ result[2..-1].each do |node|
532
+ block = node.block(:delete)
533
+ node.concat block.sexp_body if block
534
+ end
535
+
536
+ # else
537
+ body = nil if body == s(:block)
538
+ result << body
539
+
540
+ result.line = line
541
+ result
542
+ end
543
+
544
+ def new_class val
545
+ line, path, superclass, body = val[1], val[2], val[3], val[5]
546
+
547
+ result = s(:class, path, superclass)
548
+
549
+ if body then
550
+ if body.sexp_type == :block then
551
+ result.push(*body.sexp_body)
552
+ else
553
+ result.push body
554
+ end
555
+ end
556
+
557
+ result.line = line
558
+ result.comments = self.comments.pop
559
+ result
560
+ end
561
+
562
+ def new_compstmt val
563
+ result = void_stmts(val.grep(Sexp)[0])
564
+ result = remove_begin(result) if result
565
+ result
566
+ end
567
+
568
+ def new_defn val
569
+ (_, line), (name, _), _, args, body, * = val
570
+ body ||= s(:nil)
571
+
572
+ result = s(:defn, name.to_sym, args)
573
+
574
+ if body then
575
+ if body.sexp_type == :block then
576
+ result.push(*body.sexp_body)
577
+ else
578
+ result.push body
579
+ end
580
+ end
581
+
582
+ args.line line
583
+ result.line = line
584
+ result.comments = self.comments.pop
585
+
586
+ result
587
+ end
588
+
589
+ def new_defs val
590
+ recv, (name, _line), args, body = val[1], val[4], val[6], val[7]
591
+ body ||= s(:nil)
592
+
593
+ result = s(:defs, recv, name.to_sym, args)
594
+
595
+ if body then
596
+ if body.sexp_type == :block then
597
+ result.push(*body.sexp_body)
598
+ else
599
+ result.push body
600
+ end
601
+ end
602
+
603
+ result.line = recv.line
604
+ result.comments = self.comments.pop
605
+ result
606
+ end
607
+
608
+ def new_do_body args, body, lineno
609
+ new_iter(nil, args, body).line(lineno)
610
+ end
611
+
612
+ def new_for expr, var, body
613
+ result = s(:for, expr, var).line(var.line)
614
+ result << body if body
615
+ result
616
+ end
617
+
618
+ def new_hash val
619
+ s(:hash, *val[2].values).line(val[1])
620
+ end
621
+
622
+ def new_if c, t, f
623
+ l = [c.line, t && t.line, f && f.line].compact.min
624
+ c = cond c
625
+ c, t, f = c.last, f, t if c.sexp_type == :not and canonicalize_conditions
626
+ s(:if, c, t, f).line(l)
627
+ end
628
+
629
+ def new_iter call, args, body
630
+ body ||= nil
631
+
632
+ args ||= s(:args)
633
+ args = s(:args, args) if Symbol === args
634
+
635
+ result = s(:iter)
636
+ result << call if call
637
+ result << args
638
+ result << body if body
639
+
640
+ args.sexp_type = :args unless args == 0
641
+
642
+ result
643
+ end
644
+
645
+ def new_masgn_arg rhs, wrap = false
646
+ rhs = value_expr(rhs)
647
+ rhs = s(:to_ary, rhs) if wrap # HACK: could be array if lhs isn't right
648
+ rhs
649
+ end
650
+
651
+ def new_masgn lhs, rhs, wrap = false
652
+ _, ary = lhs
653
+
654
+ rhs = value_expr(rhs)
655
+ rhs = ary ? s(:to_ary, rhs) : s(:array, rhs) if wrap
656
+
657
+ lhs.delete_at 1 if ary.nil?
658
+ lhs << rhs
659
+
660
+ lhs
661
+ end
662
+
663
+ def new_module val
664
+ line, path, body = val[1], val[2], val[4]
665
+
666
+ result = s(:module, path)
667
+
668
+ if body then # REFACTOR?
669
+ if body.sexp_type == :block then
670
+ result.push(*body.sexp_body)
671
+ else
672
+ result.push body
673
+ end
674
+ end
675
+
676
+ result.line = line
677
+ result.comments = self.comments.pop
678
+ result
679
+ end
680
+
681
+ def new_op_asgn val
682
+ lhs, asgn_op, arg = val[0], val[1].to_sym, val[2]
683
+ name = lhs.value
684
+ arg = remove_begin(arg)
685
+ result = case asgn_op # REFACTOR
686
+ when :"||" then
687
+ lhs << arg
688
+ s(:op_asgn_or, self.gettable(name), lhs)
689
+ when :"&&" then
690
+ lhs << arg
691
+ s(:op_asgn_and, self.gettable(name), lhs)
692
+ else
693
+ # TODO: why [2] ?
694
+ lhs[2] = new_call(self.gettable(name), asgn_op, argl(arg))
695
+ lhs
696
+ end
697
+ result.line = lhs.line
698
+ result
699
+ end
700
+
701
+ def new_op_asgn2 val
702
+ recv, call_op, meth, op, arg = val
703
+ meth = :"#{meth}="
704
+
705
+ result = case call_op.to_sym
706
+ when :'.'
707
+ s(:op_asgn2, recv, meth, op.to_sym, arg)
708
+ when :'&.'
709
+ s(:safe_op_asgn2, recv, meth, op.to_sym, arg)
710
+ else
711
+ raise "unknown call operator: `#{type.inspect}`"
712
+ end
713
+
714
+ result.line = recv.line
715
+ result
716
+ end
717
+
718
+ def new_regexp val
719
+ node = val[1] || s(:str, '')
720
+ options = val[2]
721
+
722
+ o, k = 0, nil
723
+ options.split(//).uniq.each do |c| # FIX: this has a better home
724
+ v = {
725
+ 'x' => Regexp::EXTENDED,
726
+ 'i' => Regexp::IGNORECASE,
727
+ 'm' => Regexp::MULTILINE,
728
+ 'o' => Regexp::ONCE,
729
+ 'n' => Regexp::ENC_NONE,
730
+ 'e' => Regexp::ENC_EUC,
731
+ 's' => Regexp::ENC_SJIS,
732
+ 'u' => Regexp::ENC_UTF8,
733
+ }[c]
734
+ raise "unknown regexp option: #{c}" unless v
735
+ o += v
736
+ end
737
+
738
+ case node.sexp_type
739
+ when :str then
740
+ node.sexp_type = :lit
741
+ node[1] = if k then
742
+ Regexp.new(node[1], o, k)
743
+ else
744
+ begin
745
+ Regexp.new(node[1], o)
746
+ rescue RegexpError => e
747
+ warn "WA\RNING: #{e.message} for #{node[1].inspect} #{options.inspect}"
748
+ begin
749
+ warn "WA\RNING: trying to recover with ENC_UTF8"
750
+ Regexp.new(node[1], Regexp::ENC_UTF8)
751
+ rescue RegexpError => e
752
+ warn "WA\RNING: trying to recover with ENC_NONE"
753
+ Regexp.new(node[1], Regexp::ENC_NONE)
754
+ end
755
+ end
756
+ end
757
+ when :dstr then
758
+ if options =~ /o/ then
759
+ node.sexp_type = :dregx_once
760
+ else
761
+ node.sexp_type = :dregx
762
+ end
763
+ node << o if o and o != 0
764
+ else
765
+ node = s(:dregx, '', node);
766
+ node.sexp_type = :dregx_once if options =~ /o/
767
+ node << o if o and o != 0
768
+ end
769
+
770
+ node
771
+ end
772
+
773
+ def new_rescue body, resbody
774
+ s(:rescue, body, resbody)
775
+ end
776
+
777
+ def new_resbody cond, body
778
+ if body && body.sexp_type == :block then
779
+ body.shift # remove block and splat it in directly
780
+ else
781
+ body = [body]
782
+ end
783
+ s(:resbody, cond, *body).line cond.line
784
+ end
785
+
786
+ def new_sclass val
787
+ recv, in_def, in_single, body = val[3], val[4], val[6], val[7]
788
+
789
+ result = s(:sclass, recv)
790
+
791
+ if body then
792
+ if body.sexp_type == :block then
793
+ result.push(*body.sexp_body)
794
+ else
795
+ result.push body
796
+ end
797
+ end
798
+
799
+ result.line = val[2]
800
+ self.in_def = in_def
801
+ self.in_single = in_single
802
+ result
803
+ end
804
+
805
+ def new_string val
806
+ str = val[0]
807
+ str.force_encoding("ASCII-8BIT") unless str.valid_encoding?
808
+ result = s(:str, str)
809
+ self.lexer.fixup_lineno str.count("\n")
810
+ result
811
+ end
812
+
813
+ def new_qword_list_entry val
814
+ str = val[1]
815
+ str.force_encoding("ASCII-8BIT") unless str.valid_encoding?
816
+ result = s(:str, str)
817
+ self.lexer.fixup_lineno
818
+ result
819
+ end
820
+
821
+ def new_qword_list
822
+ result = s(:array)
823
+ self.lexer.fixup_lineno
824
+ result
825
+ end
826
+
827
+ def new_word_list
828
+ result = s(:array)
829
+ self.lexer.fixup_lineno
830
+ result
831
+ end
832
+
833
+ def new_word_list_entry val
834
+ result = val[1].sexp_type == :evstr ? s(:dstr, "", val[1]) : val[1]
835
+ self.lexer.fixup_lineno
836
+ result
837
+ end
838
+
839
+ def new_qsym_list
840
+ result = s(:array)
841
+ self.lexer.fixup_lineno
842
+ result
843
+ end
844
+
845
+ def new_qsym_list_entry val
846
+ result = s(:lit, val[1].to_sym)
847
+ self.lexer.fixup_lineno
848
+ result
849
+ end
850
+
851
+ def new_symbol_list
852
+ result = s(:array)
853
+ self.lexer.fixup_lineno
854
+ result
855
+ end
856
+
857
+ def new_symbol_list_entry val
858
+ _list, sym, _nil = val # TODO: use _list
859
+ result = val[1]
860
+
861
+ result ||= s(:str, "")
862
+
863
+ case sym.sexp_type
864
+ when :dstr then
865
+ sym.sexp_type = :dsym
866
+ when :str then
867
+ sym = s(:lit, sym.last.to_sym)
868
+ else
869
+ sym = s(:dsym, "", sym || s(:str, ""))
870
+ end
871
+ self.lexer.fixup_lineno
872
+ sym
873
+ end
874
+
875
+ def new_super args
876
+ if args && args.node_type == :block_pass then
877
+ s(:super, args)
878
+ else
879
+ args ||= s(:arglist)
880
+ s(:super, *args.sexp_body)
881
+ end
882
+ end
883
+
884
+ def new_undef n, m = nil
885
+ if m then
886
+ block_append(n, s(:undef, m))
887
+ else
888
+ s(:undef, n)
889
+ end
890
+ end
891
+
892
+ def new_until block, expr, pre
893
+ new_until_or_while :until, block, expr, pre
894
+ end
895
+
896
+ def new_until_or_while type, block, expr, pre
897
+ other = type == :until ? :while : :until
898
+ line = [block && block.line, expr.line].compact.min
899
+ block, pre = block.last, false if block && block.sexp_type == :begin
900
+
901
+ expr = cond expr
902
+
903
+ result = unless expr.sexp_type == :not and canonicalize_conditions then
904
+ s(type, expr, block, pre)
905
+ else
906
+ s(other, expr.last, block, pre)
907
+ end
908
+
909
+ result.line = line
910
+ result
911
+ end
912
+
913
+ def new_when cond, body
914
+ s(:when, cond, body)
915
+ end
916
+
917
+ def new_while block, expr, pre
918
+ new_until_or_while :while, block, expr, pre
919
+ end
920
+
921
+ def new_xstring str
922
+ if str then
923
+ case str.sexp_type
924
+ when :str
925
+ str.sexp_type = :xstr
926
+ when :dstr
927
+ str.sexp_type = :dxstr
928
+ else
929
+ str = s(:dxstr, '', str)
930
+ end
931
+ str
932
+ else
933
+ s(:xstr, '')
934
+ end
935
+ end
936
+
937
+ def new_yield args = nil
938
+ # TODO: raise args.inspect unless [:arglist].include? args.first # HACK
939
+ raise "write a test 4" if args && args.node_type == :block_pass
940
+ raise SyntaxError, "Block argument should not be given." if
941
+ args && args.node_type == :block_pass
942
+
943
+ args ||= s(:arglist)
944
+
945
+ args.sexp_type = :arglist if [:call_args, :array].include? args.sexp_type
946
+ args = s(:arglist, args) unless args.sexp_type == :arglist
947
+
948
+ return s(:yield, *args.sexp_body)
949
+ end
950
+
951
+ def next_token
952
+ token = self.lexer.next_token
953
+
954
+ if token and token.first != RubyLexer::EOF then
955
+ return token
956
+ else
957
+ return [false, '$end']
958
+ end
959
+ end
960
+
961
+ def new_assign lhs, rhs
962
+ return nil unless lhs
963
+
964
+ rhs = value_expr rhs
965
+
966
+ case lhs.sexp_type
967
+ when :lasgn, :iasgn, :cdecl, :cvdecl, :gasgn, :cvasgn, :attrasgn, :safe_attrasgn then
968
+ lhs << rhs
969
+ when :const then
970
+ lhs.sexp_type = :cdecl
971
+ lhs << rhs
972
+ else
973
+ raise "unknown lhs #{lhs.inspect} w/ #{rhs.inspect}"
974
+ end
975
+
976
+ lhs
977
+ end
978
+
979
+ ##
980
+ # Returns a UTF-8 encoded string after processing BOMs and magic
981
+ # encoding comments.
982
+ #
983
+ # Holy crap... ok. Here goes:
984
+ #
985
+ # Ruby's file handling and encoding support is insane. We need to be
986
+ # able to lex a file. The lexer file is explicitly UTF-8 to make
987
+ # things cleaner. This allows us to deal with extended chars in
988
+ # class and method names. In order to do this, we need to encode all
989
+ # input source files as UTF-8. First, we look for a UTF-8 BOM by
990
+ # looking at the first line while forcing its encoding to
991
+ # ASCII-8BIT. If we find a BOM, we strip it and set the expected
992
+ # encoding to UTF-8. Then, we search for a magic encoding comment.
993
+ # If found, it overrides the BOM. Finally, we force the encoding of
994
+ # the input string to whatever was found, and then encode that to
995
+ # UTF-8 for compatibility with the lexer.
996
+
997
+ def handle_encoding str
998
+ str = str.dup
999
+ has_enc = str.respond_to? :encoding
1000
+ encoding = nil
1001
+
1002
+ header = str.each_line.first(2)
1003
+ header.map! { |s| s.force_encoding "ASCII-8BIT" } if has_enc
1004
+
1005
+ first = header.first || ""
1006
+ encoding, str = "utf-8", str[3..-1] if first =~ /\A\xEF\xBB\xBF/
1007
+
1008
+ encoding = $1.strip if header.find { |s|
1009
+ s[/^#.*?-\*-.*?coding:\s*([^ ;]+).*?-\*-/, 1] ||
1010
+ s[/^#.*(?:en)?coding(?:\s*[:=])\s*([\w-]+)/, 1]
1011
+ }
1012
+
1013
+ if encoding then
1014
+ if has_enc then
1015
+ encoding.sub!(/utf-8-.+$/, 'utf-8') # HACK for stupid emacs formats
1016
+ hack_encoding str, encoding
1017
+ else
1018
+ warn "Skipping magic encoding comment"
1019
+ end
1020
+ else
1021
+ # nothing specified... ugh. try to encode as utf-8
1022
+ hack_encoding str if has_enc
1023
+ end
1024
+
1025
+ str
1026
+ end
1027
+
1028
+ def hack_encoding str, extra = nil
1029
+ encodings = ENCODING_ORDER.dup
1030
+ encodings.unshift(extra) unless extra.nil?
1031
+
1032
+ # terrible, horrible, no good, very bad, last ditch effort.
1033
+ encodings.each do |enc|
1034
+ begin
1035
+ str.force_encoding enc
1036
+ if str.valid_encoding? then
1037
+ str.encode! Encoding::UTF_8
1038
+ break
1039
+ end
1040
+ rescue Encoding::InvalidByteSequenceError
1041
+ # do nothing
1042
+ rescue Encoding::UndefinedConversionError
1043
+ # do nothing
1044
+ end
1045
+ end
1046
+
1047
+ # no amount of pain is enough for you.
1048
+ raise "Bad encoding. Need a magic encoding comment." unless
1049
+ str.encoding.name == "UTF-8"
1050
+ end
1051
+
1052
+ ##
1053
+ # Parse +str+ at path +file+ and return a sexp. Raises
1054
+ # Timeout::Error if it runs for more than +time+ seconds.
1055
+
1056
+ def process(str, file = "(string)", time = 10)
1057
+ Timeout.timeout time do
1058
+ raise "bad val: #{str.inspect}" unless String === str
1059
+
1060
+ str = handle_encoding str
1061
+
1062
+ self.file = file.dup
1063
+
1064
+ @yydebug = ENV.has_key? 'DEBUG'
1065
+
1066
+ # HACK -- need to get tests passing more than have graceful code
1067
+ self.lexer.ss = RPStringScanner.new str
1068
+
1069
+ do_parse
1070
+ end
1071
+ end
1072
+
1073
+ alias :parse :process
1074
+
1075
+ def remove_begin node
1076
+ oldnode = node
1077
+ if node and node.sexp_type == :begin and node.size == 2 then
1078
+ node = node.last
1079
+ node.line = oldnode.line
1080
+ end
1081
+ node
1082
+ end
1083
+
1084
+ def reset
1085
+ lexer.reset
1086
+ self.in_def = false
1087
+ self.in_single = 0
1088
+ self.env.reset
1089
+ self.comments.clear
1090
+ end
1091
+
1092
+ def block_dup_check call_or_args, block
1093
+ syntax_error "Both block arg and actual block given." if
1094
+ block and call_or_args.block_pass?
1095
+ end
1096
+
1097
+ def inverted? val
1098
+ [:return, :next, :break, :yield].include? val[0].sexp_type
1099
+ end
1100
+
1101
+ def invert_block_call val
1102
+ (type, call), iter = val
1103
+
1104
+ iter.insert 1, call
1105
+
1106
+ [iter, s(type)]
1107
+ end
1108
+
1109
+ def ret_args node
1110
+ if node then
1111
+ raise "write a test 5" if node.sexp_type == :block_pass
1112
+
1113
+ raise SyntaxError, "block argument should not be given" if
1114
+ node.sexp_type == :block_pass
1115
+
1116
+ node.sexp_type = :array if node.sexp_type == :call_args
1117
+ node = node.last if node.sexp_type == :array && node.size == 2
1118
+
1119
+ # HACK matz wraps ONE of the FOUR splats in a newline to
1120
+ # distinguish. I use paren for now. ugh
1121
+ node = s(:svalue, node) if node.sexp_type == :splat and not node.paren
1122
+ node.sexp_type = :svalue if node.sexp_type == :arglist && node[1].sexp_type == :splat
1123
+ end
1124
+
1125
+ node
1126
+ end
1127
+
1128
+ def s(*args)
1129
+ result = Sexp.new(*args)
1130
+ result.line ||= lexer.lineno if lexer.ss # otherwise...
1131
+ result.file = self.file
1132
+ result
1133
+ end
1134
+
1135
+ def value_expr oldnode # HACK: much more to do
1136
+ node = remove_begin oldnode
1137
+ node.line = oldnode.line if oldnode
1138
+ node[2] = value_expr node[2] if node and node.sexp_type == :if
1139
+ node
1140
+ end
1141
+
1142
+ def void_stmts node
1143
+ return nil unless node
1144
+ return node unless node.sexp_type == :block
1145
+
1146
+ if node.respond_to? :sexp_body= then
1147
+ node.sexp_body = node.sexp_body.map { |n| remove_begin n }
1148
+ else
1149
+ node[1..-1] = node[1..-1].map { |n| remove_begin(n) }
1150
+ end
1151
+
1152
+ node
1153
+ end
1154
+
1155
+ def warning s
1156
+ # do nothing for now
1157
+ end
1158
+
1159
+ alias yyerror syntax_error
1160
+
1161
+ def on_error(et, ev, values)
1162
+ super
1163
+ rescue Racc::ParseError => e
1164
+ # I don't like how the exception obscures the error message
1165
+ e.message.replace "%s:%p :: %s" % [self.file, lexer.lineno, e.message.strip]
1166
+ warn e.message if $DEBUG
1167
+ raise
1168
+ end
1169
+
1170
+ class Keyword
1171
+ class KWtable
1172
+ attr_accessor :name, :state, :id0, :id1
1173
+ def initialize(name, id=[], state=nil)
1174
+ @name = name
1175
+ @id0, @id1 = id
1176
+ @state = state
1177
+ end
1178
+ end
1179
+
1180
+ ##
1181
+ # :stopdoc:
1182
+ #
1183
+ # :expr_beg = ignore newline, +/- is a sign.
1184
+ # :expr_end = newline significant, +/- is an operator.
1185
+ # :expr_endarg = ditto, and unbound braces.
1186
+ # :expr_endfn = ditto, and unbound braces.
1187
+ # :expr_arg = newline significant, +/- is an operator.
1188
+ # :expr_cmdarg = ditto
1189
+ # :expr_mid = ditto
1190
+ # :expr_fname = ignore newline, no reserved words.
1191
+ # :expr_dot = right after . or ::, no reserved words.
1192
+ # :expr_class = immediate after class, no here document.
1193
+ # :expr_label = flag bit, label is allowed.
1194
+ # :expr_labeled = flag bit, just after a label.
1195
+ # :expr_fitem = symbol literal as FNAME.
1196
+ # :expr_value = :expr_beg -- work to remove. Need multi-state support.
1197
+
1198
+ wordlist = [
1199
+ ["alias", [:kALIAS, :kALIAS ], :expr_fname ],
1200
+ ["and", [:kAND, :kAND ], :expr_beg ],
1201
+ ["begin", [:kBEGIN, :kBEGIN ], :expr_beg ],
1202
+ ["break", [:kBREAK, :kBREAK ], :expr_mid ],
1203
+ ["case", [:kCASE, :kCASE ], :expr_beg ],
1204
+ ["class", [:kCLASS, :kCLASS ], :expr_class ],
1205
+ ["def", [:kDEF, :kDEF ], :expr_fname ],
1206
+ ["defined?", [:kDEFINED, :kDEFINED ], :expr_arg ],
1207
+ ["do", [:kDO, :kDO ], :expr_beg ],
1208
+ ["else", [:kELSE, :kELSE ], :expr_beg ],
1209
+ ["elsif", [:kELSIF, :kELSIF ], :expr_beg ],
1210
+ ["end", [:kEND, :kEND ], :expr_end ],
1211
+ ["ensure", [:kENSURE, :kENSURE ], :expr_beg ],
1212
+ ["false", [:kFALSE, :kFALSE ], :expr_end ],
1213
+ ["for", [:kFOR, :kFOR ], :expr_beg ],
1214
+ ["if", [:kIF, :kIF_MOD ], :expr_beg ],
1215
+ ["in", [:kIN, :kIN ], :expr_beg ],
1216
+ ["module", [:kMODULE, :kMODULE ], :expr_beg ],
1217
+ ["next", [:kNEXT, :kNEXT ], :expr_mid ],
1218
+ ["nil", [:kNIL, :kNIL ], :expr_end ],
1219
+ ["not", [:kNOT, :kNOT ], :expr_arg ],
1220
+ ["or", [:kOR, :kOR ], :expr_beg ],
1221
+ ["redo", [:kREDO, :kREDO ], :expr_end ],
1222
+ ["rescue", [:kRESCUE, :kRESCUE_MOD ], :expr_mid ],
1223
+ ["retry", [:kRETRY, :kRETRY ], :expr_end ],
1224
+ ["return", [:kRETURN, :kRETURN ], :expr_mid ],
1225
+ ["self", [:kSELF, :kSELF ], :expr_end ],
1226
+ ["super", [:kSUPER, :kSUPER ], :expr_arg ],
1227
+ ["then", [:kTHEN, :kTHEN ], :expr_beg ],
1228
+ ["true", [:kTRUE, :kTRUE ], :expr_end ],
1229
+ ["undef", [:kUNDEF, :kUNDEF ], :expr_fname ],
1230
+ ["unless", [:kUNLESS, :kUNLESS_MOD ], :expr_beg ],
1231
+ ["until", [:kUNTIL, :kUNTIL_MOD ], :expr_beg ],
1232
+ ["when", [:kWHEN, :kWHEN ], :expr_beg ],
1233
+ ["while", [:kWHILE, :kWHILE_MOD ], :expr_beg ],
1234
+ ["yield", [:kYIELD, :kYIELD ], :expr_arg ],
1235
+ ["BEGIN", [:klBEGIN, :klBEGIN ], :expr_end ],
1236
+ ["END", [:klEND, :klEND ], :expr_end ],
1237
+ ["__FILE__", [:k__FILE__, :k__FILE__ ], :expr_end ],
1238
+ ["__LINE__", [:k__LINE__, :k__LINE__ ], :expr_end ],
1239
+ ["__ENCODING__", [:k__ENCODING__, :k__ENCODING__], :expr_end],
1240
+ ].map { |args| KWtable.new(*args) }
1241
+
1242
+ # :startdoc:
1243
+
1244
+ WORDLIST = Hash[*wordlist.map { |o| [o.name, o] }.flatten]
1245
+
1246
+ def self.keyword str
1247
+ WORDLIST[str]
1248
+ end
1249
+ end
1250
+
1251
+ class Environment
1252
+ attr_reader :env, :dyn
1253
+
1254
+ def [] k
1255
+ self.all[k]
1256
+ end
1257
+
1258
+ def []= k, v
1259
+ raise "no" if v == true
1260
+ self.current[k] = v
1261
+ end
1262
+
1263
+ def all
1264
+ idx = @dyn.index(false) || 0
1265
+ @env[0..idx].reverse.inject { |env, scope| env.merge scope }
1266
+ end
1267
+
1268
+ def current
1269
+ @env.first
1270
+ end
1271
+
1272
+ def extend dyn = false
1273
+ @dyn.unshift dyn
1274
+ @env.unshift({})
1275
+ end
1276
+
1277
+ def initialize dyn = false
1278
+ @dyn = []
1279
+ @env = []
1280
+ self.reset
1281
+ end
1282
+
1283
+ def reset
1284
+ @dyn.clear
1285
+ @env.clear
1286
+ self.extend
1287
+ end
1288
+
1289
+ def unextend
1290
+ @dyn.shift
1291
+ @env.shift
1292
+ raise "You went too far unextending env" if @env.empty?
1293
+ end
1294
+ end
1295
+
1296
+ class StackState
1297
+ attr_reader :name
1298
+ attr_reader :stack
1299
+ attr_accessor :debug
1300
+
1301
+ def initialize name, debug=false
1302
+ @name = name
1303
+ @stack = [false]
1304
+ @debug = debug
1305
+ end
1306
+
1307
+ def reset
1308
+ @stack = [false]
1309
+ log :reset if debug
1310
+ end
1311
+
1312
+ def inspect
1313
+ "StackState(#{@name}, #{@stack.inspect})"
1314
+ end
1315
+
1316
+ def is_in_state
1317
+ log :is_in_state if debug
1318
+ @stack.last
1319
+ end
1320
+
1321
+ def lexpop
1322
+ raise if @stack.size == 0
1323
+ a = @stack.pop
1324
+ b = @stack.pop
1325
+ @stack.push(a || b)
1326
+ log :lexpop if debug
1327
+ end
1328
+
1329
+ def log action
1330
+ c = caller[1]
1331
+ c = caller[2] if c =~ /expr_result/
1332
+ warn "%s_stack.%s: %p at %s" % [name, action, @stack, c.clean_caller]
1333
+ nil
1334
+ end
1335
+
1336
+ def pop
1337
+ r = @stack.pop
1338
+ @stack.push false if @stack.empty?
1339
+ log :pop if debug
1340
+ r
1341
+ end
1342
+
1343
+ def push val
1344
+ @stack.push val
1345
+ log :push if debug
1346
+ end
1347
+
1348
+ def store base = false
1349
+ result = @stack.dup
1350
+ @stack.replace [base]
1351
+ log :store if debug
1352
+ result
1353
+ end
1354
+
1355
+ def restore oldstate
1356
+ @stack.replace oldstate
1357
+ log :restore if debug
1358
+ end
1359
+ end
1360
+ end