ruby-lint 0.0.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.asc +14 -14
  3. data/.gitignore +1 -0
  4. data/.yardopts +1 -1
  5. data/Gemfile +3 -3
  6. data/MANIFEST +16 -3
  7. data/benchmark/virtual_machine.rb +17 -0
  8. data/checksum/ruby-lint-0.0.5.gem.sha512 +1 -0
  9. data/doc/changelog.md +42 -0
  10. data/doc/configuration.md +133 -13
  11. data/lib/ruby-lint/analysis/shadowing_variables.rb +8 -14
  12. data/lib/ruby-lint/analysis/unused_variables.rb +17 -0
  13. data/lib/ruby-lint/ast/node.rb +18 -3
  14. data/lib/ruby-lint/cache.rb +121 -0
  15. data/lib/ruby-lint/cache_entry.rb +44 -0
  16. data/lib/ruby-lint/cli/analyze.rb +37 -18
  17. data/lib/ruby-lint/cli/plot.rb +94 -0
  18. data/lib/ruby-lint/cli.rb +1 -0
  19. data/lib/ruby-lint/configuration.rb +48 -3
  20. data/lib/ruby-lint/definition/ruby_method.rb +28 -1
  21. data/lib/ruby-lint/definition/ruby_object.rb +37 -3
  22. data/lib/ruby-lint/definition_builder/ruby_method.rb +4 -1
  23. data/lib/ruby-lint/definition_builder/ruby_module.rb +4 -1
  24. data/lib/ruby-lint/definition_generator.rb +3 -2
  25. data/lib/ruby-lint/definitions/core/arg0.rb +3 -1
  26. data/lib/ruby-lint/definitions/core/argf.rb +3 -1
  27. data/lib/ruby-lint/definitions/core/argument_error.rb +3 -1
  28. data/lib/ruby-lint/definitions/core/argv.rb +3 -1
  29. data/lib/ruby-lint/definitions/core/array.rb +3 -1
  30. data/lib/ruby-lint/definitions/core/autoload.rb +3 -1
  31. data/lib/ruby-lint/definitions/core/basic_object.rb +2 -0
  32. data/lib/ruby-lint/definitions/core/bignum.rb +3 -1
  33. data/lib/ruby-lint/definitions/core/binding.rb +3 -1
  34. data/lib/ruby-lint/definitions/core/class.rb +2 -0
  35. data/lib/ruby-lint/definitions/core/comparable.rb +3 -1
  36. data/lib/ruby-lint/definitions/core/complex.rb +3 -1
  37. data/lib/ruby-lint/definitions/core/condition_variable.rb +3 -1
  38. data/lib/ruby-lint/definitions/core/continuation.rb +3 -1
  39. data/lib/ruby-lint/definitions/core/data.rb +3 -1
  40. data/lib/ruby-lint/definitions/core/date.rb +3 -1
  41. data/lib/ruby-lint/definitions/core/date_time.rb +3 -1
  42. data/lib/ruby-lint/definitions/core/default_record_separator.rb +3 -1
  43. data/lib/ruby-lint/definitions/core/digest.rb +3 -1
  44. data/lib/ruby-lint/definitions/core/dir.rb +3 -1
  45. data/lib/ruby-lint/definitions/core/encoding.rb +3 -1
  46. data/lib/ruby-lint/definitions/core/encoding_error.rb +3 -1
  47. data/lib/ruby-lint/definitions/core/enumerable.rb +3 -1
  48. data/lib/ruby-lint/definitions/core/enumerator.rb +3 -1
  49. data/lib/ruby-lint/definitions/core/env.rb +4 -1
  50. data/lib/ruby-lint/definitions/core/eoferror.rb +3 -1
  51. data/lib/ruby-lint/definitions/core/erb.rb +2 -0
  52. data/lib/ruby-lint/definitions/core/errno.rb +3 -1
  53. data/lib/ruby-lint/definitions/core/etc.rb +3 -1
  54. data/lib/ruby-lint/definitions/core/exception.rb +3 -1
  55. data/lib/ruby-lint/definitions/core/false.rb +3 -1
  56. data/lib/ruby-lint/definitions/core/false_class.rb +3 -1
  57. data/lib/ruby-lint/definitions/core/fatal_error.rb +3 -1
  58. data/lib/ruby-lint/definitions/core/fiber.rb +3 -1
  59. data/lib/ruby-lint/definitions/core/fiber_error.rb +3 -1
  60. data/lib/ruby-lint/definitions/core/file.rb +3 -1
  61. data/lib/ruby-lint/definitions/core/file_list.rb +3 -1
  62. data/lib/ruby-lint/definitions/core/file_test.rb +3 -1
  63. data/lib/ruby-lint/definitions/core/file_utils.rb +3 -1
  64. data/lib/ruby-lint/definitions/core/fixnum.rb +3 -1
  65. data/lib/ruby-lint/definitions/core/float.rb +3 -1
  66. data/lib/ruby-lint/definitions/core/float_domain_error.rb +3 -1
  67. data/lib/ruby-lint/definitions/core/gc.rb +3 -1
  68. data/lib/ruby-lint/definitions/core/gem.rb +3 -1
  69. data/lib/ruby-lint/definitions/core/hash.rb +3 -1
  70. data/lib/ruby-lint/definitions/core/immediate_value.rb +3 -1
  71. data/lib/ruby-lint/definitions/core/index_error.rb +3 -1
  72. data/lib/ruby-lint/definitions/core/integer.rb +3 -1
  73. data/lib/ruby-lint/definitions/core/interrupt.rb +3 -1
  74. data/lib/ruby-lint/definitions/core/io.rb +3 -1
  75. data/lib/ruby-lint/definitions/core/ioerror.rb +3 -1
  76. data/lib/ruby-lint/definitions/core/kernel.rb +2 -0
  77. data/lib/ruby-lint/definitions/core/key_error.rb +3 -1
  78. data/lib/ruby-lint/definitions/core/load_error.rb +3 -1
  79. data/lib/ruby-lint/definitions/core/local_jump_error.rb +3 -1
  80. data/lib/ruby-lint/definitions/core/marshal.rb +3 -1
  81. data/lib/ruby-lint/definitions/core/match_data.rb +3 -1
  82. data/lib/ruby-lint/definitions/core/math.rb +3 -1
  83. data/lib/ruby-lint/definitions/core/memory_segmention_error.rb +3 -1
  84. data/lib/ruby-lint/definitions/core/method.rb +3 -1
  85. data/lib/ruby-lint/definitions/core/module.rb +2 -0
  86. data/lib/ruby-lint/definitions/core/monitor.rb +3 -1
  87. data/lib/ruby-lint/definitions/core/monitor_mixin.rb +3 -1
  88. data/lib/ruby-lint/definitions/core/mutex.rb +3 -1
  89. data/lib/ruby-lint/definitions/core/name_error.rb +3 -1
  90. data/lib/ruby-lint/definitions/core/nil.rb +3 -1
  91. data/lib/ruby-lint/definitions/core/nil_class.rb +3 -1
  92. data/lib/ruby-lint/definitions/core/no_memory_error.rb +3 -1
  93. data/lib/ruby-lint/definitions/core/no_method_error.rb +3 -1
  94. data/lib/ruby-lint/definitions/core/not_implemented_error.rb +3 -1
  95. data/lib/ruby-lint/definitions/core/numeric.rb +3 -1
  96. data/lib/ruby-lint/definitions/core/object.rb +3 -1
  97. data/lib/ruby-lint/definitions/core/object_space.rb +3 -1
  98. data/lib/ruby-lint/definitions/core/open_struct.rb +3 -1
  99. data/lib/ruby-lint/definitions/core/option_parser.rb +3 -1
  100. data/lib/ruby-lint/definitions/core/precision.rb +3 -1
  101. data/lib/ruby-lint/definitions/core/primitive_failure.rb +3 -1
  102. data/lib/ruby-lint/definitions/core/proc.rb +3 -1
  103. data/lib/ruby-lint/definitions/core/process.rb +3 -1
  104. data/lib/ruby-lint/definitions/core/queue.rb +3 -1
  105. data/lib/ruby-lint/definitions/core/rake.rb +3 -1
  106. data/lib/ruby-lint/definitions/core/rake_file_utils.rb +3 -1
  107. data/lib/ruby-lint/definitions/core/rakeversion.rb +3 -1
  108. data/lib/ruby-lint/definitions/core/random.rb +3 -1
  109. data/lib/ruby-lint/definitions/core/range.rb +3 -1
  110. data/lib/ruby-lint/definitions/core/range_error.rb +3 -1
  111. data/lib/ruby-lint/definitions/core/rational.rb +3 -1
  112. data/lib/ruby-lint/definitions/core/rb_config.rb +3 -1
  113. data/lib/ruby-lint/definitions/core/regexp.rb +3 -1
  114. data/lib/ruby-lint/definitions/core/regexp_error.rb +3 -1
  115. data/lib/ruby-lint/definitions/core/ruby_copyright.rb +3 -1
  116. data/lib/ruby-lint/definitions/core/ruby_description.rb +3 -1
  117. data/lib/ruby-lint/definitions/core/ruby_engine.rb +3 -1
  118. data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +3 -1
  119. data/lib/ruby-lint/definitions/core/ruby_platform.rb +3 -1
  120. data/lib/ruby-lint/definitions/core/ruby_release_date.rb +3 -1
  121. data/lib/ruby-lint/definitions/core/ruby_version.rb +3 -1
  122. data/lib/ruby-lint/definitions/core/runtime_error.rb +3 -1
  123. data/lib/ruby-lint/definitions/core/scan_error.rb +3 -1
  124. data/lib/ruby-lint/definitions/core/script_error.rb +3 -1
  125. data/lib/ruby-lint/definitions/core/security_error.rb +3 -1
  126. data/lib/ruby-lint/definitions/core/shellwords.rb +3 -1
  127. data/lib/ruby-lint/definitions/core/signal.rb +3 -1
  128. data/lib/ruby-lint/definitions/core/signal_exception.rb +3 -1
  129. data/lib/ruby-lint/definitions/core/singleton.rb +3 -1
  130. data/lib/ruby-lint/definitions/core/sized_queue.rb +3 -1
  131. data/lib/ruby-lint/definitions/core/standard_error.rb +3 -1
  132. data/lib/ruby-lint/definitions/core/stderr.rb +2 -0
  133. data/lib/ruby-lint/definitions/core/stdin.rb +2 -0
  134. data/lib/ruby-lint/definitions/core/stdout.rb +2 -0
  135. data/lib/ruby-lint/definitions/core/stop_iteration.rb +3 -1
  136. data/lib/ruby-lint/definitions/core/string.rb +3 -1
  137. data/lib/ruby-lint/definitions/core/string_io.rb +3 -1
  138. data/lib/ruby-lint/definitions/core/string_scanner.rb +3 -1
  139. data/lib/ruby-lint/definitions/core/struct.rb +3 -1
  140. data/lib/ruby-lint/definitions/core/syck.rb +3 -1
  141. data/lib/ruby-lint/definitions/core/symbol.rb +3 -1
  142. data/lib/ruby-lint/definitions/core/syntax_error.rb +3 -1
  143. data/lib/ruby-lint/definitions/core/system_call_error.rb +3 -1
  144. data/lib/ruby-lint/definitions/core/system_exit.rb +3 -1
  145. data/lib/ruby-lint/definitions/core/system_stack_error.rb +3 -1
  146. data/lib/ruby-lint/definitions/core/thread.rb +3 -1
  147. data/lib/ruby-lint/definitions/core/thread_error.rb +3 -1
  148. data/lib/ruby-lint/definitions/core/thread_group.rb +3 -1
  149. data/lib/ruby-lint/definitions/core/time.rb +3 -1
  150. data/lib/ruby-lint/definitions/core/toplevel_binding.rb +3 -1
  151. data/lib/ruby-lint/definitions/core/true.rb +3 -1
  152. data/lib/ruby-lint/definitions/core/true_class.rb +3 -1
  153. data/lib/ruby-lint/definitions/core/type_error.rb +3 -1
  154. data/lib/ruby-lint/definitions/core/unbound_method.rb +3 -1
  155. data/lib/ruby-lint/definitions/core/unmarshalable.rb +3 -1
  156. data/lib/ruby-lint/definitions/core/unsupported_library_error.rb +3 -1
  157. data/lib/ruby-lint/definitions/core/weak_ref.rb +3 -1
  158. data/lib/ruby-lint/definitions/core/yaml.rb +1 -0
  159. data/lib/ruby-lint/definitions/core/zero_division_error.rb +3 -1
  160. data/lib/ruby-lint/definitions/core/zlib.rb +8840 -0
  161. data/lib/ruby-lint/definitions/rails/abstract_controller.rb +1 -0
  162. data/lib/ruby-lint/definitions/rails/action_controller.rb +1 -0
  163. data/lib/ruby-lint/definitions/rails/action_dispatch.rb +1 -0
  164. data/lib/ruby-lint/definitions/rails/action_mailer.rb +1 -0
  165. data/lib/ruby-lint/definitions/rails/action_pack.rb +1 -0
  166. data/lib/ruby-lint/definitions/rails/action_view.rb +1 -0
  167. data/lib/ruby-lint/definitions/rails/active_model.rb +1 -0
  168. data/lib/ruby-lint/definitions/rails/active_record.rb +1 -0
  169. data/lib/ruby-lint/definitions/rails/active_support.rb +1 -0
  170. data/lib/ruby-lint/definitions/rails/arel.rb +1 -0
  171. data/lib/ruby-lint/definitions/rails/rails.rb +1 -0
  172. data/lib/ruby-lint/definitions/rails/sprockets.rb +1 -0
  173. data/lib/ruby-lint/file_scanner.rb +2 -0
  174. data/lib/ruby-lint/iterator.rb +21 -12
  175. data/lib/ruby-lint/method_call_info.rb +31 -0
  176. data/lib/ruby-lint/node_hash.rb +105 -0
  177. data/lib/ruby-lint/parser.rb +4 -2
  178. data/lib/ruby-lint/runner.rb +62 -6
  179. data/lib/ruby-lint/template/definition.erb +2 -0
  180. data/lib/ruby-lint/version.rb +1 -1
  181. data/lib/ruby-lint/virtual_machine.rb +75 -43
  182. data/lib/ruby-lint.rb +20 -2
  183. data/profiling/virtual_machine.rb +20 -0
  184. data/ruby-lint.gemspec +2 -1
  185. data/spec/fixtures/complex/rcap.rb +29 -0
  186. data/spec/fixtures/complex/slop.rb +21 -0
  187. data/spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb +6 -0
  188. data/spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb +6 -0
  189. data/spec/ruby-lint/analysis/unused_variables_spec.rb +114 -0
  190. data/spec/ruby-lint/cache_entry_spec.rb +25 -0
  191. data/spec/ruby-lint/cache_spec.rb +53 -0
  192. data/spec/ruby-lint/definition/ruby_method_spec.rb +4 -4
  193. data/spec/ruby-lint/definition/ruby_object_spec.rb +33 -0
  194. data/spec/ruby-lint/iterator_spec.rb +15 -0
  195. data/spec/ruby-lint/node_hash_spec.rb +56 -0
  196. data/spec/ruby-lint/runner_spec.rb +6 -1
  197. data/spec/ruby-lint/virtual_machine/assignments/variables_spec.rb +2 -2
  198. data/spec/ruby-lint/virtual_machine/location_spec.rb +64 -0
  199. data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +64 -0
  200. data/spec/spec_helper.rb +7 -0
  201. data/task/generate.rake +1 -1
  202. data.tar.gz.asc +14 -14
  203. metadata +34 -7
  204. metadata.gz.asc +14 -14
  205. data/debug/memory_usage.rb +0 -14
  206. data/debug/profile.rb +0 -18
  207. data/task/profile.rake +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf30514aa5a1f824fa2dd56dfb776da2f19b02f1
4
- data.tar.gz: 333fe29270d161bba23bbeeb077647eb482758e6
3
+ metadata.gz: fe09b414c536802b61ad8624935086a8a190485e
4
+ data.tar.gz: 38f69287cc16982dee093653557848a8d2ce940d
5
5
  SHA512:
6
- metadata.gz: 68e08f78c67e18632afd43aadd45dd0eb7e95c3abbe505ff1f5fd64bd5c8cc019a3c4f7e22456cee7359acc05188551e60484e4e8ceae5417d5c623ee69f26eb
7
- data.tar.gz: af1bdbb7036b5e2c728a2f31f2dc074baf268f083337f04b4cbc5389db6d6c82e3ed87db8bd7113ea695a947b66b02c28e07726c461453615f98b6326eb2f359
6
+ metadata.gz: 46e3649eb9b98b1deb98c22e38797295b1016caae028eddf3191e1b871bf0381e5bafd02b8fa6c8cdb38c1a5cf8624f020a7dde85946aeb4752b0c8e9b505ab1
7
+ data.tar.gz: 3005aaed981fb405931e820a6e757459651112d83126ad5ec83a2be1373157867a7dd1f7da5ca86e5dd3c7f91adec6283f17daa08e094944f9a0661bb956fa7b
checksums.yaml.gz.asc CHANGED
@@ -1,17 +1,17 @@
1
1
  -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v2.0.21 (GNU/Linux)
2
+ Version: GnuPG v2.0.22 (GNU/Linux)
3
3
 
4
- iQIcBAABAgAGBQJSI1ZdAAoJEPMbESk2SfREreIQAK4KVRJ8W9NfaMaoIAt9PqrK
5
- 9F82AF819tV9Yp8pzv+QhzXeQf/HStRtqGgUu/TeH3OLQ9+i866xTUZPPUtL0WRC
6
- D3YuTRtRcaL6DKei4PwnUkzxr4Vyc+ESZHy0MtR7brYyXntjWAwpgE7scZiP/6h5
7
- lP8LKmGFmdt/cviz03byGFM7AIQ2H7Bn7y6E8Z+SLzSVhgQtuVfvrxrM3CLiTLCB
8
- l3efJyuhWfWnDRWcL6mxDAD3yJmx68v9RnpPF/uDFAf/UxzSCKzxxIgPVqc3GdCL
9
- fyuZhnmYVxkgVdVKx0emEp1uVOP5Ab7CpTQcnQ7SptrgQ726Hllr2hbg5o/Yyc4c
10
- KGcsOsqVbp4ADfuPcBGPBGSNEXsUBWuhCJbLX3L/WpCa+efyDVJ9Q1ibSwo8T1Db
11
- NGcKWE95MEbgwrL2kQVZLWP0+EFK15B5Ejpj4l6wUiKaPphScVwbHbrfVtWT4Ol4
12
- D9G5FFEX5VSYVjJD9md2/IiBsZEtOxn10p+6bYrFZKP1ebcGI+7lIbjuSBv/bsla
13
- HSH1aiF5DyuJo5Sl7gcHkLUJSncyIoRJkYGDeDzXq5X77WK38P7QRgNYUFKeAvn8
14
- IFW4u8nv3RMIuQoPeXDd29OzCz6dwfwpCU0Ru84IBpuxj3FD5Pki4UrjkjE13W30
15
- /kVP2nSbwCKsmcT/G5mp
16
- =ovVB
4
+ iQIcBAABAgAGBQJSWugYAAoJEPMbESk2SfREECsP/0XuJJCH46m/b8fxkAYUf2M3
5
+ GdO8/8hMQDBgBRjx6Q1vvebuJNTl6b5AdEo6LnwbZMYURA/7YGzYDjkk7rUsF9WC
6
+ Zsc5vAfOwGS5bnVpvVqjIiuCt2349lKQyVAmD57270WXKu6QYZJRQ9PQZ+0/BDGQ
7
+ 3X9aOJIURWW1kTRylmYu4ZXHc5s72qGKg2zsJqBcY6GMaeEsv0+578XFuReVcsyY
8
+ xBxdp4GzLE3cK5E5a5JVwmzE5/TNZr9TzktNgqeGOYldKSdENCGkp8M1MfRhlSaN
9
+ Hm5bUtPPkpz2bUVKVN0Ipk79d65Nmk3U28MCbKgSx+w2v6nw+AaU0H/9ktLsf8iO
10
+ q2PLXsk3op/Ds3laTP3OZgKxYoW6jb/Tq4y0sjdcJimZv6ID4BRs95/iCsPsgTi3
11
+ K8uUhOHWb9wYhwB/WbFjIQcLhblgVStekcIUCMgGYGRt1Mv4rc++gMPVCFNgJ3Qa
12
+ zraKQcMB6xASwIcUhzkQ/ritgSev66V6q4iXn+sskEwXXzsaK3jvoWp4dDShMl84
13
+ sKhP+dVdXW7YAjfM1l53YwLvObHaf7u6YbykPv3bKWxrbb9E68OH66x2h1DjBAUR
14
+ 4ssbGFOaXDl6EimYqoWWIaE7FPwt1FMnnoHlXZLOH/zCJkxfnZkLV6PMO8JSpvkV
15
+ zh8/IQvpvhW1oFlhLYV/
16
+ =gb/s
17
17
  -----END PGP SIGNATURE-----
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ coverage
3
3
 
4
4
  pkg
5
5
  Gemfile.lock
6
+ .ruby-lint
data/.yardopts CHANGED
@@ -7,7 +7,7 @@
7
7
  --protected
8
8
  --asset ./doc/css/common.css:css/common.css
9
9
  --asset ./doc/images:images
10
- --exclude lib/ruby-lint/definitions/core
10
+ --exclude lib/ruby-lint/definitions
11
11
  --verbose
12
12
  -
13
13
  ./doc/*.md
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source 'https://rubygems.org/'
2
2
 
3
3
  gemspec
4
4
 
5
- group :profile do
6
- gem 'ruby-prof', :platforms => :mri
7
- end
5
+ gem 'racc', :platforms => :rbx
6
+
7
+ gem 'ruby-prof', :platforms => :mri
data/MANIFEST CHANGED
@@ -8,12 +8,12 @@ LICENSE
8
8
  MANIFEST
9
9
  README.md
10
10
  Rakefile
11
+ benchmark/virtual_machine.rb
11
12
  bin/ruby-lint
12
13
  checksum/.gitkeep
13
14
  checksum/ruby-lint-0.0.3.gem.sha512
14
15
  checksum/ruby-lint-0.0.4.gem.sha512
15
- debug/memory_usage.rb
16
- debug/profile.rb
16
+ checksum/ruby-lint-0.0.5.gem.sha512
17
17
  doc/.gitkeep
18
18
  doc/DCO.md
19
19
  doc/architecture.md
@@ -35,10 +35,13 @@ lib/ruby-lint/analysis/undefined_variables.rb
35
35
  lib/ruby-lint/analysis/unused_variables.rb
36
36
  lib/ruby-lint/ast/builder.rb
37
37
  lib/ruby-lint/ast/node.rb
38
+ lib/ruby-lint/cache.rb
39
+ lib/ruby-lint/cache_entry.rb
38
40
  lib/ruby-lint/cli.rb
39
41
  lib/ruby-lint/cli/analyze.rb
40
42
  lib/ruby-lint/cli/ast.rb
41
43
  lib/ruby-lint/cli/base.rb
44
+ lib/ruby-lint/cli/plot.rb
42
45
  lib/ruby-lint/configuration.rb
43
46
  lib/ruby-lint/constant_loader.rb
44
47
  lib/ruby-lint/default_names.rb
@@ -190,6 +193,7 @@ lib/ruby-lint/definitions/core/unsupported_library_error.rb
190
193
  lib/ruby-lint/definitions/core/weak_ref.rb
191
194
  lib/ruby-lint/definitions/core/yaml.rb
192
195
  lib/ruby-lint/definitions/core/zero_division_error.rb
196
+ lib/ruby-lint/definitions/core/zlib.rb
193
197
  lib/ruby-lint/definitions/global_variables.rb
194
198
  lib/ruby-lint/definitions/rails.rb
195
199
  lib/ruby-lint/definitions/rails/abstract_controller.rb
@@ -222,7 +226,9 @@ lib/ruby-lint/method_call/attribute.rb
222
226
  lib/ruby-lint/method_call/base.rb
223
227
  lib/ruby-lint/method_call/define_method.rb
224
228
  lib/ruby-lint/method_call/include.rb
229
+ lib/ruby-lint/method_call_info.rb
225
230
  lib/ruby-lint/nested_stack.rb
231
+ lib/ruby-lint/node_hash.rb
226
232
  lib/ruby-lint/parser.rb
227
233
  lib/ruby-lint/presenter/json.rb
228
234
  lib/ruby-lint/presenter/text.rb
@@ -234,6 +240,7 @@ lib/ruby-lint/template/scope.rb
234
240
  lib/ruby-lint/variable_predicates.rb
235
241
  lib/ruby-lint/version.rb
236
242
  lib/ruby-lint/virtual_machine.rb
243
+ profiling/virtual_machine.rb
237
244
  ruby-lint.gemspec
238
245
  ruby-lint.yml
239
246
  spec/fixtures/associating.rb
@@ -244,6 +251,8 @@ spec/fixtures/config.yml
244
251
  spec/fixtures/file_scanner/lib/example/recursive/source.rb
245
252
  spec/fixtures/file_scanner/lib/example/recursive/target.rb
246
253
  spec/fixtures/file_scanner/lib/example/user.rb
254
+ spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb
255
+ spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb
247
256
  spec/fixtures/file_scanner/lib/test-dashes/foo.rb
248
257
  spec/fixtures/file_scanner/rails/app/models/example/user.rb
249
258
  spec/fixtures/file_scanner/rails/app/models/user.rb
@@ -262,6 +271,8 @@ spec/ruby-lint/analysis/undefined_methods_spec.rb
262
271
  spec/ruby-lint/analysis/undefined_variables_spec.rb
263
272
  spec/ruby-lint/analysis/unused_variables_spec.rb
264
273
  spec/ruby-lint/ast/node_spec.rb
274
+ spec/ruby-lint/cache_entry_spec.rb
275
+ spec/ruby-lint/cache_spec.rb
265
276
  spec/ruby-lint/cli/analyze_spec.rb
266
277
  spec/ruby-lint/cli/ast_spec.rb
267
278
  spec/ruby-lint/configuration_spec.rb
@@ -281,6 +292,7 @@ spec/ruby-lint/file_scanner_spec.rb
281
292
  spec/ruby-lint/inspector_spec.rb
282
293
  spec/ruby-lint/iterator_spec.rb
283
294
  spec/ruby-lint/nested_stack_spec.rb
295
+ spec/ruby-lint/node_hash_spec.rb
284
296
  spec/ruby-lint/parser_spec.rb
285
297
  spec/ruby-lint/presenter/json_spec.rb
286
298
  spec/ruby-lint/presenter/text_spec.rb
@@ -310,6 +322,8 @@ spec/ruby-lint/virtual_machine/freeze_spec.rb
310
322
  spec/ruby-lint/virtual_machine/global_variables_spec.rb
311
323
  spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb
312
324
  spec/ruby-lint/virtual_machine/interpolation_spec.rb
325
+ spec/ruby-lint/virtual_machine/location_spec.rb
326
+ spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb
313
327
  spec/ruby-lint/virtual_machine/methods/attr_spec.rb
314
328
  spec/ruby-lint/virtual_machine/methods/define_method_spec.rb
315
329
  spec/ruby-lint/virtual_machine/methods/defining_spec.rb
@@ -337,7 +351,6 @@ task/doc.rake
337
351
  task/generate.rake
338
352
  task/graphviz.rake
339
353
  task/manifest.rake
340
- task/profile.rake
341
354
  task/tag.rake
342
355
  task/test.rake
343
356
  task/todo.rake
@@ -0,0 +1,17 @@
1
+ # This benchmarks N runs of the VM and outputs them to the console making it
2
+ # easy to pass the data to tools such as `ministat`
3
+ # (http://www.freebsd.org/cgi/man.cgi?ministat).
4
+
5
+ require_relative '../lib/ruby-lint'
6
+ require 'benchmark'
7
+
8
+ parser = RubyLint::Parser.new
9
+ file = File.expand_path('../../lib/ruby-lint/virtual_machine.rb', __FILE__)
10
+ ast = parser.parse(File.read(file), file)
11
+ amount = 1000
12
+
13
+ amount.times do
14
+ timing = Benchmark.measure { RubyLint::VirtualMachine.new.run(ast) }
15
+
16
+ puts timing.real
17
+ end
@@ -0,0 +1 @@
1
+ dcc8326dec9cc6bdfdcf19e73a1f69172ffcdf4105be974ab644af00a44cd08306569d1001fe5a680e1ed5158bd2b73be6af801df096a037e7e06fcc116dd086
data/doc/changelog.md CHANGED
@@ -5,6 +5,47 @@ This document contains a short summary of the various releases of ruby-lint.
5
5
  For a full list of commits included in each release see the corresponding Git
6
6
  tags (named after the versions).
7
7
 
8
+ ## 0.9.0 - 2013-10-13
9
+
10
+ Although the version number increased by quite a bit this release in itself is
11
+ fairly small. Seeing how the ruby-lint internals are slowly becoming more and
12
+ more stable I'd like the version numbers to correspond with that. I'm not
13
+ jumping to 1.0 right away since I do want to make various changes to the
14
+ internals before I release 1.0.
15
+
16
+ Having said that, this release contains the following:
17
+
18
+ * Caching of ASTs required for finding externally defined constants.
19
+ * An extra CLI command (`plot`) for plotting analysis timings.
20
+ * Method call tracking.
21
+ * Warnings for unused method/block arguments.
22
+ * Support for Rubinius 2.0.
23
+
24
+ The two most noteworthy changes are the caching system and support for method
25
+ call tracking, these are highlighted below.
26
+
27
+ ### Caching
28
+
29
+ In previous releases ruby-lint would re-parse extra files needed (those that
30
+ contain the definitions of referenced constants) every time you'd analyze a
31
+ file. This was rather problematic since [parser][parser] sadly isn't the
32
+ fastest kid on the block. By caching the resulting ASTs performance of the same
33
+ file (assuming it doesn't change between runs) can be increased drastically. If
34
+ the analyzed file or an external one is changed the cache is invalidated
35
+ automatically.
36
+
37
+ Caching is enabled by default so you don't need to add any extra command-line
38
+ flags or configuration options in your ruby-lint configuration file.
39
+
40
+ ### Method Call Tracking
41
+
42
+ This new features makes it possible for ruby-lint to keep track of what methods
43
+ are called from another method, both in the direction of caller to callee and
44
+ the other way around. Currently this isn't used yet for any analysis but I have
45
+ some ideas on adding useful analysis using this new feature. Another use case
46
+ for this feature is generating Graphviz call graphs without actually having to
47
+ run the corresponding Ruby source code.
48
+
8
49
  ## 0.0.5 - 2013-09-01
9
50
 
10
51
  Originally slated for August 1st I decided to push this release back one month
@@ -121,3 +162,4 @@ Various changes to the old parser.
121
162
  First public release of ruby-lint.
122
163
 
123
164
  [yard]: http://yardoc.org/
165
+ [parser]: https://github.com/whitequark/parser
data/doc/configuration.md CHANGED
@@ -33,25 +33,145 @@ fallback.
33
33
 
34
34
  ## Configuring ruby-lint
35
35
 
36
- Configuration is done using simple YAML files with the following structure:
36
+ Configuration files are simple YAML files. An example of such a configuration
37
+ file is the following:
37
38
 
38
- * `requires`: an Array of files to require before running ruby-lint
39
- * `report_levels`: an Array of report levels to enable.
40
- * `analysis_classes`: an Array of the human friendly names of the analysis
41
- classes to enable.
42
- * `presenter`: the human friendly name of the presenter to use.
39
+ ---
40
+ directories:
41
+ - lib
42
+
43
+ ignore_paths:
44
+ - lib/ruby-lint/definitions
45
+ - lib/ruby-lint/cli
46
+
47
+ ### requires
48
+
49
+ The `requires` option can be used to specify a list of Ruby files that should
50
+ be loaded before analysis is performed. The primary use case of this option is
51
+ to load extra definitions that don't come with ruby-lint by default.
43
52
 
44
- A basic example looks lik the following:
53
+ Example:
45
54
 
46
55
  ---
47
56
  requires:
48
- - ruby-lint/definitions/core/string
57
+ - ruby-lint/definitions/rails
58
+
59
+ By default this option is left empty.
60
+
61
+ ### report_levels
62
+
63
+ The `report_levels` option can be used to specify a list of the enabled
64
+ reporting levels. The following levels are currently available:
65
+
66
+ * info
67
+ * warning
68
+ * error
69
+
70
+ By default all of these are enabled.
71
+
72
+ Example:
73
+
74
+ ---
49
75
  report_levels:
76
+ - warning
50
77
  - error
78
+
79
+ ### presenter
80
+
81
+ The short, human readable name of the presenter to use for displaying the
82
+ analysis results. The following presenters are currently available:
83
+
84
+ * text
85
+ * json
86
+
87
+ The default presenter is `text`.
88
+
89
+ Example:
90
+
91
+ ---
92
+ presenter: text
93
+
94
+ ### analysis_classes
95
+
96
+ A list of the short, human readable names of the analysis classes to enable.
97
+ The following analysis classes are currently available:
98
+
99
+ * `argument_amount`
100
+ * `pedantics`
101
+ * `shadowing_variables`
102
+ * `undefined_methods`
103
+ * `undefined_variables`
104
+ * `unused_variables`
105
+
106
+ By default all of these are enabled.
107
+
108
+ Example:
109
+
110
+ ---
51
111
  analysis_classes:
52
- - undefined_methods
53
- - undefined_variables
54
- presenter: json
112
+ - argument_amount
113
+ - pedantics
114
+
115
+ ### directories
55
116
 
56
- If no value is given for a certain configuration option the default value(s)
57
- will be used instead.
117
+ A list of directories to search in for externally defined constants. By
118
+ default this is set to the current working directory which, for big projects,
119
+ can slow things down.
120
+
121
+ Example:
122
+
123
+ ---
124
+ directories:
125
+ - app
126
+ - lib
127
+
128
+ ### debug
129
+
130
+ A boolean that indicates that debugging mode should be enabled or disabled, by
131
+ default this is disabled.
132
+
133
+ Example:
134
+
135
+ ---
136
+ debug: true
137
+
138
+ ### ignore_paths
139
+
140
+ A list of patterns to apply to the `directories` option to filter out unwanted
141
+ directories. For example, you could use this to search for files in the lib/
142
+ directory but exclude lib/foo/bar:
143
+
144
+ ---
145
+ directories:
146
+ - lib
147
+
148
+ ignore_paths:
149
+ - lib/foo/bar
150
+
151
+ Example:
152
+
153
+ ---
154
+ ignore_paths:
155
+ - lib/ruby-lint/definitions
156
+
157
+ ### enable_cache
158
+
159
+ A boolean that indicates that caching should be enabled or disabled, by default
160
+ this is enabled. Disabling caching can slow down ruby-lint considerably.
161
+
162
+ Example:
163
+
164
+ ---
165
+ enable_cache: true
166
+
167
+ ### cache_directory
168
+
169
+ The directory to store cache files in if caching is enabled. By default this is
170
+ set to `$XDG_CACHE_HOME/ruby-lint` or `$HOME/.cache/ruby-lint` if the former
171
+ variable isn't set. If the cache directory doesn't exist it's created
172
+ automatically.
173
+
174
+ Example:
175
+
176
+ ---
177
+ cache_directory: ~/ruby-lint
@@ -17,28 +17,22 @@ module RubyLint
17
17
  # @param [RubyLint::AST::Node] node
18
18
  #
19
19
  def on_block(node)
20
- @outer_scope = current_scope
21
- @in_block = true
20
+ arguments = node.children[1].children
22
21
 
23
- super
24
- end
25
-
26
- ##
27
- # @param [RubyLint::AST::Node] node
28
- #
29
- def after_block(node)
30
- @in_block = false
31
- @outer_scope = nil
22
+ arguments.each do |arg|
23
+ validate_argument(arg)
24
+ end
32
25
 
33
26
  super
34
27
  end
35
28
 
29
+ private
30
+
36
31
  ##
37
32
  # @param [RubyLint::AST::Node] node
38
33
  #
39
- def on_arg(node)
40
- if @in_block \
41
- and @outer_scope.has_definition?(:lvar, node.name)
34
+ def validate_argument(node)
35
+ if current_scope.has_definition?(:lvar, node.name)
42
36
  warning("shadowing outer local variable #{node.name}", node)
43
37
  end
44
38
  end
@@ -57,8 +57,25 @@ module RubyLint
57
57
  end
58
58
  end
59
59
 
60
+ VirtualMachine::ARGUMENT_TYPES.each do |name|
61
+ define_method("on_#{name}") { |node| verify_argument(node) }
62
+ end
63
+
60
64
  private
61
65
 
66
+ ##
67
+ # Adds warnings for unused method arguments.
68
+ #
69
+ # @param [RubyLint::AST::Node] node
70
+ #
71
+ def verify_argument(node)
72
+ variable = current_scope.lookup(:lvar, node.name)
73
+
74
+ if add_warning?(variable)
75
+ warning("unused argument #{variable.name}", node)
76
+ end
77
+ end
78
+
62
79
  ##
63
80
  # @param [RubyLint::Definition::RubyObject] variable
64
81
  # @return [TrueClass|FalseClass]