ruby-lint 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,93 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Constant: RubyLint
|
3
|
-
# Created: 2013-04-01 18:33:55 +0200
|
4
|
-
# Platform: rbx 2.0.0.rc1
|
5
|
-
#
|
6
|
-
RubyLint::VirtualMachine.global_scope.define_constant('RubyLint') do |klass|
|
7
|
-
|
8
|
-
klass.define_method('__module_init__')
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
# Constant: RubyLint::DefinitionGenerator
|
13
|
-
# Created: 2013-04-01 18:33:55 +0200
|
14
|
-
# Platform: rbx 2.0.0.rc1
|
15
|
-
#
|
16
|
-
RubyLint::VirtualMachine.global_scope.define_constant('RubyLint::DefinitionGenerator') do |klass|
|
17
|
-
klass.inherits(RubyLint::VirtualMachine.constant_proxy('Object'))
|
18
|
-
|
19
|
-
klass.define_method('__class_init__')
|
20
|
-
|
21
|
-
klass.define_instance_method('directory')
|
22
|
-
|
23
|
-
klass.define_instance_method('generate')
|
24
|
-
|
25
|
-
klass.define_instance_method('inspector')
|
26
|
-
|
27
|
-
klass.define_instance_method('options')
|
28
|
-
|
29
|
-
klass.define_instance_method('template')
|
30
|
-
end
|
31
|
-
|
32
|
-
##
|
33
|
-
# Constant: RubyLint::Inspector
|
34
|
-
# Created: 2013-04-01 18:33:55 +0200
|
35
|
-
# Platform: rbx 2.0.0.rc1
|
36
|
-
#
|
37
|
-
RubyLint::VirtualMachine.global_scope.define_constant('RubyLint::Inspector') do |klass|
|
38
|
-
klass.inherits(RubyLint::VirtualMachine.constant_proxy('Object'))
|
39
|
-
|
40
|
-
klass.define_method('__class_init__')
|
41
|
-
|
42
|
-
klass.define_instance_method('constant')
|
43
|
-
|
44
|
-
klass.define_instance_method('constant_name')
|
45
|
-
|
46
|
-
klass.define_instance_method('format_constants') do |method|
|
47
|
-
method.define_argument('constants')
|
48
|
-
end
|
49
|
-
|
50
|
-
klass.define_instance_method('format_methods') do |method|
|
51
|
-
method.define_argument('methods')
|
52
|
-
end
|
53
|
-
|
54
|
-
klass.define_instance_method('inspect_constants') do |method|
|
55
|
-
method.define_optional_argument('source')
|
56
|
-
method.define_optional_argument('ignore')
|
57
|
-
end
|
58
|
-
|
59
|
-
klass.define_instance_method('inspect_instance_methods')
|
60
|
-
|
61
|
-
klass.define_instance_method('inspect_methods')
|
62
|
-
end
|
63
|
-
|
64
|
-
##
|
65
|
-
# Constant: RubyLint::Template
|
66
|
-
# Created: 2013-04-01 18:33:55 +0200
|
67
|
-
# Platform: rbx 2.0.0.rc1
|
68
|
-
#
|
69
|
-
RubyLint::VirtualMachine.global_scope.define_constant('RubyLint::Template') do |klass|
|
70
|
-
|
71
|
-
klass.define_method('__module_init__')
|
72
|
-
end
|
73
|
-
|
74
|
-
##
|
75
|
-
# Constant: RubyLint::Template::Scope
|
76
|
-
# Created: 2013-04-01 18:33:55 +0200
|
77
|
-
# Platform: rbx 2.0.0.rc1
|
78
|
-
#
|
79
|
-
RubyLint::VirtualMachine.global_scope.define_constant('RubyLint::Template::Scope') do |klass|
|
80
|
-
klass.inherits(RubyLint::VirtualMachine.constant_proxy('Object'))
|
81
|
-
|
82
|
-
klass.define_method('__class_init__')
|
83
|
-
|
84
|
-
klass.define_instance_method('get_binding')
|
85
|
-
end
|
86
|
-
|
87
|
-
##
|
88
|
-
# Constant: RubyLint::VERSION
|
89
|
-
# Created: 2013-04-01 18:33:55 +0200
|
90
|
-
# Platform: rbx 2.0.0.rc1
|
91
|
-
#
|
92
|
-
RubyLint::VirtualMachine.global_scope.define_constant('RubyLint::VERSION') do |klass|
|
93
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
2
|
-
|
3
|
-
describe RubyLint::Analysis::ConfusingVariables do
|
4
|
-
should 'warn when assigning a variable with the same name as a method' do
|
5
|
-
code = <<-CODE
|
6
|
-
def number
|
7
|
-
end
|
8
|
-
|
9
|
-
number = 10
|
10
|
-
CODE
|
11
|
-
|
12
|
-
report = build_report(code, RubyLint::Analysis::ConfusingVariables)
|
13
|
-
entry = report.entries[0]
|
14
|
-
|
15
|
-
entry.line.should == 4
|
16
|
-
entry.column.should == 0
|
17
|
-
entry.message.should =~ /variable assignment using the same name/
|
18
|
-
end
|
19
|
-
|
20
|
-
should 'not warn when the variable is assigned inside the method itself' do
|
21
|
-
code = <<-CODE
|
22
|
-
def number
|
23
|
-
number = 10
|
24
|
-
end
|
25
|
-
CODE
|
26
|
-
|
27
|
-
report = build_report(code, RubyLint::Analysis::ConfusingVariables)
|
28
|
-
|
29
|
-
report.entries.empty?.should == true
|
30
|
-
end
|
31
|
-
|
32
|
-
should 'not warn when the method is defined in a different scope' do
|
33
|
-
code = <<-CODE
|
34
|
-
module Foo
|
35
|
-
def number
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
number = 10
|
40
|
-
CODE
|
41
|
-
|
42
|
-
report = build_report(code, RubyLint::Analysis::ConfusingVariables)
|
43
|
-
|
44
|
-
report.entries.empty?.should == true
|
45
|
-
end
|
46
|
-
end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
2
|
-
|
3
|
-
describe RubyLint::Analysis::UndefinedMethods do
|
4
|
-
should 'add an error for calling an undefined method' do
|
5
|
-
report = build_report('example_method', RubyLint::Analysis::UndefinedMethods)
|
6
|
-
entry = report.entries[0]
|
7
|
-
|
8
|
-
entry.is_a?(RubyLint::Report::Entry).should == true
|
9
|
-
|
10
|
-
entry.line.should == 1
|
11
|
-
entry.column.should == 0
|
12
|
-
entry.message.should == 'undefined method example_method'
|
13
|
-
end
|
14
|
-
|
15
|
-
should 'add an error for calling an undefined method with a receiver' do
|
16
|
-
code = <<-CODE
|
17
|
-
class << self
|
18
|
-
def example_method
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
String.example_method
|
23
|
-
CODE
|
24
|
-
|
25
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
26
|
-
entry = report.entries[0]
|
27
|
-
|
28
|
-
entry.is_a?(RubyLint::Report::Entry).should == true
|
29
|
-
|
30
|
-
entry.line.should == 6
|
31
|
-
entry.column.should == 0
|
32
|
-
entry.message.should == 'undefined method example_method on String'
|
33
|
-
end
|
34
|
-
|
35
|
-
should 'add an error for calling an undefined method on a receiver instance' do
|
36
|
-
code = '"hello".example_method'
|
37
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
38
|
-
entry = report.entries[0]
|
39
|
-
|
40
|
-
entry.is_a?(RubyLint::Report::Entry).should == true
|
41
|
-
|
42
|
-
entry.line.should == 1
|
43
|
-
entry.column.should == 0
|
44
|
-
entry.message.should == 'undefined method example_method ' \
|
45
|
-
'on an instance of String'
|
46
|
-
end
|
47
|
-
|
48
|
-
should 'add an error when calling a method defined in a different scope' do
|
49
|
-
code = <<-CODE
|
50
|
-
class Person
|
51
|
-
def name
|
52
|
-
return 'name'
|
53
|
-
end
|
54
|
-
|
55
|
-
def greet
|
56
|
-
name
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
name
|
61
|
-
CODE
|
62
|
-
|
63
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
64
|
-
|
65
|
-
report.entries.length.should == 1
|
66
|
-
|
67
|
-
entry = report.entries[0]
|
68
|
-
|
69
|
-
entry.is_a?(RubyLint::Report::Entry).should == true
|
70
|
-
|
71
|
-
entry.line.should == 11
|
72
|
-
entry.column.should == 0
|
73
|
-
entry.message.should == 'undefined method name'
|
74
|
-
end
|
75
|
-
|
76
|
-
describe 'core Ruby types' do
|
77
|
-
should 'not add errors for calling defined methods on a Fixnum' do
|
78
|
-
report = build_report('10.to_s', RubyLint::Analysis::UndefinedMethods)
|
79
|
-
|
80
|
-
report.entries.empty?.should == true
|
81
|
-
end
|
82
|
-
|
83
|
-
should 'not add errors for calling defined methods on a Float' do
|
84
|
-
report = build_report('(10.0).to_s', RubyLint::Analysis::UndefinedMethods)
|
85
|
-
|
86
|
-
report.entries.empty?.should == true
|
87
|
-
end
|
88
|
-
|
89
|
-
should 'not add errors for calling defined methods on a String' do
|
90
|
-
report = build_report('"10".to_s', RubyLint::Analysis::UndefinedMethods)
|
91
|
-
|
92
|
-
report.entries.empty?.should == true
|
93
|
-
end
|
94
|
-
|
95
|
-
should 'not add errors for calling defined methods on a Hash' do
|
96
|
-
report = build_report('{}.to_s', RubyLint::Analysis::UndefinedMethods)
|
97
|
-
|
98
|
-
report.entries.empty?.should == true
|
99
|
-
end
|
100
|
-
|
101
|
-
should 'not add errors for calling defined methods on an Array' do
|
102
|
-
report = build_report('[].to_s', RubyLint::Analysis::UndefinedMethods)
|
103
|
-
|
104
|
-
report.entries.empty?.should == true
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
should 'not add errors for variables created using blocks' do
|
109
|
-
code = <<-CODE
|
110
|
-
[10, 20].each do |number|
|
111
|
-
number.to_s
|
112
|
-
end
|
113
|
-
CODE
|
114
|
-
|
115
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
116
|
-
|
117
|
-
report.entries.empty?.should == true
|
118
|
-
end
|
119
|
-
|
120
|
-
should 'take variable assignments into account' do
|
121
|
-
code = <<-CODE
|
122
|
-
name = 'Ruby'
|
123
|
-
|
124
|
-
name.downcase
|
125
|
-
name.downcasex
|
126
|
-
CODE
|
127
|
-
|
128
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
129
|
-
|
130
|
-
report.entries.length.should == 1
|
131
|
-
|
132
|
-
entry = report.entries[0]
|
133
|
-
|
134
|
-
entry.line.should == 4
|
135
|
-
entry.column.should == 0
|
136
|
-
entry.message.should == 'undefined method downcasex on an instance of String'
|
137
|
-
end
|
138
|
-
|
139
|
-
should 'not add errors when calling a method on an undefined constant' do
|
140
|
-
code = 'A.example_method'
|
141
|
-
|
142
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
143
|
-
|
144
|
-
report.entries.empty?.should == true
|
145
|
-
end
|
146
|
-
|
147
|
-
should 'not add errors for methods called on variables without values' do
|
148
|
-
code = <<-CODE
|
149
|
-
def example(number)
|
150
|
-
number.to_s
|
151
|
-
end
|
152
|
-
CODE
|
153
|
-
|
154
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
155
|
-
|
156
|
-
report.entries.empty?.should == true
|
157
|
-
end
|
158
|
-
|
159
|
-
should 'report the right receiver name in multiple variable assignments' do
|
160
|
-
code = <<-CODE
|
161
|
-
number = 10
|
162
|
-
|
163
|
-
first = second = number.foobar
|
164
|
-
CODE
|
165
|
-
|
166
|
-
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
167
|
-
|
168
|
-
report.entries.length.should == 1
|
169
|
-
|
170
|
-
entry = report.entries[0]
|
171
|
-
|
172
|
-
entry.message.should == 'undefined method foobar on an instance of Fixnum'
|
173
|
-
end
|
174
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require File.expand_path('../../helper', __FILE__)
|
2
|
-
|
3
|
-
describe RubyLint::Configuration do
|
4
|
-
describe 'default options' do
|
5
|
-
before do
|
6
|
-
@configuration = RubyLint::Configuration.new
|
7
|
-
end
|
8
|
-
|
9
|
-
should 'set the default report levels' do
|
10
|
-
@configuration.report_levels.should == RubyLint::Report::DEFAULT_LEVELS
|
11
|
-
end
|
12
|
-
|
13
|
-
should 'set the default presenter' do
|
14
|
-
@configuration.default_presenter.should == RubyLint::Presenter::Text
|
15
|
-
end
|
16
|
-
|
17
|
-
should 'set the default analysis classes' do
|
18
|
-
@configuration.default_analysis_classes.empty?.should == false
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'setting options via the constructor' do
|
23
|
-
should 'set the report levels' do
|
24
|
-
conf = RubyLint::Configuration.new(:report_levels => ['info'])
|
25
|
-
|
26
|
-
conf.report_levels.should == [:info]
|
27
|
-
end
|
28
|
-
|
29
|
-
should 'set the presenter' do
|
30
|
-
conf = RubyLint::Configuration.new(:presenter => 'json')
|
31
|
-
|
32
|
-
conf.presenter.should == RubyLint::Presenter::JSON
|
33
|
-
end
|
34
|
-
|
35
|
-
should 'set the analysis classes' do
|
36
|
-
conf = RubyLint::Configuration.new(
|
37
|
-
:analysis_classes => ['undefined_methods']
|
38
|
-
)
|
39
|
-
|
40
|
-
conf.analysis_classes.should == [RubyLint::Analysis::UndefinedMethods]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'setting options via a configuration file' do
|
45
|
-
should 'set the options from a YAML file' do
|
46
|
-
paths = [File.expand_path('../../fixtures/config.yml', __FILE__)]
|
47
|
-
conf = RubyLint::Configuration.load_from_file(paths)
|
48
|
-
|
49
|
-
conf.report_levels.should == [:info]
|
50
|
-
conf.analysis_classes.should == [RubyLint::Analysis::UndefinedMethods]
|
51
|
-
conf.presenter.should == RubyLint::Presenter::JSON
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
2
|
-
|
3
|
-
describe RubyLint::Definition::ConstantProxy do
|
4
|
-
before do
|
5
|
-
@source = ruby_object.new(:name => 'global', :type => :global)
|
6
|
-
@proxy = RubyLint::Definition::ConstantProxy.new(@source, 'Foo')
|
7
|
-
end
|
8
|
-
|
9
|
-
should 'create a new constant proxy' do
|
10
|
-
@proxy.proxy_source.should == @source
|
11
|
-
@proxy.proxy_name.should == 'Foo'
|
12
|
-
end
|
13
|
-
|
14
|
-
should 'act like a RubyObject definition' do
|
15
|
-
@proxy.lookup(:const, 'Bar').nil?.should == true
|
16
|
-
end
|
17
|
-
|
18
|
-
should 'cache the definition when it exists' do
|
19
|
-
@proxy.name.nil?.should == true
|
20
|
-
@proxy.type.nil?.should == true
|
21
|
-
|
22
|
-
@proxy.lookup(:const, 'VERSION').nil?.should == true
|
23
|
-
|
24
|
-
@source.define_constant('Foo').define_constant('VERSION')
|
25
|
-
|
26
|
-
@proxy.name.should == 'Foo'
|
27
|
-
@proxy.type.should == :const
|
28
|
-
|
29
|
-
@proxy.lookup(:const, 'VERSION').is_a?(ruby_object).should == true
|
30
|
-
end
|
31
|
-
end
|
data/spec/ruby-lint/parser.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path('../../helper', __FILE__)
|
2
|
-
|
3
|
-
describe RubyLint::Parser do
|
4
|
-
should 'parse a block of Ruby code' do
|
5
|
-
ast = parse('10', false)
|
6
|
-
|
7
|
-
ast.type.should == :root
|
8
|
-
ast.children.length.should == 1
|
9
|
-
end
|
10
|
-
|
11
|
-
should 'use a custom node class' do
|
12
|
-
parse('10').class.should == RubyLint::AST::Node
|
13
|
-
end
|
14
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
describe RubyLint::Presenter::JSON do
|
5
|
-
should 'format a set of entries' do
|
6
|
-
report = RubyLint::Report.new
|
7
|
-
presenter = RubyLint::Presenter::JSON.new
|
8
|
-
|
9
|
-
report.error('error message', 1, 1, 'a.rb')
|
10
|
-
report.error('error message 2', 2, 1, 'a.rb')
|
11
|
-
report.warning('warning message', 1, 1, 'b.rb')
|
12
|
-
report.info('info message', 1, 1, 'c.rb')
|
13
|
-
|
14
|
-
output = presenter.present(report)
|
15
|
-
decoded = JSON(output)
|
16
|
-
|
17
|
-
decoded.length.should == 4
|
18
|
-
|
19
|
-
decoded[0]['file'].should == 'a.rb'
|
20
|
-
decoded[0]['level'].should == 'error'
|
21
|
-
|
22
|
-
decoded[1]['file'].should == 'a.rb'
|
23
|
-
decoded[1]['level'].should == 'error'
|
24
|
-
|
25
|
-
decoded[2]['file'].should == 'b.rb'
|
26
|
-
decoded[2]['level'].should == 'warning'
|
27
|
-
|
28
|
-
decoded[3]['file'].should == 'c.rb'
|
29
|
-
decoded[3]['level'].should == 'info'
|
30
|
-
end
|
31
|
-
end
|