ruby-lint 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +43 -29
  3. data/LICENSE +1 -1
  4. data/README.md +0 -1
  5. data/bin/ruby-lint +91 -3
  6. data/checksum/ruby-lint-1.1.0.gem.sha512 +1 -0
  7. data/doc/changelog.md +30 -0
  8. data/doc/code_analysis.md +13 -0
  9. data/doc/configuration.md +5 -24
  10. data/lib/ruby-lint.rb +7 -10
  11. data/lib/ruby-lint/analysis/argument_amount.rb +2 -0
  12. data/lib/ruby-lint/analysis/base.rb +12 -0
  13. data/lib/ruby-lint/analysis/pedantics.rb +2 -0
  14. data/lib/ruby-lint/analysis/shadowing_variables.rb +2 -0
  15. data/lib/ruby-lint/analysis/undefined_methods.rb +5 -2
  16. data/lib/ruby-lint/analysis/undefined_variables.rb +2 -0
  17. data/lib/ruby-lint/analysis/unused_variables.rb +2 -0
  18. data/lib/ruby-lint/analysis/useless_equality_checks.rb +2 -0
  19. data/lib/ruby-lint/ast/node.rb +0 -15
  20. data/lib/ruby-lint/command.rb +100 -0
  21. data/lib/ruby-lint/configuration.rb +35 -66
  22. data/lib/ruby-lint/constant_path.rb +7 -2
  23. data/lib/ruby-lint/definition/ruby_object.rb +20 -6
  24. data/lib/ruby-lint/definitions/core/argf.rb +3 -3
  25. data/lib/ruby-lint/definitions/gems/minitest.rb +792 -0
  26. data/lib/ruby-lint/file_list.rb +1 -1
  27. data/lib/ruby-lint/file_loader.rb +2 -20
  28. data/lib/ruby-lint/file_scanner.rb +11 -2
  29. data/lib/ruby-lint/method_evaluation.rb +21 -0
  30. data/lib/ruby-lint/presenter/base.rb +18 -0
  31. data/lib/ruby-lint/presenter/json.rb +3 -1
  32. data/lib/ruby-lint/presenter/syntastic.rb +3 -1
  33. data/lib/ruby-lint/presenter/text.rb +3 -1
  34. data/lib/ruby-lint/runner.rb +6 -63
  35. data/lib/ruby-lint/variable_predicates.rb +3 -3
  36. data/lib/ruby-lint/version.rb +1 -1
  37. data/lib/ruby-lint/virtual_machine.rb +4 -1
  38. data/ruby-lint.gemspec +13 -4
  39. metadata +12 -187
  40. data/.editorconfig +0 -15
  41. data/.gitignore +0 -6
  42. data/.ruby-version +0 -1
  43. data/.travis.yml +0 -19
  44. data/Gemfile +0 -15
  45. data/MANIFEST +0 -469
  46. data/Rakefile +0 -25
  47. data/benchmark/bootup.rb +0 -13
  48. data/benchmark/virtual_machine.rb +0 -17
  49. data/checksum/.gitkeep +0 -0
  50. data/doc/.gitkeep +0 -0
  51. data/doc/css/.gitkeep +0 -0
  52. data/doc/images/.gitkeep +0 -0
  53. data/gen/rails/constants.txt +0 -12
  54. data/gen/rails/requires.rb +0 -2
  55. data/gen/stdlib/constants.rb +0 -30
  56. data/gen/stdlib/constants.txt +0 -214
  57. data/gen/stdlib/requires.rb +0 -64
  58. data/lib/ruby-lint/benchmark/average.rb +0 -115
  59. data/lib/ruby-lint/cache.rb +0 -121
  60. data/lib/ruby-lint/cache_entry.rb +0 -44
  61. data/lib/ruby-lint/cli.rb +0 -4
  62. data/lib/ruby-lint/cli/analyze.rb +0 -209
  63. data/lib/ruby-lint/cli/base.rb +0 -103
  64. data/lib/ruby-lint/cli/cache.rb +0 -60
  65. data/lib/ruby-lint/default_names.rb +0 -19
  66. data/lib/ruby-lint/definitions/gems/.gitkeep +0 -0
  67. data/lib/ruby-lint/node_hash.rb +0 -105
  68. data/misc/stdlib.rb +0 -66
  69. data/profiling/virtual_machine.rb +0 -20
  70. data/ruby-lint.yml +0 -7
  71. data/spec/fixtures/associating.rb +0 -7
  72. data/spec/fixtures/complex/rails/basic_controller.rb +0 -9
  73. data/spec/fixtures/complex/rcap.rb +0 -67
  74. data/spec/fixtures/complex/slop.rb +0 -701
  75. data/spec/fixtures/config.yml +0 -8
  76. data/spec/fixtures/deeply/nested/file.rb +0 -1
  77. data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +0 -6
  78. data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +0 -8
  79. data/spec/fixtures/file_scanner/lib/example/user.rb +0 -6
  80. data/spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb +0 -6
  81. data/spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb +0 -6
  82. data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +0 -4
  83. data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +0 -6
  84. data/spec/fixtures/file_scanner/rails/app/models/user.rb +0 -4
  85. data/spec/fixtures/invalid.rb +0 -3
  86. data/spec/fixtures/invalid_2.rb +0 -3
  87. data/spec/fixtures/syntax_error.rb +0 -1
  88. data/spec/fixtures/uses_external.rb +0 -1
  89. data/spec/fixtures/uses_external_invalid.rb +0 -3
  90. data/spec/fixtures/uses_external_namespace.rb +0 -1
  91. data/spec/fixtures/valid.rb +0 -3
  92. data/spec/ruby-lint/analysis/argument_amount_spec.rb +0 -131
  93. data/spec/ruby-lint/analysis/base_spec.rb +0 -24
  94. data/spec/ruby-lint/analysis/pedantics_spec.rb +0 -63
  95. data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +0 -85
  96. data/spec/ruby-lint/analysis/undefined_methods_spec.rb +0 -337
  97. data/spec/ruby-lint/analysis/undefined_variables_spec.rb +0 -138
  98. data/spec/ruby-lint/analysis/unused_variables_spec.rb +0 -270
  99. data/spec/ruby-lint/analysis/useless_equality_checks_spec.rb +0 -107
  100. data/spec/ruby-lint/ast/node_spec.rb +0 -39
  101. data/spec/ruby-lint/cache_entry_spec.rb +0 -25
  102. data/spec/ruby-lint/cache_spec.rb +0 -53
  103. data/spec/ruby-lint/cli/analyze_spec.rb +0 -52
  104. data/spec/ruby-lint/configuration_spec.rb +0 -126
  105. data/spec/ruby-lint/constant_loader_spec.rb +0 -79
  106. data/spec/ruby-lint/constant_path.rb +0 -63
  107. data/spec/ruby-lint/definition/constant_proxy_spec.rb +0 -85
  108. data/spec/ruby-lint/definition/dsl_spec.rb +0 -135
  109. data/spec/ruby-lint/definition/registry_spec.rb +0 -106
  110. data/spec/ruby-lint/definition/ruby_method_spec.rb +0 -106
  111. data/spec/ruby-lint/definition/ruby_object_spec.rb +0 -264
  112. data/spec/ruby-lint/definition_builder/primitive_spec.rb +0 -62
  113. data/spec/ruby-lint/definition_builder/ruby_class_spec.rb +0 -107
  114. data/spec/ruby-lint/definition_builder/ruby_method_spec.rb +0 -53
  115. data/spec/ruby-lint/definition_builder/ruby_module_spec.rb +0 -52
  116. data/spec/ruby-lint/definitions/argv_spec.rb +0 -18
  117. data/spec/ruby-lint/definitions/env_spec.rb +0 -13
  118. data/spec/ruby-lint/definitions/file_spec.rb +0 -17
  119. data/spec/ruby-lint/definitions/fixnum_spec.rb +0 -18
  120. data/spec/ruby-lint/definitions/io_spec.rb +0 -15
  121. data/spec/ruby-lint/definitions/kernel_spec.rb +0 -18
  122. data/spec/ruby-lint/definitions/range_spec.rb +0 -21
  123. data/spec/ruby-lint/definitions/string_spec.rb +0 -20
  124. data/spec/ruby-lint/docstring/mapping.rb +0 -27
  125. data/spec/ruby-lint/docstring/parser_spec.rb +0 -88
  126. data/spec/ruby-lint/extensions/string_spec.rb +0 -7
  127. data/spec/ruby-lint/file_list_spec.rb +0 -25
  128. data/spec/ruby-lint/file_loader_spec.rb +0 -69
  129. data/spec/ruby-lint/file_scanner_spec.rb +0 -84
  130. data/spec/ruby-lint/inspector_spec.rb +0 -224
  131. data/spec/ruby-lint/iterator_spec.rb +0 -151
  132. data/spec/ruby-lint/method_call/.gitkeep +0 -0
  133. data/spec/ruby-lint/nested_stack_spec.rb +0 -23
  134. data/spec/ruby-lint/node_hash_spec.rb +0 -56
  135. data/spec/ruby-lint/parser_spec.rb +0 -38
  136. data/spec/ruby-lint/presenter/json_spec.rb +0 -58
  137. data/spec/ruby-lint/presenter/syntastic_spec.rb +0 -49
  138. data/spec/ruby-lint/presenter/text_spec.rb +0 -49
  139. data/spec/ruby-lint/report/entry_spec.rb +0 -58
  140. data/spec/ruby-lint/report_spec.rb +0 -39
  141. data/spec/ruby-lint/runner_spec.rb +0 -74
  142. data/spec/ruby-lint/variable_predicates_spec.rb +0 -30
  143. data/spec/ruby-lint/virtual_machine/alias_spec.rb +0 -55
  144. data/spec/ruby-lint/virtual_machine/assignments/arrays_spec.rb +0 -87
  145. data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +0 -14
  146. data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +0 -23
  147. data/spec/ruby-lint/virtual_machine/assignments/hashes_spec.rb +0 -52
  148. data/spec/ruby-lint/virtual_machine/assignments/optional_spec.rb +0 -41
  149. data/spec/ruby-lint/virtual_machine/assignments/range_spec.rb +0 -28
  150. data/spec/ruby-lint/virtual_machine/assignments/return_values_spec.rb +0 -78
  151. data/spec/ruby-lint/virtual_machine/assignments/variables_spec.rb +0 -130
  152. data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +0 -61
  153. data/spec/ruby-lint/virtual_machine/autoloading_spec.rb +0 -18
  154. data/spec/ruby-lint/virtual_machine/blocks_spec.rb +0 -90
  155. data/spec/ruby-lint/virtual_machine/classes/class_methods_spec.rb +0 -21
  156. data/spec/ruby-lint/virtual_machine/classes/extending_spec.rb +0 -109
  157. data/spec/ruby-lint/virtual_machine/classes/redefining_spec.rb +0 -51
  158. data/spec/ruby-lint/virtual_machine/classes/sclass_spec.rb +0 -96
  159. data/spec/ruby-lint/virtual_machine/classes/scoping_spec.rb +0 -60
  160. data/spec/ruby-lint/virtual_machine/complex/rails_spec.rb +0 -21
  161. data/spec/ruby-lint/virtual_machine/complex/rcap_spec.rb +0 -15
  162. data/spec/ruby-lint/virtual_machine/complex/slop_spec.rb +0 -16
  163. data/spec/ruby-lint/virtual_machine/constants_spec.rb +0 -31
  164. data/spec/ruby-lint/virtual_machine/for_spec.rb +0 -16
  165. data/spec/ruby-lint/virtual_machine/freeze_spec.rb +0 -13
  166. data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +0 -15
  167. data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +0 -15
  168. data/spec/ruby-lint/virtual_machine/interpolation_spec.rb +0 -12
  169. data/spec/ruby-lint/virtual_machine/location_spec.rb +0 -64
  170. data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +0 -57
  171. data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +0 -182
  172. data/spec/ruby-lint/virtual_machine/methods/calls_spec.rb +0 -25
  173. data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +0 -41
  174. data/spec/ruby-lint/virtual_machine/methods/defining_spec.rb +0 -40
  175. data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +0 -80
  176. data/spec/ruby-lint/virtual_machine/methods/exporting_spec.rb +0 -19
  177. data/spec/ruby-lint/virtual_machine/methods/kernel_spec.rb +0 -25
  178. data/spec/ruby-lint/virtual_machine/methods/parameters_spec.rb +0 -89
  179. data/spec/ruby-lint/virtual_machine/methods/patching_spec.rb +0 -20
  180. data/spec/ruby-lint/virtual_machine/methods/scoping_spec.rb +0 -63
  181. data/spec/ruby-lint/virtual_machine/methods/square_bracket_spec.rb +0 -32
  182. data/spec/ruby-lint/virtual_machine/methods/visibility_spec.rb +0 -64
  183. data/spec/ruby-lint/virtual_machine/modules_spec.rb +0 -205
  184. data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +0 -81
  185. data/spec/ruby-lint/virtual_machine/self_spec.rb +0 -37
  186. data/spec/ruby-lint/virtual_machine/unused_spec.rb +0 -17
  187. data/spec/spec_helper.rb +0 -28
  188. data/spec/support/building.rb +0 -50
  189. data/spec/support/coveralls.rb +0 -5
  190. data/spec/support/definitions.rb +0 -39
  191. data/spec/support/fixtures.rb +0 -20
  192. data/spec/support/parsing.rb +0 -30
  193. data/spec/support/simplecov.rb +0 -18
  194. data/spec/support/versions.rb +0 -9
  195. data/task/build.rake +0 -4
  196. data/task/checksum.rake +0 -13
  197. data/task/coverage.rake +0 -6
  198. data/task/doc.rake +0 -16
  199. data/task/generate.rake +0 -77
  200. data/task/graphviz.rake +0 -12
  201. data/task/manifest.rake +0 -8
  202. data/task/tag.rake +0 -6
  203. data/task/test.rake +0 -4
  204. data/task/todo.rake +0 -6
  205. data/task/travis.rake +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd18d2ac845d4520591324dc3491cbd5a3d9b0ca
4
- data.tar.gz: b7a344031e1b300104e1331486dbc4b8903ff9c8
3
+ metadata.gz: 512dbfa14fa8cd418ab6aa742b5b9674c8d099e5
4
+ data.tar.gz: 753e74eacbb26c7d0c1ca1e824811f50383eeb57
5
5
  SHA512:
6
- metadata.gz: 78ad431d97cef27b33f53842e36b46771895a3d1cef0ce8982a77245e5ce3b1c1400318ece043a24a594277eb21ab5dad6026d74473c9d1c9354a5289ddf6309
7
- data.tar.gz: c6010baaeb8aec96bdaf8a00eb80c92a186be594fa20136e45a3a374749c20588a3a0dd8bac2dd659d7f911eb40cd321f28f291dd1c3dd92daf6932d7fd3234f
6
+ metadata.gz: e9b624c1fe46dc6493a9fc0a85f4ce8a8c737a08f696b140e626b276b7e98f738a3e5722ea2773795b51cd33549542210dbafede324dd3ca5487ea5c197fdcfc
7
+ data.tar.gz: 439fe12246a52f2403101a738eedf13bbd95795ecc6cfb53c4585070a74e80e2ab13a8d5ff93a7dee6276b890791f2c006edec68d2efb349cfc7a51c0071d6ca
@@ -1,39 +1,53 @@
1
1
  # Contributing
2
2
 
3
- Those that wish to contribute to ruby-lint are more than welcome. However, to
4
- make the lifes of both me and others easier there are a few things one should
5
- keep in mind.
6
-
7
- The gist of this is as following:
8
-
9
- * Write tests
10
- * Write documentation using YARD (at the very least arguments and return values
11
- should be documented)
12
- * Wrap lines at 79 characters per line
3
+ Everybody is more than welcome to contribute to ruby-lint, no matter how small
4
+ the change. To keep everything running smoothly there are a few guidelines that
5
+ one should follow. These are as following:
6
+
7
+ * When changing code make sure to write RSpec tests for the changes.
8
+ * Document code using YARD. At the very least the method arguments and return
9
+ value(s) should be documented.
10
+ * Wrap lines at 79 characters per line.
13
11
  * Git commits should have a <= 50 character summary, optionally followed by a
14
12
  blank line and a more in depth description of 79 characters per line.
15
13
 
16
- More information can be found here:
17
- <http://yorickpeterse.com/articles/contributing-to-my-code/>. If you have any
18
- questions or whatsoever don't hesitate to ask and don't worry about making
19
- mistakes (e.g. missing some documentation), I'll help wherever I can and won't
20
- slap you with a large trout.
14
+ ## Editor Setup
21
15
 
22
- ## Legal
16
+ Whatever editor you use doesn't matter as long as it can do two things:
17
+
18
+ * Use spaces for indentation.
19
+ * Hard wrap lines at 79 characters per line.
20
+
21
+ To make this process easier Oga comes with an [EditorConfig][editorconfig]
22
+ configuration file. If your editor supports this it will automatically apply
23
+ the required settings for you.
24
+
25
+ ## Hacking on ruby-lint
26
+
27
+ Assuming you have a local Git clone of ruby-lint, the first step should be to
28
+ install all the required Gems:
23
29
 
24
- Legal wise there are two files to take into account:
30
+ bundle install
25
31
 
26
- * LICENSE
27
- * doc/DCO.md
32
+ Next up, run the tests to make sure everything is working:
33
+
34
+ rake
35
+ rspec spec # also fine
36
+
37
+ For more information about the available tasks, run `rake -T`.
38
+
39
+ ## Contact
40
+
41
+ In case you have any further questions or would like to receive feedback before
42
+ submitting a change, feel free to contact me. You can either open an issue,
43
+ send a tweet to [@yorickpeterse][twitter] or send an Email to
44
+ <yorickpeterse@gmail.com>.
45
+
46
+ ## Legal
28
47
 
29
- The LICENSE file contains a copy of the MIT license. All ruby-lint source code
30
- and related files (basically whatever this repository and the resulting Gem
31
- contains) are licensed under the MIT license unless specified otherwise.
48
+ By contributing to ruby-lint you agree with both the Developer's Certificate of
49
+ origin, found in `doc/DCO.md` and the license, found in `LICENSE`. This applies
50
+ to all content in this repository unless stated otherwise.
32
51
 
33
- The DCO contains a agreement for developers that basically specifies that they
34
- agree with the license and that whatever they contribute is something they are
35
- allowed to contribute. By contributing to ruby-lint you automatically agree
36
- with this DCO so it's worth giving a read. The DCO is put in to place to ensure
37
- that whenever somebody gets mad at me for using proprietary code contributed by
38
- somebody else I have at least something to defend myself with. Lets just hope I
39
- never have to.
52
+ [editorconfig]:http://editorconfig.org/
53
+ [twitter]: https://twitter.com/yorickpeterse
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 - 2013, Yorick Peterse
1
+ Copyright (c) 2012 - 2014, Yorick Peterse
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # ruby-lint
2
2
 
3
3
  [![Build Status](https://travis-ci.org/YorickPeterse/ruby-lint.png?branch=master)](https://travis-ci.org/YorickPeterse/ruby-lint)
4
- [![Coverage Status](https://coveralls.io/repos/YorickPeterse/ruby-lint/badge.png?branch=master)](https://coveralls.io/r/YorickPeterse/ruby-lint)
5
4
  [![Code Climate](https://codeclimate.com/github/YorickPeterse/ruby-lint.png)](https://codeclimate.com/github/YorickPeterse/ruby-lint)
6
5
 
7
6
  ruby-lint is a static code analysis tool for Ruby. It is inspired by tools such
@@ -1,6 +1,94 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path('../../lib/ruby-lint', __FILE__)
4
- require File.expand_path('../../lib/ruby-lint/cli', __FILE__)
3
+ require_relative '../lib/ruby-lint'
5
4
 
6
- RubyLint::CLI.run
5
+ require 'slop'
6
+
7
+ slop = Slop.new(:strict => true) do
8
+ banner 'Usage: ruby-lint [FILES] [OPTIONS]'
9
+ description 'Analyze the source code of Ruby files'
10
+
11
+ separator <<-EOF.chomp
12
+
13
+ About:
14
+
15
+ Analyses the source code of a Ruby file and presents a report containing
16
+ information such as errors about invalid code, warnings and informational
17
+ messages.
18
+
19
+ Configuration:
20
+
21
+ When this command is executed it will try to load a configuration file in
22
+ one of the following two locations (in this order):
23
+
24
+ * $PWD/ruby-lint.yml
25
+ * ~/.ruby-lint.yml
26
+
27
+ Only the first existing configuration file is loaded.
28
+
29
+ These configuration files can be used for specifying the presenter, reporting
30
+ levels and various other options.
31
+
32
+ You can also configure various parts using the supplied commandline options.
33
+ For example, to use the JSON presenter you'd run the following:
34
+
35
+ $ ruby-lint ./test_file.rb --presenter=json
36
+
37
+ Analysis Classes:
38
+
39
+ #{RubyLint::Command.format_names(:available_analysis_classes)}
40
+
41
+ Presenters:
42
+
43
+ #{RubyLint::Command.format_names(:available_presenters)}
44
+
45
+ Reporting Levels:
46
+
47
+ #{RubyLint::Command.format_names(:available_report_levels)}
48
+
49
+ Examples:
50
+
51
+ To analyze a single file you can run the following command:
52
+
53
+ $ ruby-lint ./test_file.rb
54
+
55
+ You can also specify multiple files:
56
+
57
+ $ ruby-lint first_file.rb second_file.rb
58
+
59
+ Run analysis on an entire directory:
60
+
61
+ $ ruby-lint lib/
62
+ EOF
63
+
64
+ separator "\nOptions:\n"
65
+
66
+ on :h, :help, 'Shows this help message' do
67
+ puts self
68
+ exit
69
+ end
70
+
71
+ on :v, :version, 'Shows the current version' do
72
+ puts "ruby-lint v#{RubyLint::VERSION} on #{RUBY_DESCRIPTION}"
73
+ exit
74
+ end
75
+
76
+ on :l=, :levels=, 'The reporting levels to enable', :as => Array
77
+ on :p=, :presenter=, 'The presenter to use', :as => String
78
+ on :a=, :analysis=, 'The analysis classes to use', :as => Array
79
+ on :b, :benchmark, 'Enables benchmarking mode'
80
+
81
+ run do |opts, args|
82
+ abort 'You must specify at least one file to analyze' if args.empty?
83
+
84
+ command = RubyLint::Command.new(opts)
85
+
86
+ begin
87
+ command.run(args)
88
+ rescue Errno::ENOENT => error
89
+ abort error.message
90
+ end
91
+ end
92
+ end
93
+
94
+ slop.parse
@@ -0,0 +1 @@
1
+ 4558bf03ee277a8334cd79eeaac6f0f8f0e59a4dd7fbc03b90de0f82f4bd6b873b505278b82b3bd15ae60c429a73eeb1e3efd4ca1f8210321c2ac7c9c720aace
@@ -5,6 +5,36 @@ 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
+ ## 2.0.0 - 2014-06-06
9
+
10
+ Although the version number might suggest otherwise this is a rather modest
11
+ release compared to previous releases.
12
+
13
+ There are 3 big changes in this release:
14
+
15
+ 1. A refactored and less confusing CLI.
16
+ 2. The caching system has been removed as it was too problematic.
17
+ 3. The API used for registering analysis classes has been changed to make it
18
+ easier to register custom classes.
19
+
20
+ The first change is not backwards compatible with previous releases of
21
+ ruby-lint, hence the mayor version increase.
22
+
23
+ The following other changes are included in this release:
24
+
25
+ * Fuzzy file matching when scanning for external files has been removed. This
26
+ was too problematic and would cause problems such as
27
+ <https://github.com/YorickPeterse/ruby-lint/issues/105>.
28
+ * Definitions for Minitest have been added.
29
+ * Proper handling of methods called on block return values.
30
+ * Constant paths with variables in them are handled properly.
31
+ * Diagnostics emitted by the parser Gem are re-used properly by ruby-lint
32
+ instead of always being displayed as errors.
33
+ * ARGF is handled with extra care so that ruby-lint doesn't throw tons of false
34
+ positives.
35
+ * Debug output has been removed from the CLI, it will be replaced with a better
36
+ system in the near future.
37
+
8
38
  ## 1.1.0 - 2014-02-02
9
39
 
10
40
  This release changes the way the definitions system works so that it no longer
@@ -108,3 +108,16 @@ For example, if you only want to analyze RSpec files:
108
108
  end
109
109
 
110
110
  By default all analysis classes are enabled.
111
+
112
+ ## Registering Analysis Classes
113
+
114
+ In order for a analysis class to become available in {RubyLint::Configuration}
115
+ objects, either via the CLI or via Ruby directly, you must register the
116
+ analysis class. This can be done by calling the class method
117
+ {RubyLint::Analysis::Base.register}:
118
+
119
+ class CamelCaseVariables < RubyLint::Analysis::Base
120
+ register 'camel_case_variables'
121
+ end
122
+
123
+ The value should be a `snake_cased` string that matches the class name.
@@ -54,9 +54,11 @@ Example:
54
54
 
55
55
  ---
56
56
  requires:
57
- - ruby-lint/definitions/rails
57
+ - ruby-lint/definitions/gems/devise
58
58
 
59
- By default this option is left empty.
59
+ By default this option is left empty. You do not need to use this option for
60
+ loading built-in definitions unless stated otherwise. For example, definitions
61
+ for Rails are loaded automatically.
60
62
 
61
63
  ### report_levels
62
64
 
@@ -103,6 +105,7 @@ The following analysis classes are currently available:
103
105
  * `undefined_methods`
104
106
  * `undefined_variables`
105
107
  * `unused_variables`
108
+ * `useless_equality_checks`
106
109
 
107
110
  By default all of these are enabled.
108
111
 
@@ -154,25 +157,3 @@ Example:
154
157
  ---
155
158
  ignore_paths:
156
159
  - lib/ruby-lint/definitions
157
-
158
- ### enable_cache
159
-
160
- A boolean that indicates that caching should be enabled or disabled, by default
161
- this is enabled. Disabling caching can slow down ruby-lint considerably.
162
-
163
- Example:
164
-
165
- ---
166
- enable_cache: true
167
-
168
- ### cache_directory
169
-
170
- The directory to store cache files in if caching is enabled. By default this is
171
- set to `$XDG_CACHE_HOME/ruby-lint` or `$HOME/.cache/ruby-lint` if the former
172
- variable isn't set. If the cache directory doesn't exist it's created
173
- automatically.
174
-
175
- Example:
176
-
177
- ---
178
- cache_directory: ~/ruby-lint
@@ -5,28 +5,29 @@ require 'parser/current'
5
5
 
6
6
  require 'yaml'
7
7
  require 'set'
8
- require 'digest/sha1'
9
8
  require 'zlib'
10
9
 
11
10
  require_relative 'ruby-lint/extensions/string'
12
11
 
13
12
  require_relative 'ruby-lint/ruby_lint'
13
+ require_relative 'ruby-lint/version'
14
14
  require_relative 'ruby-lint/variable_predicates'
15
+ require_relative 'ruby-lint/method_evaluation'
15
16
  require_relative 'ruby-lint/ast/node'
16
17
  require_relative 'ruby-lint/ast/builder'
17
18
  require_relative 'ruby-lint/parser'
18
19
  require_relative 'ruby-lint/file_scanner'
19
20
  require_relative 'ruby-lint/file_list'
20
21
  require_relative 'ruby-lint/nested_stack'
22
+ require_relative 'ruby-lint/configuration'
23
+ require_relative 'ruby-lint/runner'
24
+ require_relative 'ruby-lint/command'
25
+
21
26
  require_relative 'ruby-lint/docstring/parser'
22
27
  require_relative 'ruby-lint/docstring/param_tag'
23
28
  require_relative 'ruby-lint/docstring/return_tag'
24
29
  require_relative 'ruby-lint/docstring/mapping'
25
30
 
26
- require_relative 'ruby-lint/node_hash'
27
- require_relative 'ruby-lint/cache'
28
- require_relative 'ruby-lint/cache_entry'
29
-
30
31
  require_relative 'ruby-lint/constant_path'
31
32
  require_relative 'ruby-lint/inspector'
32
33
 
@@ -70,11 +71,7 @@ require_relative 'ruby-lint/analysis/useless_equality_checks'
70
71
  require_relative 'ruby-lint/report'
71
72
  require_relative 'ruby-lint/report/entry'
72
73
 
74
+ require_relative 'ruby-lint/presenter/base'
73
75
  require_relative 'ruby-lint/presenter/text'
74
76
  require_relative 'ruby-lint/presenter/json'
75
77
  require_relative 'ruby-lint/presenter/syntastic'
76
-
77
- require_relative 'ruby-lint/configuration'
78
- require_relative 'ruby-lint/default_names'
79
- require_relative 'ruby-lint/runner'
80
- require_relative 'ruby-lint/version'
@@ -6,6 +6,8 @@ module RubyLint
6
6
  # amount was given.
7
7
  #
8
8
  class ArgumentAmount < Base
9
+ register 'argument_amount'
10
+
9
11
  ##
10
12
  # Hash that contains method names that should be used for analysis
11
13
  # instead of the ones specified in the keys.
@@ -14,6 +14,8 @@ module RubyLint
14
14
  # @return [RubyLint::Configuration]
15
15
  #
16
16
  class Base < Iterator
17
+ include MethodEvaluation
18
+
17
19
  attr_reader :report, :vm, :config
18
20
 
19
21
  ##
@@ -24,6 +26,16 @@ module RubyLint
24
26
  #
25
27
  SCOPES = [:root, :block, :class, :def, :module, :sclass]
26
28
 
29
+ ##
30
+ # Registers the current class in
31
+ # {RubyLint::Configuration.available_analysis_classes}.
32
+ #
33
+ # @param [String] name A human friendly name of the current class.
34
+ #
35
+ def self.register(name)
36
+ Configuration.available_analysis_classes[name] = self
37
+ end
38
+
27
39
  ##
28
40
  # Returns a boolean that indicates if the analysis class should be used
29
41
  # or not.
@@ -6,6 +6,8 @@ module RubyLint
6
6
  # statements and various other pedantics.
7
7
  #
8
8
  class Pedantics < Base
9
+ register 'pedantics'
10
+
9
11
  [:if, :unless, :until, :while].each do |type|
10
12
  define_method("on_#{type}") do |node|
11
13
  if node.location.respond_to?(:begin) and node.location.begin
@@ -13,6 +13,8 @@ module RubyLint
13
13
  # end
14
14
  #
15
15
  class ShadowingVariables < Base
16
+ register 'shadowing_variables'
17
+
16
18
  ##
17
19
  # @param [RubyLint::AST::Node] node
18
20
  #
@@ -12,14 +12,17 @@ module RubyLint
12
12
  # 'test'.foobar # => undefined method foobar on an instance of String
13
13
  #
14
14
  class UndefinedMethods < Base
15
+ register 'undefined_methods'
16
+
15
17
  ##
16
18
  # @param [RubyLint::AST::Node] node
17
19
  #
18
20
  def on_send(node)
19
21
  receiver, name, _ = *node
20
22
 
21
- name = name.to_s
22
- scope = current_scope
23
+ receiver = unpack_block(receiver)
24
+ name = name.to_s
25
+ scope = current_scope
23
26
 
24
27
  if receiver and vm.associations.key?(receiver)
25
28
  scope = vm.associations[receiver]
@@ -10,6 +10,8 @@ module RubyLint
10
10
  # {RubyLint::Analysis::UndefinedMethods} instead.
11
11
  #
12
12
  class UndefinedVariables < Base
13
+ register 'undefined_variables'
14
+
13
15
  ##
14
16
  # Hash containing the various variable types to add errors for whenever
15
17
  # they are used but not defined.