ruby-lint 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.asc +17 -0
  3. data.tar.gz.asc +14 -14
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +0 -1
  6. data/.yardopts +1 -0
  7. data/CONTRIBUTING.md +41 -0
  8. data/MANIFEST +99 -66
  9. data/README.md +36 -10
  10. data/Rakefile +6 -0
  11. data/checksum/ruby-lint-0.0.4.gem.sha512 +1 -0
  12. data/doc/changelog.md +94 -0
  13. data/lib/ruby-lint.rb +18 -1
  14. data/lib/ruby-lint/analysis/argument_amount.rb +43 -10
  15. data/lib/ruby-lint/analysis/base.rb +23 -17
  16. data/lib/ruby-lint/analysis/pedantics.rb +3 -1
  17. data/lib/ruby-lint/analysis/undefined_methods.rb +48 -10
  18. data/lib/ruby-lint/analysis/unused_variables.rb +27 -5
  19. data/lib/ruby-lint/ast/node.rb +10 -0
  20. data/lib/ruby-lint/cli/analyze.rb +22 -4
  21. data/lib/ruby-lint/cli/base.rb +8 -2
  22. data/lib/ruby-lint/configuration.rb +43 -4
  23. data/lib/ruby-lint/definition/constant_proxy.rb +10 -1
  24. data/lib/ruby-lint/definition/ruby_method.rb +45 -31
  25. data/lib/ruby-lint/definition/ruby_object.rb +56 -15
  26. data/lib/ruby-lint/definition_builder/base.rb +4 -0
  27. data/lib/ruby-lint/definition_builder/primitive.rb +1 -1
  28. data/lib/ruby-lint/definition_builder/ruby_array.rb +1 -1
  29. data/lib/ruby-lint/definition_builder/ruby_block.rb +1 -0
  30. data/lib/ruby-lint/definition_builder/ruby_class.rb +1 -1
  31. data/lib/ruby-lint/definition_builder/ruby_hash.rb +1 -1
  32. data/lib/ruby-lint/definition_builder/ruby_module.rb +3 -1
  33. data/lib/ruby-lint/definition_generator.rb +15 -7
  34. data/lib/ruby-lint/definitions/core/arg0.rb +1 -1
  35. data/lib/ruby-lint/definitions/core/argf.rb +1 -1
  36. data/lib/ruby-lint/definitions/core/argument_error.rb +2 -2
  37. data/lib/ruby-lint/definitions/core/argv.rb +1 -1
  38. data/lib/ruby-lint/definitions/core/array.rb +6 -6
  39. data/lib/ruby-lint/definitions/core/autoload.rb +2 -2
  40. data/lib/ruby-lint/definitions/core/basic_object.rb +8 -12
  41. data/lib/ruby-lint/definitions/core/bignum.rb +2 -2
  42. data/lib/ruby-lint/definitions/core/binding.rb +2 -2
  43. data/lib/ruby-lint/definitions/core/class.rb +2 -2
  44. data/lib/ruby-lint/definitions/core/comparable.rb +1 -1
  45. data/lib/ruby-lint/definitions/core/complex.rb +4 -4
  46. data/lib/ruby-lint/definitions/core/condition_variable.rb +2 -2
  47. data/lib/ruby-lint/definitions/core/continuation.rb +2 -2
  48. data/lib/ruby-lint/definitions/core/data.rb +2 -2
  49. data/lib/ruby-lint/definitions/core/date.rb +34 -34
  50. data/lib/ruby-lint/definitions/core/date_time.rb +26 -26
  51. data/lib/ruby-lint/definitions/core/default_record_separator.rb +1 -1
  52. data/lib/ruby-lint/definitions/core/digest.rb +14 -14
  53. data/lib/ruby-lint/definitions/core/dir.rb +34 -34
  54. data/lib/ruby-lint/definitions/core/encoding.rb +237 -237
  55. data/lib/ruby-lint/definitions/core/encoding_error.rb +2 -2
  56. data/lib/ruby-lint/definitions/core/enumerable.rb +15 -15
  57. data/lib/ruby-lint/definitions/core/enumerator.rb +2 -2
  58. data/lib/ruby-lint/definitions/core/env.rb +1 -1
  59. data/lib/ruby-lint/definitions/core/eoferror.rb +2 -2
  60. data/lib/ruby-lint/definitions/core/erb.rb +30 -23
  61. data/lib/ruby-lint/definitions/core/errno.rb +525 -525
  62. data/lib/ruby-lint/definitions/core/etc.rb +6 -6
  63. data/lib/ruby-lint/definitions/core/exception.rb +2 -2
  64. data/lib/ruby-lint/definitions/core/false.rb +1 -1
  65. data/lib/ruby-lint/definitions/core/false_class.rb +2 -2
  66. data/lib/ruby-lint/definitions/core/fatal_error.rb +2 -2
  67. data/lib/ruby-lint/definitions/core/fiber.rb +2 -2
  68. data/lib/ruby-lint/definitions/core/fiber_error.rb +2 -2
  69. data/lib/ruby-lint/definitions/core/file.rb +68 -68
  70. data/lib/ruby-lint/definitions/core/file_list.rb +2 -2
  71. data/lib/ruby-lint/definitions/core/file_test.rb +1 -1
  72. data/lib/ruby-lint/definitions/core/file_utils.rb +16 -16
  73. data/lib/ruby-lint/definitions/core/fixnum.rb +4 -4
  74. data/lib/ruby-lint/definitions/core/float.rb +16 -16
  75. data/lib/ruby-lint/definitions/core/float_domain_error.rb +2 -2
  76. data/lib/ruby-lint/definitions/core/gc.rb +2 -2
  77. data/lib/ruby-lint/definitions/core/gem.rb +119 -119
  78. data/lib/ruby-lint/definitions/core/hash.rb +14 -14
  79. data/lib/ruby-lint/definitions/core/immediate_value.rb +1 -1
  80. data/lib/ruby-lint/definitions/core/index_error.rb +2 -2
  81. data/lib/ruby-lint/definitions/core/integer.rb +2 -2
  82. data/lib/ruby-lint/definitions/core/interrupt.rb +2 -2
  83. data/lib/ruby-lint/definitions/core/io.rb +38 -38
  84. data/lib/ruby-lint/definitions/core/ioerror.rb +2 -2
  85. data/lib/ruby-lint/definitions/core/kernel.rb +113 -60
  86. data/lib/ruby-lint/definitions/core/key_error.rb +2 -2
  87. data/lib/ruby-lint/definitions/core/load_error.rb +6 -6
  88. data/lib/ruby-lint/definitions/core/local_jump_error.rb +2 -2
  89. data/lib/ruby-lint/definitions/core/marshal.rb +35 -35
  90. data/lib/ruby-lint/definitions/core/match_data.rb +2 -2
  91. data/lib/ruby-lint/definitions/core/math.rb +7 -7
  92. data/lib/ruby-lint/definitions/core/memory_segmention_error.rb +2 -2
  93. data/lib/ruby-lint/definitions/core/method.rb +2 -2
  94. data/lib/ruby-lint/definitions/core/module.rb +39 -3
  95. data/lib/ruby-lint/definitions/core/monitor.rb +4 -4
  96. data/lib/ruby-lint/definitions/core/monitor_mixin.rb +5 -5
  97. data/lib/ruby-lint/definitions/core/mutex.rb +2 -2
  98. data/lib/ruby-lint/definitions/core/name_error.rb +2 -2
  99. data/lib/ruby-lint/definitions/core/nil.rb +1 -1
  100. data/lib/ruby-lint/definitions/core/nil_class.rb +2 -2
  101. data/lib/ruby-lint/definitions/core/no_memory_error.rb +2 -2
  102. data/lib/ruby-lint/definitions/core/no_method_error.rb +2 -2
  103. data/lib/ruby-lint/definitions/core/not_implemented_error.rb +2 -2
  104. data/lib/ruby-lint/definitions/core/numeric.rb +2 -2
  105. data/lib/ruby-lint/definitions/core/object.rb +2 -2
  106. data/lib/ruby-lint/definitions/core/object_space.rb +1 -1
  107. data/lib/ruby-lint/definitions/core/open_struct.rb +3 -3
  108. data/lib/ruby-lint/definitions/core/option_parser.rb +83 -83
  109. data/lib/ruby-lint/definitions/core/precision.rb +1 -1
  110. data/lib/ruby-lint/definitions/core/primitive_failure.rb +2 -2
  111. data/lib/ruby-lint/definitions/core/proc.rb +2 -2
  112. data/lib/ruby-lint/definitions/core/process.rb +29 -29
  113. data/lib/ruby-lint/definitions/core/queue.rb +2 -2
  114. data/lib/ruby-lint/definitions/core/rake.rb +117 -117
  115. data/lib/ruby-lint/definitions/core/rake_file_utils.rb +1 -1
  116. data/lib/ruby-lint/definitions/core/rakeversion.rb +1 -1
  117. data/lib/ruby-lint/definitions/core/random.rb +2 -2
  118. data/lib/ruby-lint/definitions/core/range.rb +4 -4
  119. data/lib/ruby-lint/definitions/core/range_error.rb +2 -2
  120. data/lib/ruby-lint/definitions/core/rational.rb +2 -2
  121. data/lib/ruby-lint/definitions/core/rb_config.rb +3 -3
  122. data/lib/ruby-lint/definitions/core/regexp.rb +28 -28
  123. data/lib/ruby-lint/definitions/core/regexp_error.rb +2 -2
  124. data/lib/ruby-lint/definitions/core/ruby_copyright.rb +1 -1
  125. data/lib/ruby-lint/definitions/core/ruby_description.rb +1 -1
  126. data/lib/ruby-lint/definitions/core/ruby_engine.rb +1 -1
  127. data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +1 -1
  128. data/lib/ruby-lint/definitions/core/ruby_platform.rb +1 -1
  129. data/lib/ruby-lint/definitions/core/ruby_release_date.rb +1 -1
  130. data/lib/ruby-lint/definitions/core/ruby_version.rb +1 -1
  131. data/lib/ruby-lint/definitions/core/runtime_error.rb +2 -2
  132. data/lib/ruby-lint/definitions/core/scan_error.rb +2 -2
  133. data/lib/ruby-lint/definitions/core/script_error.rb +2 -2
  134. data/lib/ruby-lint/definitions/core/security_error.rb +2 -2
  135. data/lib/ruby-lint/definitions/core/shellwords.rb +1 -1
  136. data/lib/ruby-lint/definitions/core/signal.rb +3 -3
  137. data/lib/ruby-lint/definitions/core/signal_exception.rb +2 -2
  138. data/lib/ruby-lint/definitions/core/singleton.rb +2 -2
  139. data/lib/ruby-lint/definitions/core/sized_queue.rb +2 -2
  140. data/lib/ruby-lint/definitions/core/standard_error.rb +2 -2
  141. data/lib/ruby-lint/definitions/core/stderr.rb +3 -2
  142. data/lib/ruby-lint/definitions/core/stdin.rb +3 -2
  143. data/lib/ruby-lint/definitions/core/stdout.rb +3 -2
  144. data/lib/ruby-lint/definitions/core/stop_iteration.rb +2 -2
  145. data/lib/ruby-lint/definitions/core/string.rb +21 -21
  146. data/lib/ruby-lint/definitions/core/string_io.rb +7 -7
  147. data/lib/ruby-lint/definitions/core/string_scanner.rb +4 -4
  148. data/lib/ruby-lint/definitions/core/struct.rb +20 -20
  149. data/lib/ruby-lint/definitions/core/syck.rb +4 -4
  150. data/lib/ruby-lint/definitions/core/symbol.rb +2 -2
  151. data/lib/ruby-lint/definitions/core/syntax_error.rb +2 -2
  152. data/lib/ruby-lint/definitions/core/system_call_error.rb +2 -2
  153. data/lib/ruby-lint/definitions/core/system_exit.rb +2 -2
  154. data/lib/ruby-lint/definitions/core/system_stack_error.rb +2 -2
  155. data/lib/ruby-lint/definitions/core/thread.rb +6 -6
  156. data/lib/ruby-lint/definitions/core/thread_error.rb +2 -2
  157. data/lib/ruby-lint/definitions/core/thread_group.rb +2 -2
  158. data/lib/ruby-lint/definitions/core/time.rb +3 -3
  159. data/lib/ruby-lint/definitions/core/toplevel_binding.rb +1 -1
  160. data/lib/ruby-lint/definitions/core/true.rb +1 -1
  161. data/lib/ruby-lint/definitions/core/true_class.rb +2 -2
  162. data/lib/ruby-lint/definitions/core/type_error.rb +2 -2
  163. data/lib/ruby-lint/definitions/core/unbound_method.rb +2 -2
  164. data/lib/ruby-lint/definitions/core/unmarshalable.rb +1 -1
  165. data/lib/ruby-lint/definitions/core/unsupported_library_error.rb +2 -2
  166. data/lib/ruby-lint/definitions/core/weak_ref.rb +4 -4
  167. data/lib/ruby-lint/definitions/core/yaml.rb +2361 -0
  168. data/lib/ruby-lint/definitions/core/zero_division_error.rb +2 -2
  169. data/lib/ruby-lint/definitions/global_variables.rb +9 -0
  170. data/lib/ruby-lint/definitions/rails/abstract_controller.rb +174 -28
  171. data/lib/ruby-lint/definitions/rails/action_controller.rb +4959 -550
  172. data/lib/ruby-lint/definitions/rails/action_dispatch.rb +2489 -292
  173. data/lib/ruby-lint/definitions/rails/action_mailer.rb +1285 -42
  174. data/lib/ruby-lint/definitions/rails/action_pack.rb +14 -6
  175. data/lib/ruby-lint/definitions/rails/action_view.rb +6941 -445
  176. data/lib/ruby-lint/definitions/rails/active_model.rb +1212 -69
  177. data/lib/ruby-lint/definitions/rails/active_record.rb +10344 -1450
  178. data/lib/ruby-lint/definitions/rails/active_support.rb +4631 -573
  179. data/lib/ruby-lint/definitions/rails/arel.rb +3211 -319
  180. data/lib/ruby-lint/definitions/rails/rails.rb +2922 -84
  181. data/lib/ruby-lint/definitions/rails/sprockets.rb +3048 -277
  182. data/lib/ruby-lint/docstring/mapping.rb +55 -0
  183. data/lib/ruby-lint/docstring/param_tag.rb +29 -0
  184. data/lib/ruby-lint/docstring/parser.rb +133 -0
  185. data/lib/ruby-lint/docstring/return_tag.rb +24 -0
  186. data/lib/ruby-lint/file_loader.rb +96 -0
  187. data/lib/ruby-lint/file_scanner.rb +91 -0
  188. data/lib/ruby-lint/global_scope.rb +56 -0
  189. data/lib/ruby-lint/helper/constant_paths.rb +1 -1
  190. data/lib/ruby-lint/inspector.rb +11 -33
  191. data/lib/ruby-lint/iterator.rb +31 -4
  192. data/lib/ruby-lint/method_call/alias.rb +46 -0
  193. data/lib/ruby-lint/method_call/assign_member.rb +55 -0
  194. data/lib/ruby-lint/method_call/attribute.rb +102 -0
  195. data/lib/ruby-lint/method_call/base.rb +37 -0
  196. data/lib/ruby-lint/method_call/define_method.rb +17 -0
  197. data/lib/ruby-lint/method_call/include.rb +39 -0
  198. data/lib/ruby-lint/parser.rb +9 -4
  199. data/lib/ruby-lint/presenter/text.rb +2 -1
  200. data/lib/ruby-lint/report.rb +19 -42
  201. data/lib/ruby-lint/report/entry.rb +20 -17
  202. data/lib/ruby-lint/runner.rb +92 -11
  203. data/lib/ruby-lint/template/definition.erb +2 -2
  204. data/lib/ruby-lint/variable_predicates.rb +7 -10
  205. data/lib/ruby-lint/version.rb +1 -1
  206. data/lib/ruby-lint/virtual_machine.rb +265 -188
  207. data/ruby-lint.gemspec +4 -4
  208. data/ruby-lint.yml +7 -0
  209. data/spec/fixtures/associating.rb +7 -0
  210. data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +6 -0
  211. data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +8 -0
  212. data/spec/fixtures/file_scanner/lib/example/user.rb +6 -0
  213. data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +4 -0
  214. data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +6 -0
  215. data/spec/fixtures/file_scanner/rails/app/models/user.rb +4 -0
  216. data/spec/fixtures/uses_external.rb +1 -0
  217. data/spec/fixtures/uses_external_invalid.rb +3 -0
  218. data/spec/fixtures/uses_external_namespace.rb +1 -0
  219. data/spec/ruby-lint/analysis/{argument_amount.rb → argument_amount_spec.rb} +33 -7
  220. data/spec/ruby-lint/analysis/base_spec.rb +12 -0
  221. data/spec/ruby-lint/analysis/{pedantics.rb → pedantics_spec.rb} +24 -4
  222. data/spec/ruby-lint/analysis/{shadowing_variables.rb → shadowing_variables_spec.rb} +6 -6
  223. data/spec/ruby-lint/analysis/undefined_methods_spec.rb +320 -0
  224. data/spec/ruby-lint/analysis/{undefined_variables.rb → undefined_variables_spec.rb} +33 -10
  225. data/spec/ruby-lint/analysis/{unused_variables.rb → unused_variables_spec.rb} +36 -9
  226. data/spec/ruby-lint/ast/{node.rb → node_spec.rb} +12 -6
  227. data/spec/ruby-lint/cli/{analyze.rb → analyze_spec.rb} +16 -5
  228. data/spec/ruby-lint/cli/{ast.rb → ast_spec.rb} +3 -3
  229. data/spec/ruby-lint/configuration_spec.rb +106 -0
  230. data/spec/ruby-lint/definition/constant_proxy_spec.rb +54 -0
  231. data/spec/ruby-lint/definition/{dsl.rb → dsl_spec.rb} +15 -15
  232. data/spec/ruby-lint/definition/{ruby_method.rb → ruby_method_spec.rb} +31 -17
  233. data/spec/ruby-lint/definition/{ruby_object.rb → ruby_object_spec.rb} +28 -23
  234. data/spec/ruby-lint/definition_builder/{primitive.rb → primitive_spec.rb} +9 -9
  235. data/spec/ruby-lint/definition_builder/{ruby_class.rb → ruby_class_spec.rb} +13 -13
  236. data/spec/ruby-lint/definition_builder/{ruby_method.rb → ruby_method_spec.rb} +9 -9
  237. data/spec/ruby-lint/definition_builder/{ruby_module.rb → ruby_module_spec.rb} +12 -10
  238. data/spec/ruby-lint/docstring/mapping.rb +27 -0
  239. data/spec/ruby-lint/docstring/parser_spec.rb +88 -0
  240. data/spec/ruby-lint/extensions/{string.rb → string_spec.rb} +3 -3
  241. data/spec/ruby-lint/file_loader_spec.rb +69 -0
  242. data/spec/ruby-lint/file_scanner_spec.rb +51 -0
  243. data/spec/ruby-lint/inspector_spec.rb +44 -0
  244. data/spec/ruby-lint/{iterator.rb → iterator_spec.rb} +39 -4
  245. data/spec/ruby-lint/{nested_stack.rb → nested_stack_spec.rb} +4 -4
  246. data/spec/ruby-lint/parser_spec.rb +31 -0
  247. data/spec/ruby-lint/presenter/json_spec.rb +58 -0
  248. data/spec/ruby-lint/presenter/text_spec.rb +49 -0
  249. data/spec/ruby-lint/report/entry_spec.rb +58 -0
  250. data/spec/ruby-lint/report_spec.rb +39 -0
  251. data/spec/ruby-lint/runner_spec.rb +52 -0
  252. data/spec/ruby-lint/virtual_machine/alias_spec.rb +55 -0
  253. data/spec/ruby-lint/virtual_machine/assignments/{arrays.rb → arrays_spec.rb} +7 -7
  254. data/spec/ruby-lint/virtual_machine/assignments/{hashes.rb → hashes_spec.rb} +6 -6
  255. data/spec/ruby-lint/virtual_machine/assignments/{optional.rb → optional_spec.rb} +6 -6
  256. data/spec/ruby-lint/virtual_machine/assignments/{return_values.rb → return_values_spec.rb} +11 -11
  257. data/spec/ruby-lint/virtual_machine/assignments/{variables.rb → variables_spec.rb} +38 -7
  258. data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +59 -0
  259. data/spec/ruby-lint/virtual_machine/{autoloading.rb → autoloading_spec.rb} +6 -6
  260. data/spec/ruby-lint/virtual_machine/{blocks.rb → blocks_spec.rb} +30 -4
  261. data/spec/ruby-lint/virtual_machine/classes/{class_methods.rb → class_methods_spec.rb} +3 -3
  262. data/spec/ruby-lint/virtual_machine/classes/{extending.rb → extending_spec.rb} +20 -15
  263. data/spec/ruby-lint/virtual_machine/classes/{redefining.rb → redefining_spec.rb} +3 -3
  264. data/spec/ruby-lint/virtual_machine/classes/{sclass.rb → sclass_spec.rb} +7 -7
  265. data/spec/ruby-lint/virtual_machine/classes/{scoping.rb → scoping_spec.rb} +5 -5
  266. data/spec/ruby-lint/virtual_machine/complex/{rails.rb → rails_spec.rb} +3 -3
  267. data/spec/ruby-lint/virtual_machine/complex/{rcap.rb → rcap_spec.rb} +3 -3
  268. data/spec/ruby-lint/virtual_machine/complex/{slop.rb → slop_spec.rb} +3 -3
  269. data/spec/ruby-lint/virtual_machine/constants_spec.rb +31 -0
  270. data/spec/ruby-lint/virtual_machine/{for.rb → for_spec.rb} +3 -3
  271. data/spec/ruby-lint/virtual_machine/{freeze.rb → freeze_spec.rb} +3 -3
  272. data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +12 -0
  273. data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +15 -0
  274. data/spec/ruby-lint/virtual_machine/{interpolation.rb → interpolation_spec.rb} +3 -3
  275. data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +116 -0
  276. data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +41 -0
  277. data/spec/ruby-lint/virtual_machine/methods/{defining.rb → defining_spec.rb} +4 -4
  278. data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +69 -0
  279. data/spec/ruby-lint/virtual_machine/methods/{exporting.rb → exporting_spec.rb} +3 -3
  280. data/spec/ruby-lint/virtual_machine/methods/{parameters.rb → parameters_spec.rb} +17 -5
  281. data/spec/ruby-lint/virtual_machine/methods/{patching.rb → patching_spec.rb} +4 -4
  282. data/spec/ruby-lint/virtual_machine/methods/{scoping.rb → scoping_spec.rb} +5 -5
  283. data/spec/ruby-lint/virtual_machine/methods/{visibility.rb → visibility_spec.rb} +6 -6
  284. data/spec/ruby-lint/virtual_machine/{modules.rb → modules_spec.rb} +39 -9
  285. data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +61 -0
  286. data/spec/ruby-lint/virtual_machine/{unused.rb → unused_spec.rb} +4 -4
  287. data/spec/{helper.rb → spec_helper.rb} +6 -4
  288. data/spec/support/building.rb +10 -6
  289. data/spec/support/coveralls.rb +1 -1
  290. data/spec/support/parsing.rb +10 -1
  291. data/spec/support/simplecov.rb +1 -1
  292. data/spec/support/versions.rb +9 -0
  293. data/task/test.rake +2 -4
  294. data/task/travis.rake +1 -0
  295. metadata +144 -143
  296. metadata.gz.asc +14 -14
  297. data/.rubocop.yml +0 -59
  298. data/doc/contributing.md +0 -16
  299. data/lib/ruby-lint/analysis/confusing_variables.rb +0 -26
  300. data/lib/ruby-lint/definitions/core/main.rb +0 -25
  301. data/lib/ruby-lint/definitions/core/psych.rb +0 -2231
  302. data/lib/ruby-lint/definitions/core/rubinius.rb +0 -16637
  303. data/lib/ruby-lint/definitions/core/ruby_lint.rb +0 -93
  304. data/spec/ruby-lint/analysis/confusing_variables.rb +0 -46
  305. data/spec/ruby-lint/analysis/undefined_methods.rb +0 -174
  306. data/spec/ruby-lint/configuration.rb +0 -54
  307. data/spec/ruby-lint/definition/constant_proxy.rb +0 -31
  308. data/spec/ruby-lint/parser.rb +0 -14
  309. data/spec/ruby-lint/presenter/json.rb +0 -31
  310. data/spec/ruby-lint/presenter/text.rb +0 -22
  311. data/spec/ruby-lint/report.rb +0 -50
  312. data/spec/ruby-lint/report/entry.rb +0 -28
  313. data/spec/ruby-lint/runner.rb +0 -32
  314. data/spec/ruby-lint/virtual_machine/associate_nodes.rb +0 -17
  315. data/spec/ruby-lint/virtual_machine/reference_amount.rb +0 -33
  316. data/spec/support/bacon.rb +0 -33
  317. data/task/cop.rake +0 -11
data/ruby-lint.gemspec CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../lib/ruby-lint/version', __FILE__)
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ruby-lint'
5
5
  s.version = RubyLint::VERSION
6
- s.date = '2013-04-22'
6
+ s.date = Time.now.strftime('%Y-%m-%d')
7
7
  s.authors = ['Yorick Peterse']
8
8
  s.email = 'yorickpeterse@gmail.com'
9
9
  s.summary = 'A linter and static code analysis tool for Ruby.'
@@ -29,17 +29,17 @@ using the handle "yorickpeterse".
29
29
  s.has_rdoc = 'yard'
30
30
  s.required_ruby_version = '>= 1.9.3'
31
31
 
32
- s.add_dependency 'parser', ['>= 2.0.0.pre2']
32
+ s.add_dependency 'parser', ['>= 2.0.0.pre6']
33
33
  s.add_dependency 'slop'
34
34
 
35
35
  s.add_development_dependency 'rake'
36
- s.add_development_dependency 'bacon', ['>= 1.2.0']
36
+ s.add_development_dependency 'rspec', ['>= 2.14']
37
37
  s.add_development_dependency 'yard'
38
38
  s.add_development_dependency 'pry-rescue'
39
- s.add_development_dependency 'bacon-colored_output'
40
39
  s.add_development_dependency 'simplecov'
41
40
  s.add_development_dependency 'rubygems-openpgp'
42
41
  s.add_development_dependency 'coveralls'
43
42
  s.add_development_dependency 'json'
44
43
  s.add_development_dependency 'kramdown'
44
+ s.add_development_dependency 'redcard'
45
45
  end
data/ruby-lint.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ directories:
3
+ - lib
4
+
5
+ ignore_paths:
6
+ - lib/ruby-lint/definitions
7
+ - lib/ruby-lint/cli
@@ -0,0 +1,7 @@
1
+ module RubyLint
2
+ class GlobalScope
3
+ def self.constant_proxy(name)
4
+ return Definition::ConstantProxy.new(definitions, name)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Example
2
+ module Recursive
3
+ class Source < Target
4
+ end # Source
5
+ end # Recursive
6
+ end # Example
@@ -0,0 +1,8 @@
1
+ module Example
2
+ module Recursive
3
+ class Target
4
+ def example_method
5
+ end
6
+ end # Target
7
+ end # Recursive
8
+ end # Example
@@ -0,0 +1,6 @@
1
+ module Example
2
+ class User
3
+ def example_method
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module TestDashes
2
+ module Foo
3
+ end # Foo
4
+ end # TestDashes
@@ -0,0 +1,6 @@
1
+ module Example
2
+ class User
3
+ def example_method
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ class User
2
+ def example_method
3
+ end
4
+ end
@@ -0,0 +1 @@
1
+ User.new
@@ -0,0 +1,3 @@
1
+ user = User.new
2
+
3
+ user.foobar
@@ -0,0 +1 @@
1
+ Example::User.new
@@ -1,7 +1,7 @@
1
- require File.expand_path('../../../helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe RubyLint::Analysis::ArgumentAmount do
4
- should 'validate the amount of required arguments' do
4
+ example 'validate the amount of required arguments' do
5
5
  code = <<-CODE
6
6
  def example(first, second)
7
7
  end
@@ -19,7 +19,7 @@ example
19
19
  entry.message.should == 'wrong number of arguments (expected 2 but got 0)'
20
20
  end
21
21
 
22
- should 'validate argument amounts when using optional arguments' do
22
+ example 'validate argument amounts when using optional arguments' do
23
23
  code = <<-CODE
24
24
  def example(first, second, third = nil)
25
25
  end
@@ -38,7 +38,7 @@ example
38
38
  '(expected 2..3 but got 0)'
39
39
  end
40
40
 
41
- should 'validate argument amounts when using rest arguments' do
41
+ example 'validate argument amounts when using rest arguments' do
42
42
  code = <<-CODE
43
43
  def example(first, second, *args)
44
44
  end
@@ -57,7 +57,7 @@ example
57
57
  '(expected 2 but got 0)'
58
58
  end
59
59
 
60
- should 'validate argument amounts when using a required and rest argument' do
60
+ example 'validate argument amounts when using a required and rest argument' do
61
61
  code = <<-CODE
62
62
  def example(required, *numbers)
63
63
  end
@@ -70,7 +70,7 @@ example(10, 20, 30)
70
70
  report.entries.length.should == 0
71
71
  end
72
72
 
73
- should 'take variable assignments into account' do
73
+ example 'take variable assignments into account' do
74
74
  code = <<-CODE
75
75
  name = 'Ruby'
76
76
 
@@ -82,10 +82,36 @@ name.downcase
82
82
  report.entries.empty?.should == true
83
83
  end
84
84
 
85
- should 'not validate methods called on undefined receivers' do
85
+ example 'not validate methods called on undefined receivers' do
86
86
  code = 'A.example_method'
87
87
  report = build_report(code, RubyLint::Analysis::ArgumentAmount)
88
88
 
89
89
  report.entries.empty?.should == true
90
90
  end
91
+
92
+ example 'use #initialize for arguments when processing .new' do
93
+ code = <<-CODE
94
+ class Person
95
+ def initialize(name)
96
+ end
97
+ end
98
+
99
+ Person.new
100
+ Person.new(10, 20)
101
+ CODE
102
+
103
+ report = build_report(code, RubyLint::Analysis::ArgumentAmount)
104
+
105
+ report.entries.length.should == 2
106
+
107
+ first, second = report.entries
108
+
109
+ first.line.should == 6
110
+ first.column.should == 0
111
+ first.message.should == 'wrong number of arguments (expected 1 but got 0)'
112
+
113
+ second.line.should == 7
114
+ second.column.should == 0
115
+ second.message.should == 'wrong number of arguments (expected 1 but got 2)'
116
+ end
91
117
  end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyLint::Analysis::Base do
4
+ example 'require a VM' do
5
+ lambda { RubyLint::Analysis::Base.new }.should raise_error(ArgumentError)
6
+
7
+ vm = RubyLint::VirtualMachine.new
8
+ blk = lambda { RubyLint::Analysis::Base.new(:vm => vm) }
9
+
10
+ blk.should_not raise_error
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
- require File.expand_path('../../../helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe RubyLint::Analysis::Pedantics do
4
- should 'warn when using do/then in various statements' do
4
+ example 'warn when using do/then in various statements' do
5
5
  code = <<-CODE
6
6
  if true then; end
7
7
  unless true then; end
@@ -23,7 +23,27 @@ while true do; end
23
23
  entries[2].message.should == 'the use of then/do is not needed here'
24
24
  end
25
25
 
26
- should 'warn for the use of BEGIN/END' do
26
+ # See https://github.com/YorickPeterse/ruby-lint/issues/32 for the motivation
27
+ # behind this test.
28
+ example 'not warn when no do/then identifier is used in a statement' do
29
+ code = <<-CODE.strip
30
+ if true; end
31
+
32
+ if foo && bar
33
+ true
34
+ else
35
+ false
36
+ end
37
+
38
+ foo ? true : false
39
+ CODE
40
+
41
+ report = build_report(code, RubyLint::Analysis::Pedantics)
42
+
43
+ report.entries.empty?.should == true
44
+ end
45
+
46
+ example 'warn for the use of BEGIN/END' do
27
47
  code = <<-CODE
28
48
  BEGIN {}
29
49
  END {}
@@ -40,4 +60,4 @@ END {}
40
60
  entries[1].line.should == 2
41
61
  entries[1].message.should == 'BEGIN/END is useless'
42
62
  end
43
- end
63
+ end
@@ -1,7 +1,7 @@
1
- require File.expand_path('../../../helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe RubyLint::Analysis::ShadowingVariables do
4
- should 'warn for shadowing outer variables' do
4
+ example 'warn for shadowing outer variables' do
5
5
  code = <<-CODE
6
6
  number = 10
7
7
 
@@ -20,7 +20,7 @@ end
20
20
  entry.message.should == 'shadowing outer local variable number'
21
21
  end
22
22
 
23
- should 'not warn for shadowed variables in a new scope' do
23
+ example 'not warn for shadowed variables in a new scope' do
24
24
  code = <<-CODE
25
25
  number = 10
26
26
 
@@ -36,7 +36,7 @@ end
36
36
  report.entries.empty?.should == true
37
37
  end
38
38
 
39
- should 'warn when shadowing variables after a new scope' do
39
+ example 'warn when shadowing variables after a new scope' do
40
40
  code = <<-CODE
41
41
  number = 10
42
42
 
@@ -57,7 +57,7 @@ end
57
57
  entry.message.should == 'shadowing outer local variable number'
58
58
  end
59
59
 
60
- should 'not fail when re-using the same block' do
60
+ example 'not fail when re-using the same block' do
61
61
  code = <<-CODE
62
62
  number = 10
63
63
 
@@ -82,4 +82,4 @@ end
82
82
  second.line.should == 7
83
83
  second.column.should == 17
84
84
  end
85
- end
85
+ end
@@ -0,0 +1,320 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyLint::Analysis::UndefinedMethods do
4
+ example 'add an error for calling an undefined method' do
5
+ report = build_report('example_method', RubyLint::Analysis::UndefinedMethods)
6
+ entry = report.entries[0]
7
+
8
+ entry.is_a?(RubyLint::Report::Entry).should == true
9
+
10
+ entry.line.should == 1
11
+ entry.column.should == 0
12
+ entry.message.should == 'undefined method example_method'
13
+ end
14
+
15
+ example 'add an error for calling an undefined method with a receiver' do
16
+ code = <<-CODE
17
+ class << self
18
+ def example_method
19
+ end
20
+ end
21
+
22
+ String.example_method
23
+ CODE
24
+
25
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
26
+ entry = report.entries[0]
27
+
28
+ entry.is_a?(RubyLint::Report::Entry).should == true
29
+
30
+ entry.line.should == 6
31
+ entry.column.should == 0
32
+ entry.message.should == 'undefined method example_method on String'
33
+ end
34
+
35
+ example 'add an error for calling an undefined method on a receiver instance' do
36
+ code = '"hello".example_method'
37
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
38
+ entry = report.entries[0]
39
+
40
+ entry.is_a?(RubyLint::Report::Entry).should == true
41
+
42
+ entry.line.should == 1
43
+ entry.column.should == 0
44
+ entry.message.should == 'undefined method example_method ' \
45
+ 'on an instance of String'
46
+ end
47
+
48
+ example 'add an error when calling a method defined in a different scope' do
49
+ code = <<-CODE
50
+ class Person
51
+ def name
52
+ return 'name'
53
+ end
54
+
55
+ def greet
56
+ name
57
+ end
58
+ end
59
+
60
+ name
61
+ CODE
62
+
63
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
64
+
65
+ report.entries.length.should == 1
66
+
67
+ entry = report.entries[0]
68
+
69
+ entry.is_a?(RubyLint::Report::Entry).should == true
70
+
71
+ entry.line.should == 11
72
+ entry.column.should == 0
73
+ entry.message.should == 'undefined method name'
74
+ end
75
+
76
+ describe 'core Ruby types' do
77
+ example 'do not add errors for calling defined methods on a Fixnum' do
78
+ report = build_report('10.to_s', RubyLint::Analysis::UndefinedMethods)
79
+
80
+ report.entries.empty?.should == true
81
+ end
82
+
83
+ example 'do not add errors for calling defined methods on a Float' do
84
+ report = build_report('(10.0).to_s', RubyLint::Analysis::UndefinedMethods)
85
+
86
+ report.entries.empty?.should == true
87
+ end
88
+
89
+ example 'do not add errors for calling defined methods on a String' do
90
+ report = build_report('"10".to_s', RubyLint::Analysis::UndefinedMethods)
91
+
92
+ report.entries.empty?.should == true
93
+ end
94
+
95
+ example 'do not add errors for calling defined methods on a Hash' do
96
+ report = build_report('{}.to_s', RubyLint::Analysis::UndefinedMethods)
97
+
98
+ report.entries.empty?.should == true
99
+ end
100
+
101
+ example 'do not add errors for calling defined methods on an Array' do
102
+ report = build_report('[].to_s', RubyLint::Analysis::UndefinedMethods)
103
+
104
+ report.entries.empty?.should == true
105
+ end
106
+ end
107
+
108
+ example 'do not add errors for variables created using blocks' do
109
+ code = <<-CODE
110
+ [10, 20].each do |number|
111
+ number.to_s
112
+ end
113
+ CODE
114
+
115
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
116
+
117
+ report.entries.empty?.should == true
118
+ end
119
+
120
+ example 'take variable assignments into account' do
121
+ code = <<-CODE
122
+ name = 'Ruby'
123
+
124
+ name.downcase
125
+ name.downcasex
126
+ CODE
127
+
128
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
129
+
130
+ report.entries.length.should == 1
131
+
132
+ entry = report.entries[0]
133
+
134
+ entry.line.should == 4
135
+ entry.column.should == 0
136
+ entry.message.should == 'undefined method downcasex on an instance of String'
137
+ end
138
+
139
+ example 'take variable assignments and custom classes into account' do
140
+ code = <<-CODE
141
+ class User
142
+ def example
143
+ end
144
+ end
145
+
146
+ user = User.new
147
+
148
+ user.example
149
+ user.invalid
150
+ CODE
151
+
152
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
153
+
154
+ report.entries.length.should == 1
155
+
156
+ entry = report.entries[0]
157
+
158
+ entry.line.should == 9
159
+ entry.column.should == 0
160
+ entry.message.should == 'undefined method invalid on an instance of User'
161
+ end
162
+
163
+ example 'do not add errors when calling a method on an undefined constant' do
164
+ code = 'A.example_method'
165
+
166
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
167
+
168
+ report.entries.empty?.should == true
169
+ end
170
+
171
+ example 'do not add errors for methods called on variables without values' do
172
+ code = <<-CODE
173
+ def example(number)
174
+ number.to_s
175
+ end
176
+ CODE
177
+
178
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
179
+
180
+ report.entries.empty?.should == true
181
+ end
182
+
183
+ example 'report the right receiver name in multiple variable assignments' do
184
+ code = <<-CODE
185
+ number = 10
186
+
187
+ first = second = number.foobar
188
+ CODE
189
+
190
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
191
+
192
+ report.entries.length.should == 1
193
+
194
+ entry = report.entries[0]
195
+
196
+ entry.message.should == 'undefined method foobar on an instance of Fixnum'
197
+ end
198
+
199
+ example 'ignore methods calls on other non existing methods' do
200
+ code = 'foo.bar'
201
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
202
+
203
+ report.entries.length.should == 1
204
+
205
+ report.entries[0].message.should == 'undefined method foo'
206
+ end
207
+
208
+ example 'ignore methods calls with arguments on other non existing methods' do
209
+ code = 'foo.bar(:baz)'
210
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
211
+
212
+ report.entries.length.should == 1
213
+
214
+ report.entries[0].message.should == 'undefined method foo'
215
+ end
216
+
217
+ context 'Kernel methods' do
218
+ example 'do not add errors for methods defined in Kernel' do
219
+ code = 'puts "hello"'
220
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
221
+
222
+ report.entries.empty?.should == true
223
+ end
224
+
225
+ example 'do not add errors for Kernel methods in an sclass in a module' do
226
+ code = <<-CODE
227
+ module Foo
228
+ def self.foo
229
+ end
230
+
231
+ class << self
232
+ alias_method :foo, :bar
233
+ end
234
+ end
235
+ CODE
236
+
237
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
238
+
239
+ report.entries.empty?.should == true
240
+ end
241
+ end
242
+
243
+ context 'core Ruby methods' do
244
+ example 'do not add errors for #include' do
245
+ code = <<-CODE
246
+ module Foo
247
+ end
248
+
249
+ class Bar
250
+ include Foo
251
+ end
252
+ CODE
253
+
254
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
255
+
256
+ report.entries.empty?.should == true
257
+ end
258
+
259
+ example 'do not add errors for #attr_reader' do
260
+ code = <<-CODE
261
+ class Bar
262
+ attr_reader :foobar
263
+ end
264
+ CODE
265
+
266
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
267
+
268
+ report.entries.empty?.should == true
269
+ end
270
+ end
271
+
272
+ example 'properly handle method lookups in blocks' do
273
+ code = <<-CODE
274
+ class Foo
275
+ def baz
276
+ end
277
+
278
+ [10, 20].each do
279
+ define_method(:example) do
280
+ baz
281
+ end
282
+ end
283
+ end
284
+ CODE
285
+
286
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
287
+
288
+ report.entries.empty?.should == true
289
+ end
290
+
291
+ example 'do not add errors for private/protected/public' do
292
+ code = <<-CODE
293
+ private
294
+ protected
295
+ public
296
+ CODE
297
+
298
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
299
+
300
+ report.entries.empty?.should == true
301
+ end
302
+
303
+ example 'use the correct error message for YARD documented arguments' do
304
+ code = <<-CODE
305
+ ##
306
+ # @param [Fixnum|Bignum|Numeric] number
307
+ #
308
+ def double(number)
309
+ return number.to_foo
310
+ end
311
+ CODE
312
+
313
+ report = build_report(code, RubyLint::Analysis::UndefinedMethods)
314
+ entry = report.entries[0]
315
+
316
+ entry.line.should == 5
317
+ entry.message.should == 'undefined method to_foo on an instance of ' \
318
+ 'Fixnum, Bignum or Numeric'
319
+ end
320
+ end