ruby-lint 1.1.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +43 -29
- data/LICENSE +1 -1
- data/README.md +0 -1
- data/bin/ruby-lint +91 -3
- data/checksum/ruby-lint-1.1.0.gem.sha512 +1 -0
- data/doc/changelog.md +30 -0
- data/doc/code_analysis.md +13 -0
- data/doc/configuration.md +5 -24
- data/lib/ruby-lint.rb +7 -10
- data/lib/ruby-lint/analysis/argument_amount.rb +2 -0
- data/lib/ruby-lint/analysis/base.rb +12 -0
- data/lib/ruby-lint/analysis/pedantics.rb +2 -0
- data/lib/ruby-lint/analysis/shadowing_variables.rb +2 -0
- data/lib/ruby-lint/analysis/undefined_methods.rb +5 -2
- data/lib/ruby-lint/analysis/undefined_variables.rb +2 -0
- data/lib/ruby-lint/analysis/unused_variables.rb +2 -0
- data/lib/ruby-lint/analysis/useless_equality_checks.rb +2 -0
- data/lib/ruby-lint/ast/node.rb +0 -15
- data/lib/ruby-lint/command.rb +100 -0
- data/lib/ruby-lint/configuration.rb +35 -66
- data/lib/ruby-lint/constant_path.rb +7 -2
- data/lib/ruby-lint/definition/ruby_object.rb +20 -6
- data/lib/ruby-lint/definitions/core/argf.rb +3 -3
- data/lib/ruby-lint/definitions/gems/minitest.rb +792 -0
- data/lib/ruby-lint/file_list.rb +1 -1
- data/lib/ruby-lint/file_loader.rb +2 -20
- data/lib/ruby-lint/file_scanner.rb +11 -2
- data/lib/ruby-lint/method_evaluation.rb +21 -0
- data/lib/ruby-lint/presenter/base.rb +18 -0
- data/lib/ruby-lint/presenter/json.rb +3 -1
- data/lib/ruby-lint/presenter/syntastic.rb +3 -1
- data/lib/ruby-lint/presenter/text.rb +3 -1
- data/lib/ruby-lint/runner.rb +6 -63
- data/lib/ruby-lint/variable_predicates.rb +3 -3
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +4 -1
- data/ruby-lint.gemspec +13 -4
- metadata +12 -187
- data/.editorconfig +0 -15
- data/.gitignore +0 -6
- data/.ruby-version +0 -1
- data/.travis.yml +0 -19
- data/Gemfile +0 -15
- data/MANIFEST +0 -469
- data/Rakefile +0 -25
- data/benchmark/bootup.rb +0 -13
- data/benchmark/virtual_machine.rb +0 -17
- data/checksum/.gitkeep +0 -0
- data/doc/.gitkeep +0 -0
- data/doc/css/.gitkeep +0 -0
- data/doc/images/.gitkeep +0 -0
- data/gen/rails/constants.txt +0 -12
- data/gen/rails/requires.rb +0 -2
- data/gen/stdlib/constants.rb +0 -30
- data/gen/stdlib/constants.txt +0 -214
- data/gen/stdlib/requires.rb +0 -64
- data/lib/ruby-lint/benchmark/average.rb +0 -115
- data/lib/ruby-lint/cache.rb +0 -121
- data/lib/ruby-lint/cache_entry.rb +0 -44
- data/lib/ruby-lint/cli.rb +0 -4
- data/lib/ruby-lint/cli/analyze.rb +0 -209
- data/lib/ruby-lint/cli/base.rb +0 -103
- data/lib/ruby-lint/cli/cache.rb +0 -60
- data/lib/ruby-lint/default_names.rb +0 -19
- data/lib/ruby-lint/definitions/gems/.gitkeep +0 -0
- data/lib/ruby-lint/node_hash.rb +0 -105
- data/misc/stdlib.rb +0 -66
- data/profiling/virtual_machine.rb +0 -20
- data/ruby-lint.yml +0 -7
- data/spec/fixtures/associating.rb +0 -7
- data/spec/fixtures/complex/rails/basic_controller.rb +0 -9
- data/spec/fixtures/complex/rcap.rb +0 -67
- data/spec/fixtures/complex/slop.rb +0 -701
- data/spec/fixtures/config.yml +0 -8
- data/spec/fixtures/deeply/nested/file.rb +0 -1
- data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +0 -6
- data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +0 -8
- data/spec/fixtures/file_scanner/lib/example/user.rb +0 -6
- data/spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb +0 -6
- data/spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb +0 -6
- data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +0 -4
- data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +0 -6
- data/spec/fixtures/file_scanner/rails/app/models/user.rb +0 -4
- data/spec/fixtures/invalid.rb +0 -3
- data/spec/fixtures/invalid_2.rb +0 -3
- data/spec/fixtures/syntax_error.rb +0 -1
- data/spec/fixtures/uses_external.rb +0 -1
- data/spec/fixtures/uses_external_invalid.rb +0 -3
- data/spec/fixtures/uses_external_namespace.rb +0 -1
- data/spec/fixtures/valid.rb +0 -3
- data/spec/ruby-lint/analysis/argument_amount_spec.rb +0 -131
- data/spec/ruby-lint/analysis/base_spec.rb +0 -24
- data/spec/ruby-lint/analysis/pedantics_spec.rb +0 -63
- data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +0 -85
- data/spec/ruby-lint/analysis/undefined_methods_spec.rb +0 -337
- data/spec/ruby-lint/analysis/undefined_variables_spec.rb +0 -138
- data/spec/ruby-lint/analysis/unused_variables_spec.rb +0 -270
- data/spec/ruby-lint/analysis/useless_equality_checks_spec.rb +0 -107
- data/spec/ruby-lint/ast/node_spec.rb +0 -39
- data/spec/ruby-lint/cache_entry_spec.rb +0 -25
- data/spec/ruby-lint/cache_spec.rb +0 -53
- data/spec/ruby-lint/cli/analyze_spec.rb +0 -52
- data/spec/ruby-lint/configuration_spec.rb +0 -126
- data/spec/ruby-lint/constant_loader_spec.rb +0 -79
- data/spec/ruby-lint/constant_path.rb +0 -63
- data/spec/ruby-lint/definition/constant_proxy_spec.rb +0 -85
- data/spec/ruby-lint/definition/dsl_spec.rb +0 -135
- data/spec/ruby-lint/definition/registry_spec.rb +0 -106
- data/spec/ruby-lint/definition/ruby_method_spec.rb +0 -106
- data/spec/ruby-lint/definition/ruby_object_spec.rb +0 -264
- data/spec/ruby-lint/definition_builder/primitive_spec.rb +0 -62
- data/spec/ruby-lint/definition_builder/ruby_class_spec.rb +0 -107
- data/spec/ruby-lint/definition_builder/ruby_method_spec.rb +0 -53
- data/spec/ruby-lint/definition_builder/ruby_module_spec.rb +0 -52
- data/spec/ruby-lint/definitions/argv_spec.rb +0 -18
- data/spec/ruby-lint/definitions/env_spec.rb +0 -13
- data/spec/ruby-lint/definitions/file_spec.rb +0 -17
- data/spec/ruby-lint/definitions/fixnum_spec.rb +0 -18
- data/spec/ruby-lint/definitions/io_spec.rb +0 -15
- data/spec/ruby-lint/definitions/kernel_spec.rb +0 -18
- data/spec/ruby-lint/definitions/range_spec.rb +0 -21
- data/spec/ruby-lint/definitions/string_spec.rb +0 -20
- data/spec/ruby-lint/docstring/mapping.rb +0 -27
- data/spec/ruby-lint/docstring/parser_spec.rb +0 -88
- data/spec/ruby-lint/extensions/string_spec.rb +0 -7
- data/spec/ruby-lint/file_list_spec.rb +0 -25
- data/spec/ruby-lint/file_loader_spec.rb +0 -69
- data/spec/ruby-lint/file_scanner_spec.rb +0 -84
- data/spec/ruby-lint/inspector_spec.rb +0 -224
- data/spec/ruby-lint/iterator_spec.rb +0 -151
- data/spec/ruby-lint/method_call/.gitkeep +0 -0
- data/spec/ruby-lint/nested_stack_spec.rb +0 -23
- data/spec/ruby-lint/node_hash_spec.rb +0 -56
- data/spec/ruby-lint/parser_spec.rb +0 -38
- data/spec/ruby-lint/presenter/json_spec.rb +0 -58
- data/spec/ruby-lint/presenter/syntastic_spec.rb +0 -49
- data/spec/ruby-lint/presenter/text_spec.rb +0 -49
- data/spec/ruby-lint/report/entry_spec.rb +0 -58
- data/spec/ruby-lint/report_spec.rb +0 -39
- data/spec/ruby-lint/runner_spec.rb +0 -74
- data/spec/ruby-lint/variable_predicates_spec.rb +0 -30
- data/spec/ruby-lint/virtual_machine/alias_spec.rb +0 -55
- data/spec/ruby-lint/virtual_machine/assignments/arrays_spec.rb +0 -87
- data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +0 -14
- data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +0 -23
- data/spec/ruby-lint/virtual_machine/assignments/hashes_spec.rb +0 -52
- data/spec/ruby-lint/virtual_machine/assignments/optional_spec.rb +0 -41
- data/spec/ruby-lint/virtual_machine/assignments/range_spec.rb +0 -28
- data/spec/ruby-lint/virtual_machine/assignments/return_values_spec.rb +0 -78
- data/spec/ruby-lint/virtual_machine/assignments/variables_spec.rb +0 -130
- data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +0 -61
- data/spec/ruby-lint/virtual_machine/autoloading_spec.rb +0 -18
- data/spec/ruby-lint/virtual_machine/blocks_spec.rb +0 -90
- data/spec/ruby-lint/virtual_machine/classes/class_methods_spec.rb +0 -21
- data/spec/ruby-lint/virtual_machine/classes/extending_spec.rb +0 -109
- data/spec/ruby-lint/virtual_machine/classes/redefining_spec.rb +0 -51
- data/spec/ruby-lint/virtual_machine/classes/sclass_spec.rb +0 -96
- data/spec/ruby-lint/virtual_machine/classes/scoping_spec.rb +0 -60
- data/spec/ruby-lint/virtual_machine/complex/rails_spec.rb +0 -21
- data/spec/ruby-lint/virtual_machine/complex/rcap_spec.rb +0 -15
- data/spec/ruby-lint/virtual_machine/complex/slop_spec.rb +0 -16
- data/spec/ruby-lint/virtual_machine/constants_spec.rb +0 -31
- data/spec/ruby-lint/virtual_machine/for_spec.rb +0 -16
- data/spec/ruby-lint/virtual_machine/freeze_spec.rb +0 -13
- data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +0 -15
- data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +0 -15
- data/spec/ruby-lint/virtual_machine/interpolation_spec.rb +0 -12
- data/spec/ruby-lint/virtual_machine/location_spec.rb +0 -64
- data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +0 -57
- data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +0 -182
- data/spec/ruby-lint/virtual_machine/methods/calls_spec.rb +0 -25
- data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +0 -41
- data/spec/ruby-lint/virtual_machine/methods/defining_spec.rb +0 -40
- data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +0 -80
- data/spec/ruby-lint/virtual_machine/methods/exporting_spec.rb +0 -19
- data/spec/ruby-lint/virtual_machine/methods/kernel_spec.rb +0 -25
- data/spec/ruby-lint/virtual_machine/methods/parameters_spec.rb +0 -89
- data/spec/ruby-lint/virtual_machine/methods/patching_spec.rb +0 -20
- data/spec/ruby-lint/virtual_machine/methods/scoping_spec.rb +0 -63
- data/spec/ruby-lint/virtual_machine/methods/square_bracket_spec.rb +0 -32
- data/spec/ruby-lint/virtual_machine/methods/visibility_spec.rb +0 -64
- data/spec/ruby-lint/virtual_machine/modules_spec.rb +0 -205
- data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +0 -81
- data/spec/ruby-lint/virtual_machine/self_spec.rb +0 -37
- data/spec/ruby-lint/virtual_machine/unused_spec.rb +0 -17
- data/spec/spec_helper.rb +0 -28
- data/spec/support/building.rb +0 -50
- data/spec/support/coveralls.rb +0 -5
- data/spec/support/definitions.rb +0 -39
- data/spec/support/fixtures.rb +0 -20
- data/spec/support/parsing.rb +0 -30
- data/spec/support/simplecov.rb +0 -18
- data/spec/support/versions.rb +0 -9
- data/task/build.rake +0 -4
- data/task/checksum.rake +0 -13
- data/task/coverage.rake +0 -6
- data/task/doc.rake +0 -16
- data/task/generate.rake +0 -77
- data/task/graphviz.rake +0 -12
- data/task/manifest.rake +0 -8
- data/task/tag.rake +0 -6
- data/task/test.rake +0 -4
- data/task/todo.rake +0 -6
- data/task/travis.rake +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 512dbfa14fa8cd418ab6aa742b5b9674c8d099e5
|
|
4
|
+
data.tar.gz: 753e74eacbb26c7d0c1ca1e824811f50383eeb57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9b624c1fe46dc6493a9fc0a85f4ce8a8c737a08f696b140e626b276b7e98f738a3e5722ea2773795b51cd33549542210dbafede324dd3ca5487ea5c197fdcfc
|
|
7
|
+
data.tar.gz: 439fe12246a52f2403101a738eedf13bbd95795ecc6cfb53c4585070a74e80e2ab13a8d5ff93a7dee6276b890791f2c006edec68d2efb349cfc7a51c0071d6ca
|
data/CONTRIBUTING.md
CHANGED
|
@@ -1,39 +1,53 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
+
bundle install
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
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
data/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# ruby-lint
|
|
2
2
|
|
|
3
3
|
[](https://travis-ci.org/YorickPeterse/ruby-lint)
|
|
4
|
-
[](https://coveralls.io/r/YorickPeterse/ruby-lint)
|
|
5
4
|
[](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
|
data/bin/ruby-lint
CHANGED
|
@@ -1,6 +1,94 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../lib/ruby-lint/cli', __FILE__)
|
|
3
|
+
require_relative '../lib/ruby-lint'
|
|
5
4
|
|
|
6
|
-
|
|
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
|
data/doc/changelog.md
CHANGED
|
@@ -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
|
data/doc/code_analysis.md
CHANGED
|
@@ -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.
|
data/doc/configuration.md
CHANGED
|
@@ -54,9 +54,11 @@ Example:
|
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
requires:
|
|
57
|
-
- ruby-lint/definitions/
|
|
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
|
data/lib/ruby-lint.rb
CHANGED
|
@@ -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'
|
|
@@ -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
|
|
@@ -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
|
-
|
|
22
|
-
|
|
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.
|