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.
- checksums.yaml +7 -0
- checksums.yaml.gz.asc +17 -0
- data.tar.gz.asc +14 -14
- data/.ruby-version +1 -0
- data/.travis.yml +0 -1
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +41 -0
- data/MANIFEST +99 -66
- data/README.md +36 -10
- data/Rakefile +6 -0
- data/checksum/ruby-lint-0.0.4.gem.sha512 +1 -0
- data/doc/changelog.md +94 -0
- data/lib/ruby-lint.rb +18 -1
- data/lib/ruby-lint/analysis/argument_amount.rb +43 -10
- data/lib/ruby-lint/analysis/base.rb +23 -17
- data/lib/ruby-lint/analysis/pedantics.rb +3 -1
- data/lib/ruby-lint/analysis/undefined_methods.rb +48 -10
- data/lib/ruby-lint/analysis/unused_variables.rb +27 -5
- data/lib/ruby-lint/ast/node.rb +10 -0
- data/lib/ruby-lint/cli/analyze.rb +22 -4
- data/lib/ruby-lint/cli/base.rb +8 -2
- data/lib/ruby-lint/configuration.rb +43 -4
- data/lib/ruby-lint/definition/constant_proxy.rb +10 -1
- data/lib/ruby-lint/definition/ruby_method.rb +45 -31
- data/lib/ruby-lint/definition/ruby_object.rb +56 -15
- data/lib/ruby-lint/definition_builder/base.rb +4 -0
- data/lib/ruby-lint/definition_builder/primitive.rb +1 -1
- data/lib/ruby-lint/definition_builder/ruby_array.rb +1 -1
- data/lib/ruby-lint/definition_builder/ruby_block.rb +1 -0
- data/lib/ruby-lint/definition_builder/ruby_class.rb +1 -1
- data/lib/ruby-lint/definition_builder/ruby_hash.rb +1 -1
- data/lib/ruby-lint/definition_builder/ruby_module.rb +3 -1
- data/lib/ruby-lint/definition_generator.rb +15 -7
- data/lib/ruby-lint/definitions/core/arg0.rb +1 -1
- data/lib/ruby-lint/definitions/core/argf.rb +1 -1
- data/lib/ruby-lint/definitions/core/argument_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/argv.rb +1 -1
- data/lib/ruby-lint/definitions/core/array.rb +6 -6
- data/lib/ruby-lint/definitions/core/autoload.rb +2 -2
- data/lib/ruby-lint/definitions/core/basic_object.rb +8 -12
- data/lib/ruby-lint/definitions/core/bignum.rb +2 -2
- data/lib/ruby-lint/definitions/core/binding.rb +2 -2
- data/lib/ruby-lint/definitions/core/class.rb +2 -2
- data/lib/ruby-lint/definitions/core/comparable.rb +1 -1
- data/lib/ruby-lint/definitions/core/complex.rb +4 -4
- data/lib/ruby-lint/definitions/core/condition_variable.rb +2 -2
- data/lib/ruby-lint/definitions/core/continuation.rb +2 -2
- data/lib/ruby-lint/definitions/core/data.rb +2 -2
- data/lib/ruby-lint/definitions/core/date.rb +34 -34
- data/lib/ruby-lint/definitions/core/date_time.rb +26 -26
- data/lib/ruby-lint/definitions/core/default_record_separator.rb +1 -1
- data/lib/ruby-lint/definitions/core/digest.rb +14 -14
- data/lib/ruby-lint/definitions/core/dir.rb +34 -34
- data/lib/ruby-lint/definitions/core/encoding.rb +237 -237
- data/lib/ruby-lint/definitions/core/encoding_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/enumerable.rb +15 -15
- data/lib/ruby-lint/definitions/core/enumerator.rb +2 -2
- data/lib/ruby-lint/definitions/core/env.rb +1 -1
- data/lib/ruby-lint/definitions/core/eoferror.rb +2 -2
- data/lib/ruby-lint/definitions/core/erb.rb +30 -23
- data/lib/ruby-lint/definitions/core/errno.rb +525 -525
- data/lib/ruby-lint/definitions/core/etc.rb +6 -6
- data/lib/ruby-lint/definitions/core/exception.rb +2 -2
- data/lib/ruby-lint/definitions/core/false.rb +1 -1
- data/lib/ruby-lint/definitions/core/false_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/fatal_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/fiber.rb +2 -2
- data/lib/ruby-lint/definitions/core/fiber_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/file.rb +68 -68
- data/lib/ruby-lint/definitions/core/file_list.rb +2 -2
- data/lib/ruby-lint/definitions/core/file_test.rb +1 -1
- data/lib/ruby-lint/definitions/core/file_utils.rb +16 -16
- data/lib/ruby-lint/definitions/core/fixnum.rb +4 -4
- data/lib/ruby-lint/definitions/core/float.rb +16 -16
- data/lib/ruby-lint/definitions/core/float_domain_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/gc.rb +2 -2
- data/lib/ruby-lint/definitions/core/gem.rb +119 -119
- data/lib/ruby-lint/definitions/core/hash.rb +14 -14
- data/lib/ruby-lint/definitions/core/immediate_value.rb +1 -1
- data/lib/ruby-lint/definitions/core/index_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/integer.rb +2 -2
- data/lib/ruby-lint/definitions/core/interrupt.rb +2 -2
- data/lib/ruby-lint/definitions/core/io.rb +38 -38
- data/lib/ruby-lint/definitions/core/ioerror.rb +2 -2
- data/lib/ruby-lint/definitions/core/kernel.rb +113 -60
- data/lib/ruby-lint/definitions/core/key_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/load_error.rb +6 -6
- data/lib/ruby-lint/definitions/core/local_jump_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/marshal.rb +35 -35
- data/lib/ruby-lint/definitions/core/match_data.rb +2 -2
- data/lib/ruby-lint/definitions/core/math.rb +7 -7
- data/lib/ruby-lint/definitions/core/memory_segmention_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/method.rb +2 -2
- data/lib/ruby-lint/definitions/core/module.rb +39 -3
- data/lib/ruby-lint/definitions/core/monitor.rb +4 -4
- data/lib/ruby-lint/definitions/core/monitor_mixin.rb +5 -5
- data/lib/ruby-lint/definitions/core/mutex.rb +2 -2
- data/lib/ruby-lint/definitions/core/name_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/nil.rb +1 -1
- data/lib/ruby-lint/definitions/core/nil_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/no_memory_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/no_method_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/not_implemented_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/numeric.rb +2 -2
- data/lib/ruby-lint/definitions/core/object.rb +2 -2
- data/lib/ruby-lint/definitions/core/object_space.rb +1 -1
- data/lib/ruby-lint/definitions/core/open_struct.rb +3 -3
- data/lib/ruby-lint/definitions/core/option_parser.rb +83 -83
- data/lib/ruby-lint/definitions/core/precision.rb +1 -1
- data/lib/ruby-lint/definitions/core/primitive_failure.rb +2 -2
- data/lib/ruby-lint/definitions/core/proc.rb +2 -2
- data/lib/ruby-lint/definitions/core/process.rb +29 -29
- data/lib/ruby-lint/definitions/core/queue.rb +2 -2
- data/lib/ruby-lint/definitions/core/rake.rb +117 -117
- data/lib/ruby-lint/definitions/core/rake_file_utils.rb +1 -1
- data/lib/ruby-lint/definitions/core/rakeversion.rb +1 -1
- data/lib/ruby-lint/definitions/core/random.rb +2 -2
- data/lib/ruby-lint/definitions/core/range.rb +4 -4
- data/lib/ruby-lint/definitions/core/range_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/rational.rb +2 -2
- data/lib/ruby-lint/definitions/core/rb_config.rb +3 -3
- data/lib/ruby-lint/definitions/core/regexp.rb +28 -28
- data/lib/ruby-lint/definitions/core/regexp_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/ruby_copyright.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_description.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_engine.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_platform.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_release_date.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_version.rb +1 -1
- data/lib/ruby-lint/definitions/core/runtime_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/scan_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/script_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/security_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/shellwords.rb +1 -1
- data/lib/ruby-lint/definitions/core/signal.rb +3 -3
- data/lib/ruby-lint/definitions/core/signal_exception.rb +2 -2
- data/lib/ruby-lint/definitions/core/singleton.rb +2 -2
- data/lib/ruby-lint/definitions/core/sized_queue.rb +2 -2
- data/lib/ruby-lint/definitions/core/standard_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/stderr.rb +3 -2
- data/lib/ruby-lint/definitions/core/stdin.rb +3 -2
- data/lib/ruby-lint/definitions/core/stdout.rb +3 -2
- data/lib/ruby-lint/definitions/core/stop_iteration.rb +2 -2
- data/lib/ruby-lint/definitions/core/string.rb +21 -21
- data/lib/ruby-lint/definitions/core/string_io.rb +7 -7
- data/lib/ruby-lint/definitions/core/string_scanner.rb +4 -4
- data/lib/ruby-lint/definitions/core/struct.rb +20 -20
- data/lib/ruby-lint/definitions/core/syck.rb +4 -4
- data/lib/ruby-lint/definitions/core/symbol.rb +2 -2
- data/lib/ruby-lint/definitions/core/syntax_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_call_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_exit.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_stack_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/thread.rb +6 -6
- data/lib/ruby-lint/definitions/core/thread_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/thread_group.rb +2 -2
- data/lib/ruby-lint/definitions/core/time.rb +3 -3
- data/lib/ruby-lint/definitions/core/toplevel_binding.rb +1 -1
- data/lib/ruby-lint/definitions/core/true.rb +1 -1
- data/lib/ruby-lint/definitions/core/true_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/type_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/unbound_method.rb +2 -2
- data/lib/ruby-lint/definitions/core/unmarshalable.rb +1 -1
- data/lib/ruby-lint/definitions/core/unsupported_library_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/weak_ref.rb +4 -4
- data/lib/ruby-lint/definitions/core/yaml.rb +2361 -0
- data/lib/ruby-lint/definitions/core/zero_division_error.rb +2 -2
- data/lib/ruby-lint/definitions/global_variables.rb +9 -0
- data/lib/ruby-lint/definitions/rails/abstract_controller.rb +174 -28
- data/lib/ruby-lint/definitions/rails/action_controller.rb +4959 -550
- data/lib/ruby-lint/definitions/rails/action_dispatch.rb +2489 -292
- data/lib/ruby-lint/definitions/rails/action_mailer.rb +1285 -42
- data/lib/ruby-lint/definitions/rails/action_pack.rb +14 -6
- data/lib/ruby-lint/definitions/rails/action_view.rb +6941 -445
- data/lib/ruby-lint/definitions/rails/active_model.rb +1212 -69
- data/lib/ruby-lint/definitions/rails/active_record.rb +10344 -1450
- data/lib/ruby-lint/definitions/rails/active_support.rb +4631 -573
- data/lib/ruby-lint/definitions/rails/arel.rb +3211 -319
- data/lib/ruby-lint/definitions/rails/rails.rb +2922 -84
- data/lib/ruby-lint/definitions/rails/sprockets.rb +3048 -277
- data/lib/ruby-lint/docstring/mapping.rb +55 -0
- data/lib/ruby-lint/docstring/param_tag.rb +29 -0
- data/lib/ruby-lint/docstring/parser.rb +133 -0
- data/lib/ruby-lint/docstring/return_tag.rb +24 -0
- data/lib/ruby-lint/file_loader.rb +96 -0
- data/lib/ruby-lint/file_scanner.rb +91 -0
- data/lib/ruby-lint/global_scope.rb +56 -0
- data/lib/ruby-lint/helper/constant_paths.rb +1 -1
- data/lib/ruby-lint/inspector.rb +11 -33
- data/lib/ruby-lint/iterator.rb +31 -4
- data/lib/ruby-lint/method_call/alias.rb +46 -0
- data/lib/ruby-lint/method_call/assign_member.rb +55 -0
- data/lib/ruby-lint/method_call/attribute.rb +102 -0
- data/lib/ruby-lint/method_call/base.rb +37 -0
- data/lib/ruby-lint/method_call/define_method.rb +17 -0
- data/lib/ruby-lint/method_call/include.rb +39 -0
- data/lib/ruby-lint/parser.rb +9 -4
- data/lib/ruby-lint/presenter/text.rb +2 -1
- data/lib/ruby-lint/report.rb +19 -42
- data/lib/ruby-lint/report/entry.rb +20 -17
- data/lib/ruby-lint/runner.rb +92 -11
- data/lib/ruby-lint/template/definition.erb +2 -2
- data/lib/ruby-lint/variable_predicates.rb +7 -10
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +265 -188
- data/ruby-lint.gemspec +4 -4
- data/ruby-lint.yml +7 -0
- data/spec/fixtures/associating.rb +7 -0
- data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +6 -0
- data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +8 -0
- data/spec/fixtures/file_scanner/lib/example/user.rb +6 -0
- data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +4 -0
- data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +6 -0
- data/spec/fixtures/file_scanner/rails/app/models/user.rb +4 -0
- data/spec/fixtures/uses_external.rb +1 -0
- data/spec/fixtures/uses_external_invalid.rb +3 -0
- data/spec/fixtures/uses_external_namespace.rb +1 -0
- data/spec/ruby-lint/analysis/{argument_amount.rb → argument_amount_spec.rb} +33 -7
- data/spec/ruby-lint/analysis/base_spec.rb +12 -0
- data/spec/ruby-lint/analysis/{pedantics.rb → pedantics_spec.rb} +24 -4
- data/spec/ruby-lint/analysis/{shadowing_variables.rb → shadowing_variables_spec.rb} +6 -6
- data/spec/ruby-lint/analysis/undefined_methods_spec.rb +320 -0
- data/spec/ruby-lint/analysis/{undefined_variables.rb → undefined_variables_spec.rb} +33 -10
- data/spec/ruby-lint/analysis/{unused_variables.rb → unused_variables_spec.rb} +36 -9
- data/spec/ruby-lint/ast/{node.rb → node_spec.rb} +12 -6
- data/spec/ruby-lint/cli/{analyze.rb → analyze_spec.rb} +16 -5
- data/spec/ruby-lint/cli/{ast.rb → ast_spec.rb} +3 -3
- data/spec/ruby-lint/configuration_spec.rb +106 -0
- data/spec/ruby-lint/definition/constant_proxy_spec.rb +54 -0
- data/spec/ruby-lint/definition/{dsl.rb → dsl_spec.rb} +15 -15
- data/spec/ruby-lint/definition/{ruby_method.rb → ruby_method_spec.rb} +31 -17
- data/spec/ruby-lint/definition/{ruby_object.rb → ruby_object_spec.rb} +28 -23
- data/spec/ruby-lint/definition_builder/{primitive.rb → primitive_spec.rb} +9 -9
- data/spec/ruby-lint/definition_builder/{ruby_class.rb → ruby_class_spec.rb} +13 -13
- data/spec/ruby-lint/definition_builder/{ruby_method.rb → ruby_method_spec.rb} +9 -9
- data/spec/ruby-lint/definition_builder/{ruby_module.rb → ruby_module_spec.rb} +12 -10
- data/spec/ruby-lint/docstring/mapping.rb +27 -0
- data/spec/ruby-lint/docstring/parser_spec.rb +88 -0
- data/spec/ruby-lint/extensions/{string.rb → string_spec.rb} +3 -3
- data/spec/ruby-lint/file_loader_spec.rb +69 -0
- data/spec/ruby-lint/file_scanner_spec.rb +51 -0
- data/spec/ruby-lint/inspector_spec.rb +44 -0
- data/spec/ruby-lint/{iterator.rb → iterator_spec.rb} +39 -4
- data/spec/ruby-lint/{nested_stack.rb → nested_stack_spec.rb} +4 -4
- data/spec/ruby-lint/parser_spec.rb +31 -0
- data/spec/ruby-lint/presenter/json_spec.rb +58 -0
- data/spec/ruby-lint/presenter/text_spec.rb +49 -0
- data/spec/ruby-lint/report/entry_spec.rb +58 -0
- data/spec/ruby-lint/report_spec.rb +39 -0
- data/spec/ruby-lint/runner_spec.rb +52 -0
- data/spec/ruby-lint/virtual_machine/alias_spec.rb +55 -0
- data/spec/ruby-lint/virtual_machine/assignments/{arrays.rb → arrays_spec.rb} +7 -7
- data/spec/ruby-lint/virtual_machine/assignments/{hashes.rb → hashes_spec.rb} +6 -6
- data/spec/ruby-lint/virtual_machine/assignments/{optional.rb → optional_spec.rb} +6 -6
- data/spec/ruby-lint/virtual_machine/assignments/{return_values.rb → return_values_spec.rb} +11 -11
- data/spec/ruby-lint/virtual_machine/assignments/{variables.rb → variables_spec.rb} +38 -7
- data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +59 -0
- data/spec/ruby-lint/virtual_machine/{autoloading.rb → autoloading_spec.rb} +6 -6
- data/spec/ruby-lint/virtual_machine/{blocks.rb → blocks_spec.rb} +30 -4
- data/spec/ruby-lint/virtual_machine/classes/{class_methods.rb → class_methods_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/classes/{extending.rb → extending_spec.rb} +20 -15
- data/spec/ruby-lint/virtual_machine/classes/{redefining.rb → redefining_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/classes/{sclass.rb → sclass_spec.rb} +7 -7
- data/spec/ruby-lint/virtual_machine/classes/{scoping.rb → scoping_spec.rb} +5 -5
- data/spec/ruby-lint/virtual_machine/complex/{rails.rb → rails_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/complex/{rcap.rb → rcap_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/complex/{slop.rb → slop_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/constants_spec.rb +31 -0
- data/spec/ruby-lint/virtual_machine/{for.rb → for_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/{freeze.rb → freeze_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +12 -0
- data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +15 -0
- data/spec/ruby-lint/virtual_machine/{interpolation.rb → interpolation_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +116 -0
- data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +41 -0
- data/spec/ruby-lint/virtual_machine/methods/{defining.rb → defining_spec.rb} +4 -4
- data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +69 -0
- data/spec/ruby-lint/virtual_machine/methods/{exporting.rb → exporting_spec.rb} +3 -3
- data/spec/ruby-lint/virtual_machine/methods/{parameters.rb → parameters_spec.rb} +17 -5
- data/spec/ruby-lint/virtual_machine/methods/{patching.rb → patching_spec.rb} +4 -4
- data/spec/ruby-lint/virtual_machine/methods/{scoping.rb → scoping_spec.rb} +5 -5
- data/spec/ruby-lint/virtual_machine/methods/{visibility.rb → visibility_spec.rb} +6 -6
- data/spec/ruby-lint/virtual_machine/{modules.rb → modules_spec.rb} +39 -9
- data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +61 -0
- data/spec/ruby-lint/virtual_machine/{unused.rb → unused_spec.rb} +4 -4
- data/spec/{helper.rb → spec_helper.rb} +6 -4
- data/spec/support/building.rb +10 -6
- data/spec/support/coveralls.rb +1 -1
- data/spec/support/parsing.rb +10 -1
- data/spec/support/simplecov.rb +1 -1
- data/spec/support/versions.rb +9 -0
- data/task/test.rake +2 -4
- data/task/travis.rake +1 -0
- metadata +144 -143
- metadata.gz.asc +14 -14
- data/.rubocop.yml +0 -59
- data/doc/contributing.md +0 -16
- data/lib/ruby-lint/analysis/confusing_variables.rb +0 -26
- data/lib/ruby-lint/definitions/core/main.rb +0 -25
- data/lib/ruby-lint/definitions/core/psych.rb +0 -2231
- data/lib/ruby-lint/definitions/core/rubinius.rb +0 -16637
- data/lib/ruby-lint/definitions/core/ruby_lint.rb +0 -93
- data/spec/ruby-lint/analysis/confusing_variables.rb +0 -46
- data/spec/ruby-lint/analysis/undefined_methods.rb +0 -174
- data/spec/ruby-lint/configuration.rb +0 -54
- data/spec/ruby-lint/definition/constant_proxy.rb +0 -31
- data/spec/ruby-lint/parser.rb +0 -14
- data/spec/ruby-lint/presenter/json.rb +0 -31
- data/spec/ruby-lint/presenter/text.rb +0 -22
- data/spec/ruby-lint/report.rb +0 -50
- data/spec/ruby-lint/report/entry.rb +0 -28
- data/spec/ruby-lint/runner.rb +0 -32
- data/spec/ruby-lint/virtual_machine/associate_nodes.rb +0 -17
- data/spec/ruby-lint/virtual_machine/reference_amount.rb +0 -33
- data/spec/support/bacon.rb +0 -33
- data/task/cop.rake +0 -11
data/Rakefile
CHANGED
|
@@ -5,9 +5,15 @@ require File.expand_path('../lib/ruby-lint/definition_generator', __FILE__)
|
|
|
5
5
|
require 'yaml'
|
|
6
6
|
require 'bundler/gem_tasks'
|
|
7
7
|
require 'digest/sha2'
|
|
8
|
+
require 'coveralls/rake/task'
|
|
9
|
+
require 'rake/clean'
|
|
10
|
+
|
|
11
|
+
Coveralls::RakeTask.new
|
|
8
12
|
|
|
9
13
|
GEMSPEC = Gem::Specification.load('ruby-lint.gemspec')
|
|
10
14
|
|
|
15
|
+
CLEAN.include(['coverage', 'yardoc'])
|
|
16
|
+
|
|
11
17
|
Dir['./task/*.rake'].each do |task|
|
|
12
18
|
import(task)
|
|
13
19
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
40ff98f739ee8dfb2356010f56b2110fcfa022b5df2bffd978a8585c958beae913016535d3d9721144dda39bc719334e0a61a9159f206f8ce82476ea17882540
|
data/doc/changelog.md
CHANGED
|
@@ -5,6 +5,98 @@ 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.0.5 - 2013-09-01
|
|
9
|
+
|
|
10
|
+
Originally slated for August 1st I decided to push this release back one month
|
|
11
|
+
to buy myself some extra time to polish features, resolve more bugs and
|
|
12
|
+
procrastinate more. Besides numerous bug fixes and extra polish this release
|
|
13
|
+
contains two big new features that I'd like to highlight:
|
|
14
|
+
|
|
15
|
+
* support for parsing basic YARD tags
|
|
16
|
+
* loading of externally defined constants/files from the local file system
|
|
17
|
+
|
|
18
|
+
### YARD Support
|
|
19
|
+
|
|
20
|
+
[YARD][yard] provides a set of tags that can aid in documenting your code. For
|
|
21
|
+
example, `@param` is a tag used to document the type, name and description of a
|
|
22
|
+
method parameter. Since Ruby has no form of type hinting you're often left to
|
|
23
|
+
wonder what kind of objects a method can work with.
|
|
24
|
+
|
|
25
|
+
In version 0.0.5 support for two tags was added:
|
|
26
|
+
|
|
27
|
+
* `@param`
|
|
28
|
+
* `@return`
|
|
29
|
+
|
|
30
|
+
When ruby-lint finds methods documented using these tags it will use them to
|
|
31
|
+
pull in information about the parameter types and return values. This greatly
|
|
32
|
+
increases the accuracy of ruby-lint, given your code is documented. Consider
|
|
33
|
+
the following example:
|
|
34
|
+
|
|
35
|
+
def multiply(value, multiplier)
|
|
36
|
+
return value * value
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
If ruby-lint were to process the above code it would have no idea what kind of
|
|
40
|
+
object `value` and `multiplier` are and thus wouldn't be able to much with the
|
|
41
|
+
above code. When documenting the above method with the mentioned YARD tags
|
|
42
|
+
ruby-lint *is* capable of doing this:
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# @param [Fixnum] value
|
|
46
|
+
# @param [Fixnum] multiplier
|
|
47
|
+
# @return [Fixnum]
|
|
48
|
+
#
|
|
49
|
+
def multiply(value, multiplier)
|
|
50
|
+
return value * value
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
By parsing the YARD tags ruby-lint can now know what the parameter types are
|
|
54
|
+
and what type of data the method returns. This in turn allows ruby-lint to
|
|
55
|
+
perform full analysis on the arguments instead of being forced to ignore them
|
|
56
|
+
completely.
|
|
57
|
+
|
|
58
|
+
### Loading External Files
|
|
59
|
+
|
|
60
|
+
In previous versions ruby-lint had no way of loading external code that was not
|
|
61
|
+
pre-defined using the built-in definitions (found in
|
|
62
|
+
`lib/ruby-lint/definitions`). As a result a lot of false positives would be
|
|
63
|
+
triggered when analysing complex projects (e.g. the typical Rails project).
|
|
64
|
+
|
|
65
|
+
This has been addressed by introducing so called "file scanners" and "file
|
|
66
|
+
loaders". In short, these scan for a set of constants used in a file and try to
|
|
67
|
+
find the corresponding Ruby file that defines it (recursively). This greatly
|
|
68
|
+
enhances the accuracy of analysis.
|
|
69
|
+
|
|
70
|
+
Currently the algorithm for this is rather basic and can, especially in big
|
|
71
|
+
projects, slow analysis down by quite a bit. This will be resolved in upcoming
|
|
72
|
+
releases. Keep an eye on the following issues for more information:
|
|
73
|
+
|
|
74
|
+
* <https://github.com/YorickPeterse/ruby-lint/issues/50>
|
|
75
|
+
* <https://github.com/YorickPeterse/ruby-lint/issues/49>
|
|
76
|
+
|
|
77
|
+
### Other Changes
|
|
78
|
+
|
|
79
|
+
Besides the two features mentioned above various other changes have also been
|
|
80
|
+
made, these are listed below.
|
|
81
|
+
|
|
82
|
+
* Lots of bug fixes and cleanups, as you'd expect.
|
|
83
|
+
* Constants (classes and modules) can now be referred by their name inside
|
|
84
|
+
themselves (e.g. "Foo" inside the class "Foo" refers to that class).
|
|
85
|
+
* The text presenter now only shows filenames instead of the full file path,
|
|
86
|
+
reducing clutter.
|
|
87
|
+
* Support for default global variables such as `$LOADED_FEATURES`
|
|
88
|
+
* Support for methods such as `alias` and `alias_method`
|
|
89
|
+
* Support for the `attr_*` family of methods
|
|
90
|
+
* The test suite has been migrated from Bacon to RSpec
|
|
91
|
+
* Support for keyword arguments.
|
|
92
|
+
* Updated built-in Rails definitions to include more methods.
|
|
93
|
+
* Debugging/benchmarking output for the analyze command.
|
|
94
|
+
* The analysis class ConfusingVariables has been removed due to not being very
|
|
95
|
+
useful.
|
|
96
|
+
* Various issues with method lookups inside blocks have been resolved.
|
|
97
|
+
* Various internals have been cleaned up.
|
|
98
|
+
* Improved error messages for calls to undefined methods.
|
|
99
|
+
|
|
8
100
|
## 0.0.4 - 2013-07-14
|
|
9
101
|
|
|
10
102
|
Near total refactor of the entire project. New parser setup based on the
|
|
@@ -27,3 +119,5 @@ Various changes to the old parser.
|
|
|
27
119
|
## 0.0.1 - 2012-11-13
|
|
28
120
|
|
|
29
121
|
First public release of ruby-lint.
|
|
122
|
+
|
|
123
|
+
[yard]: http://yardoc.org/
|
data/lib/ruby-lint.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
gem 'parser', '>= 2.0.0.pre6'
|
|
2
|
+
|
|
1
3
|
require 'parser'
|
|
2
4
|
require 'parser/current'
|
|
3
5
|
require 'yaml'
|
|
6
|
+
require 'set'
|
|
4
7
|
|
|
5
8
|
require_relative 'ruby-lint/extensions/string'
|
|
6
9
|
|
|
@@ -8,7 +11,12 @@ require_relative 'ruby-lint/variable_predicates'
|
|
|
8
11
|
require_relative 'ruby-lint/ast/node'
|
|
9
12
|
require_relative 'ruby-lint/ast/builder'
|
|
10
13
|
require_relative 'ruby-lint/parser'
|
|
14
|
+
require_relative 'ruby-lint/file_scanner'
|
|
11
15
|
require_relative 'ruby-lint/nested_stack'
|
|
16
|
+
require_relative 'ruby-lint/docstring/parser'
|
|
17
|
+
require_relative 'ruby-lint/docstring/param_tag'
|
|
18
|
+
require_relative 'ruby-lint/docstring/return_tag'
|
|
19
|
+
require_relative 'ruby-lint/docstring/mapping'
|
|
12
20
|
|
|
13
21
|
require_relative 'ruby-lint/helper/constant_paths'
|
|
14
22
|
|
|
@@ -21,14 +29,24 @@ require_relative 'ruby-lint/definition_builder/ruby_hash'
|
|
|
21
29
|
require_relative 'ruby-lint/definition_builder/ruby_block'
|
|
22
30
|
require_relative 'ruby-lint/definition_builder/primitive'
|
|
23
31
|
|
|
32
|
+
require_relative 'ruby-lint/method_call/base'
|
|
33
|
+
require_relative 'ruby-lint/method_call/assign_member'
|
|
34
|
+
require_relative 'ruby-lint/method_call/include'
|
|
35
|
+
require_relative 'ruby-lint/method_call/alias'
|
|
36
|
+
require_relative 'ruby-lint/method_call/attribute'
|
|
37
|
+
require_relative 'ruby-lint/method_call/define_method'
|
|
38
|
+
|
|
24
39
|
require_relative 'ruby-lint/iterator'
|
|
40
|
+
require_relative 'ruby-lint/global_scope'
|
|
25
41
|
require_relative 'ruby-lint/virtual_machine'
|
|
26
42
|
require_relative 'ruby-lint/constant_loader'
|
|
43
|
+
require_relative 'ruby-lint/file_loader'
|
|
27
44
|
|
|
28
45
|
require_relative 'ruby-lint/definition/ruby_object'
|
|
29
46
|
require_relative 'ruby-lint/definition/ruby_method'
|
|
30
47
|
require_relative 'ruby-lint/definition/constant_proxy'
|
|
31
48
|
require_relative 'ruby-lint/definitions/core'
|
|
49
|
+
require_relative 'ruby-lint/definitions/global_variables'
|
|
32
50
|
|
|
33
51
|
require_relative 'ruby-lint/analysis/base'
|
|
34
52
|
require_relative 'ruby-lint/analysis/unused_variables'
|
|
@@ -36,7 +54,6 @@ require_relative 'ruby-lint/analysis/shadowing_variables'
|
|
|
36
54
|
require_relative 'ruby-lint/analysis/undefined_variables'
|
|
37
55
|
require_relative 'ruby-lint/analysis/undefined_methods'
|
|
38
56
|
require_relative 'ruby-lint/analysis/argument_amount'
|
|
39
|
-
require_relative 'ruby-lint/analysis/confusing_variables'
|
|
40
57
|
require_relative 'ruby-lint/analysis/pedantics'
|
|
41
58
|
|
|
42
59
|
require_relative 'ruby-lint/report'
|
|
@@ -6,24 +6,28 @@ module RubyLint
|
|
|
6
6
|
# amount was given.
|
|
7
7
|
#
|
|
8
8
|
class ArgumentAmount < Base
|
|
9
|
+
##
|
|
10
|
+
# Hash that contains method names that should be used for analysis
|
|
11
|
+
# instead of the ones specified in the keys.
|
|
12
|
+
#
|
|
13
|
+
# @return [Hash]
|
|
14
|
+
#
|
|
15
|
+
MAP_METHODS = {
|
|
16
|
+
'new' => [:instance_method, 'initialize']
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
##
|
|
10
20
|
# @param [RubyLint::Node] node
|
|
11
21
|
#
|
|
12
22
|
def on_send(node)
|
|
13
|
-
receiver, name, args = *node
|
|
23
|
+
receiver, name, *args = *node
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if receiver and vm.associations.key?(receiver)
|
|
19
|
-
scope = vm.associations[receiver]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
method = scope.lookup(scope.method_call_type, name)
|
|
25
|
+
scope = scope_for_receiver(receiver)
|
|
26
|
+
method = determine_method(scope, name.to_s)
|
|
23
27
|
|
|
24
28
|
return unless method
|
|
25
29
|
|
|
26
|
-
given = args ? args.
|
|
30
|
+
given = args ? args.length : 0
|
|
27
31
|
min, max = argument_range(method)
|
|
28
32
|
|
|
29
33
|
unless correct_argument_amount(min, max, given)
|
|
@@ -38,6 +42,35 @@ module RubyLint
|
|
|
38
42
|
|
|
39
43
|
private
|
|
40
44
|
|
|
45
|
+
##
|
|
46
|
+
# @param [RubyLint::AST::Node] receiver
|
|
47
|
+
# @return [RubyLint::Definition::RubyObject]
|
|
48
|
+
#
|
|
49
|
+
def scope_for_receiver(receiver)
|
|
50
|
+
scope = current_scope
|
|
51
|
+
|
|
52
|
+
if receiver and vm.associations.key?(receiver)
|
|
53
|
+
scope = vm.associations[receiver]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return scope
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# @param [RubyLint::Definition::RubyObject] scope
|
|
61
|
+
# @param [String] name
|
|
62
|
+
# @return [RubyLint::Definition::RubyMethod]
|
|
63
|
+
#
|
|
64
|
+
def determine_method(scope, name)
|
|
65
|
+
method = scope.lookup(scope.method_call_type, name)
|
|
66
|
+
|
|
67
|
+
if method and MAP_METHODS[method.name]
|
|
68
|
+
method = scope.lookup(*MAP_METHODS[method.name])
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
return method
|
|
72
|
+
end
|
|
73
|
+
|
|
41
74
|
##
|
|
42
75
|
# @param [Numeric] min
|
|
43
76
|
# @param [Numeric] max
|
|
@@ -51,19 +51,19 @@ module RubyLint
|
|
|
51
51
|
protected
|
|
52
52
|
|
|
53
53
|
##
|
|
54
|
+
# Returns the current scope.
|
|
55
|
+
#
|
|
54
56
|
# @return [RubyLint::Definition::RubyObject]
|
|
55
57
|
#
|
|
56
|
-
def
|
|
57
|
-
return
|
|
58
|
+
def current_scope
|
|
59
|
+
return @scopes[-1]
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
##
|
|
61
|
-
# Returns the current scope.
|
|
62
|
-
#
|
|
63
63
|
# @return [RubyLint::Definition::RubyObject]
|
|
64
64
|
#
|
|
65
|
-
def
|
|
66
|
-
return @scopes[-
|
|
65
|
+
def previous_scope
|
|
66
|
+
return @scopes[-2]
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
##
|
|
@@ -90,29 +90,28 @@ module RubyLint
|
|
|
90
90
|
##
|
|
91
91
|
# Adds an error message to the report.
|
|
92
92
|
#
|
|
93
|
-
# @
|
|
94
|
-
# @param [RubyLint::Node] node The node for which to add the message.
|
|
93
|
+
# @see #add_message
|
|
95
94
|
#
|
|
96
|
-
def error(
|
|
97
|
-
add_message(:error,
|
|
95
|
+
def error(*args)
|
|
96
|
+
add_message(:error, *args)
|
|
98
97
|
end
|
|
99
98
|
|
|
100
99
|
##
|
|
101
100
|
# Adds a warning message to the report.
|
|
102
101
|
#
|
|
103
|
-
# @see
|
|
102
|
+
# @see #add_message
|
|
104
103
|
#
|
|
105
|
-
def warning(
|
|
106
|
-
add_message(:warning,
|
|
104
|
+
def warning(*args)
|
|
105
|
+
add_message(:warning, *args)
|
|
107
106
|
end
|
|
108
107
|
|
|
109
108
|
##
|
|
110
109
|
# Adds a regular informational message to the report.
|
|
111
110
|
#
|
|
112
|
-
# @see
|
|
111
|
+
# @see #add_message
|
|
113
112
|
#
|
|
114
|
-
def info(
|
|
115
|
-
add_message(:info,
|
|
113
|
+
def info(*args)
|
|
114
|
+
add_message(:info, *args)
|
|
116
115
|
end
|
|
117
116
|
|
|
118
117
|
##
|
|
@@ -125,7 +124,14 @@ module RubyLint
|
|
|
125
124
|
def add_message(level, message, node)
|
|
126
125
|
return unless report
|
|
127
126
|
|
|
128
|
-
report.add(
|
|
127
|
+
report.add(
|
|
128
|
+
:level => level,
|
|
129
|
+
:message => message,
|
|
130
|
+
:line => node.line,
|
|
131
|
+
:column => node.column,
|
|
132
|
+
:file => node.file,
|
|
133
|
+
:node => node
|
|
134
|
+
)
|
|
129
135
|
end
|
|
130
136
|
end # Base
|
|
131
137
|
end # Analysis
|
|
@@ -8,7 +8,9 @@ module RubyLint
|
|
|
8
8
|
class Pedantics < Base
|
|
9
9
|
[:if, :unless, :until, :while].each do |type|
|
|
10
10
|
define_method("on_#{type}") do |node|
|
|
11
|
-
|
|
11
|
+
if node.location.respond_to?(:begin) and node.location.begin
|
|
12
|
+
check_begin_token(node)
|
|
13
|
+
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
16
|
|
|
@@ -21,12 +21,6 @@ module RubyLint
|
|
|
21
21
|
name = name.to_s
|
|
22
22
|
scope = current_scope
|
|
23
23
|
|
|
24
|
-
# Abort if the receiver doesn't exist since it will be handled by other
|
|
25
|
-
# analysis classes.
|
|
26
|
-
if receiver and !vm.associations.key?(receiver)
|
|
27
|
-
return
|
|
28
|
-
end
|
|
29
|
-
|
|
30
24
|
if receiver and vm.associations.key?(receiver)
|
|
31
25
|
scope = vm.associations[receiver]
|
|
32
26
|
|
|
@@ -35,9 +29,7 @@ module RubyLint
|
|
|
35
29
|
return if scope.parents.empty?
|
|
36
30
|
end
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
unless exists
|
|
32
|
+
unless has_definition?(scope, name)
|
|
41
33
|
message = error_for(name, receiver, scope)
|
|
42
34
|
|
|
43
35
|
error(message, node)
|
|
@@ -46,6 +38,24 @@ module RubyLint
|
|
|
46
38
|
|
|
47
39
|
private
|
|
48
40
|
|
|
41
|
+
##
|
|
42
|
+
# @param [RubyLint::Definition::RubyObject] scope
|
|
43
|
+
# @param [String] name
|
|
44
|
+
#
|
|
45
|
+
def has_definition?(scope, name)
|
|
46
|
+
exists = scope.has_definition?(scope.method_call_type, name)
|
|
47
|
+
|
|
48
|
+
# Due to the way `parser` wraps block nodes (`(block (send) ...)`
|
|
49
|
+
# opposed to `(send ... (block))`) we'll try to find the method in the
|
|
50
|
+
# previous scope if we can't find it in the current block scope.
|
|
51
|
+
if !exists and scope.block?
|
|
52
|
+
prev = previous_scope
|
|
53
|
+
exists = prev.has_definition?(prev.method_call_type, name)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
return exists
|
|
57
|
+
end
|
|
58
|
+
|
|
49
59
|
##
|
|
50
60
|
# Determines what error message to use for a method call.
|
|
51
61
|
#
|
|
@@ -76,7 +86,7 @@ module RubyLint
|
|
|
76
86
|
# @return [String]
|
|
77
87
|
#
|
|
78
88
|
def receiver_error(name, scope)
|
|
79
|
-
klass = scope
|
|
89
|
+
klass = class_names_for_object(scope)
|
|
80
90
|
|
|
81
91
|
if scope.instance?
|
|
82
92
|
error = "undefined method #{name} on an instance of #{klass}"
|
|
@@ -86,6 +96,34 @@ module RubyLint
|
|
|
86
96
|
|
|
87
97
|
return error
|
|
88
98
|
end
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
# @param [RubyLint::Definition::RubyObject] object
|
|
104
|
+
# @return [String]
|
|
105
|
+
#
|
|
106
|
+
def class_names_for_object(object)
|
|
107
|
+
if object.parents.empty?
|
|
108
|
+
klass = object.ruby_class ? object.ruby_class : object.name
|
|
109
|
+
else
|
|
110
|
+
klass = name_for_parents(object.parents)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
return klass
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
##
|
|
117
|
+
# @param [Array] parents
|
|
118
|
+
# @return [String]
|
|
119
|
+
#
|
|
120
|
+
def name_for_parents(parents)
|
|
121
|
+
return parents[0].name if parents.length == 1
|
|
122
|
+
|
|
123
|
+
segments = parents[0..-2].map(&:name)
|
|
124
|
+
|
|
125
|
+
return segments.join(', ') + " or #{parents[-1].name}"
|
|
126
|
+
end
|
|
89
127
|
end # UndefinedMethods
|
|
90
128
|
end # Analysis
|
|
91
129
|
end # RubyLint
|
|
@@ -15,22 +15,34 @@ module RubyLint
|
|
|
15
15
|
VARIABLE_TYPES = {
|
|
16
16
|
:lvasgn => 'local variable',
|
|
17
17
|
:gvasgn => 'global variable',
|
|
18
|
-
:ivasgn => 'instance variable',
|
|
19
18
|
:cvasgn => 'class variable'
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
VARIABLE_TYPES.each do |type, label|
|
|
23
22
|
define_method("on_#{type}") do |node|
|
|
24
23
|
type = VirtualMachine::ASSIGNMENT_TYPES[node.type]
|
|
25
|
-
|
|
26
|
-
variable = current_scope.lookup(type, name)
|
|
24
|
+
variable = current_scope.lookup(type, node.name)
|
|
27
25
|
|
|
28
|
-
if variable
|
|
29
|
-
warning("unused #{label} #{name}", node)
|
|
26
|
+
if add_warning?(variable)
|
|
27
|
+
warning("unused #{label} #{variable.name}", node)
|
|
30
28
|
end
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
31
|
|
|
32
|
+
##
|
|
33
|
+
# @param [RubyLint::AST::Node] node
|
|
34
|
+
#
|
|
35
|
+
def on_ivasgn(node)
|
|
36
|
+
name = node.name
|
|
37
|
+
variable = current_scope.lookup(:ivar, name)
|
|
38
|
+
method_type = current_scope.method_call_type
|
|
39
|
+
getter = current_scope.lookup(method_type, name[1..-1])
|
|
40
|
+
|
|
41
|
+
if variable and !variable.used? and !getter
|
|
42
|
+
warning("unused instance variable #{name}", node)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
34
46
|
##
|
|
35
47
|
# Handles regular constants as well as constant paths.
|
|
36
48
|
#
|
|
@@ -44,6 +56,16 @@ module RubyLint
|
|
|
44
56
|
warning("unused constant #{name}", node)
|
|
45
57
|
end
|
|
46
58
|
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
##
|
|
63
|
+
# @param [RubyLint::Definition::RubyObject] variable
|
|
64
|
+
# @return [TrueClass|FalseClass]
|
|
65
|
+
#
|
|
66
|
+
def add_warning?(variable)
|
|
67
|
+
return variable && !variable.used? && variable.name[0] != '_'
|
|
68
|
+
end
|
|
47
69
|
end # UnusedVariables
|
|
48
70
|
end # Analysis
|
|
49
71
|
end # RubyLint
|