ruby-lint 0.0.3 → 0.0.4
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.
- data.tar.gz.asc +14 -14
- data/.gitignore +1 -2
- data/.rubocop.yml +59 -0
- data/.travis.yml +3 -7
- data/.yardopts +2 -2
- data/Gemfile +4 -0
- data/MANIFEST +103 -67
- data/README.md +13 -31
- data/Rakefile +1 -6
- data/checksum/ruby-lint-0.0.3.gem.sha512 +1 -0
- data/debug/memory_usage.rb +14 -0
- data/debug/profile.rb +18 -0
- data/doc/architecture.md +14 -18
- data/doc/changelog.md +29 -0
- data/doc/code_analysis.md +12 -12
- data/doc/configuration.md +21 -50
- data/doc/graphviz/flow.dot +1 -1
- data/doc/images/flow.png +0 -0
- data/lib/ruby-lint.rb +33 -19
- data/lib/ruby-lint/analysis/argument_amount.rb +84 -0
- data/lib/ruby-lint/analysis/base.rb +132 -0
- data/lib/ruby-lint/analysis/confusing_variables.rb +26 -0
- data/lib/ruby-lint/analysis/pedantics.rb +36 -0
- data/lib/ruby-lint/analysis/shadowing_variables.rb +47 -0
- data/lib/ruby-lint/analysis/undefined_methods.rb +91 -0
- data/lib/ruby-lint/analysis/undefined_variables.rb +46 -0
- data/lib/ruby-lint/analysis/unused_variables.rb +49 -0
- data/lib/ruby-lint/ast/builder.rb +17 -0
- data/lib/ruby-lint/ast/node.rb +39 -0
- data/lib/ruby-lint/cli.rb +0 -19
- data/lib/ruby-lint/cli/analyze.rb +54 -28
- data/lib/ruby-lint/cli/ast.rb +21 -6
- data/lib/ruby-lint/cli/base.rb +0 -23
- data/lib/ruby-lint/configuration.rb +112 -42
- data/lib/ruby-lint/constant_loader.rb +10 -28
- data/lib/ruby-lint/default_names.rb +19 -0
- data/lib/ruby-lint/definition/constant_proxy.rb +56 -0
- data/lib/ruby-lint/definition/ruby_method.rb +21 -143
- data/lib/ruby-lint/definition/ruby_object.rb +142 -246
- data/lib/ruby-lint/definition_builder/base.rb +43 -0
- data/lib/ruby-lint/definition_builder/primitive.rb +39 -0
- data/lib/ruby-lint/definition_builder/ruby_array.rb +77 -0
- data/lib/ruby-lint/definition_builder/ruby_block.rb +34 -0
- data/lib/ruby-lint/definition_builder/ruby_class.rb +24 -0
- data/lib/ruby-lint/definition_builder/ruby_hash.rb +37 -0
- data/lib/ruby-lint/definition_builder/ruby_method.rb +84 -0
- data/lib/ruby-lint/definition_builder/ruby_module.rb +68 -0
- data/lib/ruby-lint/definition_generator.rb +41 -15
- 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 +3 -3
- 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 +22 -22
- 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 +3 -3
- 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/main.rb +1 -1
- 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 +1 -1
- 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/psych.rb +149 -149
- 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/rubinius.rb +1057 -1057
- 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_lint.rb +9 -9
- 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 +1 -1
- data/lib/ruby-lint/definitions/core/stdin.rb +1 -1
- data/lib/ruby-lint/definitions/core/stdout.rb +1 -1
- 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/zero_division_error.rb +2 -2
- data/lib/ruby-lint/definitions/rails.rb +12 -0
- data/lib/ruby-lint/definitions/rails/abstract_controller.rb +335 -0
- data/lib/ruby-lint/definitions/rails/action_controller.rb +1244 -0
- data/lib/ruby-lint/definitions/rails/action_dispatch.rb +741 -0
- data/lib/ruby-lint/definitions/rails/action_mailer.rb +502 -0
- data/lib/ruby-lint/definitions/rails/action_pack.rb +16 -0
- data/lib/ruby-lint/definitions/rails/action_view.rb +898 -0
- data/lib/ruby-lint/definitions/rails/active_model.rb +437 -0
- data/lib/ruby-lint/definitions/rails/active_record.rb +2901 -0
- data/lib/ruby-lint/definitions/rails/active_support.rb +1963 -0
- data/lib/ruby-lint/definitions/rails/arel.rb +665 -0
- data/lib/ruby-lint/definitions/rails/rails.rb +452 -0
- data/lib/ruby-lint/definitions/rails/sprockets.rb +968 -0
- data/lib/ruby-lint/generated_constant.rb +33 -0
- data/lib/ruby-lint/helper/constant_paths.rb +30 -21
- data/lib/ruby-lint/inspector.rb +20 -2
- data/lib/ruby-lint/iterator.rb +11 -171
- data/lib/ruby-lint/nested_stack.rb +46 -0
- data/lib/ruby-lint/parser.rb +24 -806
- data/lib/ruby-lint/report.rb +2 -30
- data/lib/ruby-lint/report/entry.rb +2 -2
- data/lib/ruby-lint/runner.rb +81 -0
- data/lib/ruby-lint/template/definition.erb +12 -8
- data/lib/ruby-lint/variable_predicates.rb +16 -58
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +1044 -0
- data/ruby-lint.gemspec +17 -7
- data/spec/fixtures/complex/rails/basic_controller.rb +9 -0
- data/spec/fixtures/complex/rcap.rb +38 -0
- data/spec/fixtures/complex/slop.rb +680 -0
- data/spec/fixtures/config.yml +8 -0
- data/spec/fixtures/invalid.rb +3 -0
- data/spec/fixtures/invalid_2.rb +3 -0
- data/spec/fixtures/syntax_error.rb +1 -0
- data/spec/fixtures/valid.rb +3 -0
- data/spec/helper.rb +6 -0
- data/spec/ruby-lint/{analyze → analysis}/argument_amount.rb +7 -7
- data/spec/ruby-lint/analysis/confusing_variables.rb +46 -0
- data/spec/ruby-lint/analysis/pedantics.rb +43 -0
- data/spec/ruby-lint/{analyze → analysis}/shadowing_variables.rb +5 -5
- data/spec/ruby-lint/{analyze → analysis}/undefined_methods.rb +18 -18
- data/spec/ruby-lint/{analyze → analysis}/undefined_variables.rb +19 -25
- data/spec/ruby-lint/{analyze → analysis}/unused_variables.rb +29 -16
- data/spec/ruby-lint/ast/node.rb +33 -0
- data/spec/ruby-lint/cli/analyze.rb +31 -0
- data/spec/ruby-lint/cli/ast.rb +23 -0
- data/spec/ruby-lint/configuration.rb +45 -6
- data/spec/ruby-lint/definition/constant_proxy.rb +31 -0
- data/spec/ruby-lint/definition/dsl.rb +13 -20
- data/spec/ruby-lint/definition/ruby_method.rb +65 -148
- data/spec/ruby-lint/definition/ruby_object.rb +60 -96
- data/spec/ruby-lint/definition_builder/primitive.rb +62 -0
- data/spec/ruby-lint/definition_builder/ruby_class.rb +108 -0
- data/spec/ruby-lint/definition_builder/ruby_method.rb +53 -0
- data/spec/ruby-lint/definition_builder/ruby_module.rb +50 -0
- data/spec/ruby-lint/iterator.rb +40 -16
- data/spec/ruby-lint/nested_stack.rb +23 -0
- data/spec/ruby-lint/parser.rb +14 -0
- data/spec/ruby-lint/report.rb +0 -10
- data/spec/ruby-lint/report/entry.rb +8 -4
- data/spec/ruby-lint/runner.rb +32 -0
- data/spec/ruby-lint/virtual_machine/assignments/arrays.rb +87 -0
- data/spec/ruby-lint/virtual_machine/assignments/hashes.rb +52 -0
- data/spec/ruby-lint/virtual_machine/assignments/optional.rb +41 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/assignments/return_values.rb +11 -11
- data/spec/ruby-lint/virtual_machine/assignments/variables.rb +85 -0
- data/spec/ruby-lint/virtual_machine/associate_nodes.rb +17 -0
- data/spec/ruby-lint/virtual_machine/autoloading.rb +31 -0
- data/spec/ruby-lint/virtual_machine/blocks.rb +64 -0
- data/spec/ruby-lint/virtual_machine/classes/class_methods.rb +21 -0
- data/spec/ruby-lint/virtual_machine/classes/extending.rb +104 -0
- data/spec/ruby-lint/virtual_machine/classes/redefining.rb +24 -0
- data/spec/ruby-lint/virtual_machine/classes/sclass.rb +94 -0
- data/spec/ruby-lint/virtual_machine/classes/scoping.rb +60 -0
- data/spec/ruby-lint/virtual_machine/complex/rails.rb +18 -0
- data/spec/ruby-lint/virtual_machine/complex/rcap.rb +15 -0
- data/spec/ruby-lint/virtual_machine/complex/slop.rb +16 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/for.rb +2 -2
- data/spec/ruby-lint/virtual_machine/freeze.rb +13 -0
- data/spec/ruby-lint/virtual_machine/interpolation.rb +12 -0
- data/spec/ruby-lint/virtual_machine/methods/defining.rb +40 -0
- data/spec/ruby-lint/virtual_machine/methods/exporting.rb +19 -0
- data/spec/ruby-lint/virtual_machine/methods/parameters.rb +77 -0
- data/spec/ruby-lint/virtual_machine/methods/patching.rb +26 -0
- data/spec/ruby-lint/virtual_machine/methods/scoping.rb +63 -0
- data/spec/ruby-lint/virtual_machine/methods/visibility.rb +64 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/modules.rb +16 -16
- data/spec/ruby-lint/virtual_machine/reference_amount.rb +33 -0
- data/spec/ruby-lint/virtual_machine/unused.rb +17 -0
- data/spec/support/bacon.rb +13 -13
- data/spec/support/building.rb +23 -16
- data/spec/support/coveralls.rb +5 -0
- data/spec/support/fixtures.rb +20 -0
- data/spec/support/parsing.rb +3 -5
- data/spec/support/simplecov.rb +5 -3
- data/task/build.rake +1 -1
- data/task/cop.rake +11 -0
- data/task/generate.rake +40 -2
- data/task/profile.rake +27 -0
- data/task/todo.rake +6 -0
- data/task/travis.rake +7 -0
- metadata +160 -75
- metadata.gz.asc +14 -14
- data/doc/build/.gitkeep +0 -0
- data/lib/ruby-lint/analyze/argument_amount.rb +0 -73
- data/lib/ruby-lint/analyze/shadowing_variables.rb +0 -32
- data/lib/ruby-lint/analyze/undefined_methods.rb +0 -68
- data/lib/ruby-lint/analyze/undefined_variables.rb +0 -72
- data/lib/ruby-lint/analyze/unused_variables.rb +0 -48
- data/lib/ruby-lint/base.rb +0 -85
- data/lib/ruby-lint/definitions_builder.rb +0 -692
- data/lib/ruby-lint/helper/conversion.rb +0 -33
- data/lib/ruby-lint/helper/current_scope.rb +0 -98
- data/lib/ruby-lint/helper/methods.rb +0 -91
- data/lib/ruby-lint/node.rb +0 -107
- data/lib/ruby-lint/parser_error.rb +0 -30
- data/spec/ruby-lint/constant_loader.rb +0 -32
- data/spec/ruby-lint/definition/method_calls.rb +0 -26
- data/spec/ruby-lint/definitions_builder/assignments/arrays.rb +0 -71
- data/spec/ruby-lint/definitions_builder/assignments/hashes.rb +0 -65
- data/spec/ruby-lint/definitions_builder/assignments/objects.rb +0 -23
- data/spec/ruby-lint/definitions_builder/assignments/optional.rb +0 -22
- data/spec/ruby-lint/definitions_builder/assignments/variables.rb +0 -71
- data/spec/ruby-lint/definitions_builder/associate_nodes.rb +0 -17
- data/spec/ruby-lint/definitions_builder/blocks.rb +0 -40
- data/spec/ruby-lint/definitions_builder/classes.rb +0 -230
- data/spec/ruby-lint/definitions_builder/methods.rb +0 -147
- data/spec/ruby-lint/definitions_builder/reference_amount.rb +0 -31
- data/spec/ruby-lint/definitions_builder/unused.rb +0 -15
- data/spec/ruby-lint/node.rb +0 -38
- data/spec/ruby-lint/parser/assignments.rb +0 -225
- data/spec/ruby-lint/parser/classes.rb +0 -110
- data/spec/ruby-lint/parser/errors.rb +0 -12
- data/spec/ruby-lint/parser/metadata.rb +0 -17
- data/spec/ruby-lint/parser/method_definitions.rb +0 -111
- data/spec/ruby-lint/parser/methods.rb +0 -217
- data/spec/ruby-lint/parser/modules.rb +0 -70
- data/spec/ruby-lint/parser/operators.rb +0 -40
- data/spec/ruby-lint/parser/statements/begin.rb +0 -55
- data/spec/ruby-lint/parser/statements/case.rb +0 -34
- data/spec/ruby-lint/parser/statements/defined.rb +0 -11
- data/spec/ruby-lint/parser/statements/for.rb +0 -34
- data/spec/ruby-lint/parser/statements/if.rb +0 -46
- data/spec/ruby-lint/parser/statements/return.rb +0 -14
- data/spec/ruby-lint/parser/statements/super.rb +0 -49
- data/spec/ruby-lint/parser/statements/unless.rb +0 -42
- data/spec/ruby-lint/parser/statements/until.rb +0 -25
- data/spec/ruby-lint/parser/statements/while.rb +0 -25
- data/spec/ruby-lint/parser/statements/yield.rb +0 -18
- data/spec/ruby-lint/parser/types/arrays.rb +0 -47
- data/spec/ruby-lint/parser/types/booleans.rb +0 -11
- data/spec/ruby-lint/parser/types/constants.rb +0 -32
- data/spec/ruby-lint/parser/types/hashes.rb +0 -55
- data/spec/ruby-lint/parser/types/nil.rb +0 -7
- data/spec/ruby-lint/parser/types/numbers.rb +0 -11
- data/spec/ruby-lint/parser/types/procs.rb +0 -11
- data/spec/ruby-lint/parser/types/ranges.rb +0 -11
- data/spec/ruby-lint/parser/types/regexp.rb +0 -27
- data/spec/ruby-lint/parser/types/strings.rb +0 -44
- data/spec/ruby-lint/parser/types/symbols.rb +0 -15
- data/task/stdlib.rake +0 -23
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
|
2
2
|
|
|
3
|
-
describe RubyLint::
|
|
3
|
+
describe RubyLint::Analysis::UnusedVariables do
|
|
4
4
|
should 'warn for unused local variables' do
|
|
5
|
-
report = build_report('number = 1', RubyLint::
|
|
5
|
+
report = build_report('number = 1', RubyLint::Analysis::UnusedVariables)
|
|
6
6
|
entry = report.entries[0]
|
|
7
7
|
|
|
8
8
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
|
@@ -12,19 +12,20 @@ describe RubyLint::Analyze::UnusedVariables do
|
|
|
12
12
|
entry.message.should == 'unused local variable number'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
should 'warn for
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
should 'not warn for used variables' do
|
|
16
|
+
code = <<-CODE
|
|
17
|
+
number = 1
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
number
|
|
20
|
+
CODE
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
|
23
|
+
|
|
24
|
+
report.entries.empty?.should == true
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
should 'warn for unused constants' do
|
|
27
|
-
report = build_report('NUMBER = 10', RubyLint::
|
|
28
|
+
report = build_report('NUMBER = 10', RubyLint::Analysis::UnusedVariables)
|
|
28
29
|
entry = report.entries[0]
|
|
29
30
|
|
|
30
31
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
|
@@ -34,6 +35,18 @@ describe RubyLint::Analyze::UnusedVariables do
|
|
|
34
35
|
entry.message.should == 'unused constant NUMBER'
|
|
35
36
|
end
|
|
36
37
|
|
|
38
|
+
should 'not warn for used constants' do
|
|
39
|
+
code = <<-CODE
|
|
40
|
+
A = 10
|
|
41
|
+
|
|
42
|
+
A
|
|
43
|
+
CODE
|
|
44
|
+
|
|
45
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
|
46
|
+
|
|
47
|
+
report.entries.empty?.should == true
|
|
48
|
+
end
|
|
49
|
+
|
|
37
50
|
should 'warn for unused constant paths' do
|
|
38
51
|
code = <<-CODE
|
|
39
52
|
module A
|
|
@@ -42,7 +55,7 @@ end
|
|
|
42
55
|
A::B = 10
|
|
43
56
|
CODE
|
|
44
57
|
|
|
45
|
-
report = build_report(code, RubyLint::
|
|
58
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
|
46
59
|
|
|
47
60
|
report.entries.length.should == 1
|
|
48
61
|
|
|
@@ -51,8 +64,8 @@ A::B = 10
|
|
|
51
64
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
|
52
65
|
|
|
53
66
|
entry.line.should == 4
|
|
54
|
-
entry.column.should ==
|
|
55
|
-
entry.message.should == 'unused constant B'
|
|
67
|
+
entry.column.should == 0
|
|
68
|
+
entry.message.should == 'unused constant A::B'
|
|
56
69
|
end
|
|
57
70
|
|
|
58
71
|
should 'warn for unused variables in a method scope' do
|
|
@@ -62,7 +75,7 @@ def some_method
|
|
|
62
75
|
end
|
|
63
76
|
CODE
|
|
64
77
|
|
|
65
|
-
report = build_report(code, RubyLint::
|
|
78
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
|
66
79
|
entry = report.entries[0]
|
|
67
80
|
|
|
68
81
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
|
@@ -78,7 +91,7 @@ first = 10
|
|
|
78
91
|
second = first
|
|
79
92
|
CODE
|
|
80
93
|
|
|
81
|
-
report = build_report(code, RubyLint::
|
|
94
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
|
82
95
|
|
|
83
96
|
report.entries.length.should == 1
|
|
84
97
|
|
|
@@ -98,7 +111,7 @@ class B
|
|
|
98
111
|
end
|
|
99
112
|
CODE
|
|
100
113
|
|
|
101
|
-
report = build_report(code, RubyLint::
|
|
114
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
|
102
115
|
|
|
103
116
|
report.entries.empty?.should == true
|
|
104
117
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
|
2
|
+
|
|
3
|
+
describe RubyLint::AST::Node do
|
|
4
|
+
should 'return the value for a scalar' do
|
|
5
|
+
s(:str, 'hello').children[0].should == 'hello'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
should 'return the value for an Array' do
|
|
9
|
+
numbers = s(:array, s(:int, 10), s(:int, 20)).children
|
|
10
|
+
|
|
11
|
+
numbers.is_a?(Array).should == true
|
|
12
|
+
numbers.length.should == 2
|
|
13
|
+
|
|
14
|
+
numbers[0].children[0].should == 10
|
|
15
|
+
numbers[1].children[0].should == 20
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should 'return the value for a Hash' do
|
|
19
|
+
pairs = s(:hash, s(:pair, s(:str, 'number'), s(:int, 10))).children
|
|
20
|
+
|
|
21
|
+
pairs.is_a?(Array).should == true
|
|
22
|
+
|
|
23
|
+
pairs[0].children[1].children[0].should == 10
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should 'should try to guess the Ruby class of a node' do
|
|
27
|
+
s(:str, 'foo').ruby_class.should == 'String'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
should 'check if a node is a constant path' do
|
|
31
|
+
s(:const, s(:const, nil, :A), :B).constant_path?.should == true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
|
2
|
+
require File.expand_path('../../../../lib/ruby-lint/cli', __FILE__)
|
|
3
|
+
|
|
4
|
+
describe RubyLint::CLI do
|
|
5
|
+
describe 'analyze' do
|
|
6
|
+
before do
|
|
7
|
+
@command = RubyLint::CLI.options.commands['analyze']
|
|
8
|
+
@output = StringIO.new
|
|
9
|
+
|
|
10
|
+
@command.output_destination = @output
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
should 'analyze a valid Ruby file' do
|
|
14
|
+
file = File.expand_path('../../../fixtures/valid.rb', __FILE__)
|
|
15
|
+
|
|
16
|
+
@command.parse([file])
|
|
17
|
+
|
|
18
|
+
@output.rewind
|
|
19
|
+
@output.read.empty?.should == true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
should 'analyze an invalid Ruby file' do
|
|
23
|
+
file = File.expand_path('../../../fixtures/invalid.rb', __FILE__)
|
|
24
|
+
|
|
25
|
+
@command.parse([file])
|
|
26
|
+
|
|
27
|
+
@output.rewind
|
|
28
|
+
@output.read.should =~ /undefined method foobar/
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
|
2
|
+
require File.expand_path('../../../../lib/ruby-lint/cli', __FILE__)
|
|
3
|
+
|
|
4
|
+
describe RubyLint::CLI do
|
|
5
|
+
describe 'ast' do
|
|
6
|
+
before do
|
|
7
|
+
@command = RubyLint::CLI.options.commands['ast']
|
|
8
|
+
@output = StringIO.new
|
|
9
|
+
|
|
10
|
+
@command.output_destination = @output
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
should 'show the AST of a Ruby file' do
|
|
14
|
+
file = File.expand_path('../../../fixtures/valid.rb', __FILE__)
|
|
15
|
+
output = RubyLint::Parser.new.parse(File.read(file)).inspect
|
|
16
|
+
|
|
17
|
+
@command.parse([file])
|
|
18
|
+
|
|
19
|
+
@output.rewind
|
|
20
|
+
@output.read.strip.should == output
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
require File.expand_path('../../helper', __FILE__)
|
|
2
2
|
|
|
3
3
|
describe RubyLint::Configuration do
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
describe 'default options' do
|
|
5
|
+
before do
|
|
6
|
+
@configuration = RubyLint::Configuration.new
|
|
7
|
+
end
|
|
6
8
|
|
|
7
|
-
|
|
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
|
|
8
42
|
end
|
|
9
43
|
|
|
10
|
-
|
|
11
|
-
|
|
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)
|
|
12
48
|
|
|
13
|
-
|
|
49
|
+
conf.report_levels.should == [:info]
|
|
50
|
+
conf.analysis_classes.should == [RubyLint::Analysis::UndefinedMethods]
|
|
51
|
+
conf.presenter.should == RubyLint::Presenter::JSON
|
|
52
|
+
end
|
|
14
53
|
end
|
|
15
54
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
|
@@ -2,14 +2,14 @@ require File.expand_path('../../../helper', __FILE__)
|
|
|
2
2
|
|
|
3
3
|
describe RubyLint::Definition::RubyObject do
|
|
4
4
|
before do
|
|
5
|
-
@first = ruby_object.new(:name => 'First', :type => :
|
|
5
|
+
@first = ruby_object.new(:name => 'First', :type => :const)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
describe 'definining constants using a DSL' do
|
|
9
9
|
should 'define a constant' do
|
|
10
10
|
@first.define_constant('B')
|
|
11
11
|
|
|
12
|
-
@first.lookup(:
|
|
12
|
+
@first.lookup(:const, 'B').is_a?(ruby_object).should == true
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
should 'define a constant using a block' do
|
|
@@ -17,8 +17,8 @@ describe RubyLint::Definition::RubyObject do
|
|
|
17
17
|
b.define_constant('C')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
@first.lookup(:
|
|
21
|
-
.lookup(:
|
|
20
|
+
@first.lookup(:const, 'B') \
|
|
21
|
+
.lookup(:const, 'C') \
|
|
22
22
|
.is_a?(ruby_object) \
|
|
23
23
|
.should == true
|
|
24
24
|
end
|
|
@@ -29,11 +29,11 @@ describe RubyLint::Definition::RubyObject do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
@first.define_constant('D') do |d|
|
|
32
|
-
d.inherits(@first.lookup(:
|
|
32
|
+
d.inherits(@first.lookup(:const, 'B'))
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
@first.lookup(:
|
|
36
|
-
.lookup(:
|
|
35
|
+
@first.lookup(:const, 'D') \
|
|
36
|
+
.lookup(:const, 'C') \
|
|
37
37
|
.is_a?(ruby_object) \
|
|
38
38
|
.should == true
|
|
39
39
|
end
|
|
@@ -42,8 +42,8 @@ describe RubyLint::Definition::RubyObject do
|
|
|
42
42
|
@first.define_constant('A')
|
|
43
43
|
@first.define_constant('A::B')
|
|
44
44
|
|
|
45
|
-
@first.lookup(:
|
|
46
|
-
.lookup(:
|
|
45
|
+
@first.lookup(:const, 'A') \
|
|
46
|
+
.lookup(:const, 'B') \
|
|
47
47
|
.is_a?(ruby_object) \
|
|
48
48
|
.should == true
|
|
49
49
|
end
|
|
@@ -65,7 +65,7 @@ describe RubyLint::Definition::RubyObject do
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
should 'define a method\'s return value' do
|
|
68
|
-
string = ruby_object.new(:type => :
|
|
68
|
+
string = ruby_object.new(:type => :str, :value => 'hello')
|
|
69
69
|
|
|
70
70
|
@first.define_method('example') do |example|
|
|
71
71
|
example.returns(string)
|
|
@@ -100,13 +100,6 @@ describe RubyLint::Definition::RubyObject do
|
|
|
100
100
|
arg.name.should == 'number'
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
should 'add a more argument' do
|
|
104
|
-
arg = method_with_argument(@first, :more_argument).more_arguments.first
|
|
105
|
-
|
|
106
|
-
arg.is_a?(ruby_object).should == true
|
|
107
|
-
arg.name.should == 'number'
|
|
108
|
-
end
|
|
109
|
-
|
|
110
103
|
should 'add a block argument' do
|
|
111
104
|
arg = method_with_argument(@first, :block_argument).block_argument
|
|
112
105
|
|
|
@@ -132,11 +125,11 @@ describe RubyLint::Definition::RubyObject do
|
|
|
132
125
|
should 'define a global variable' do
|
|
133
126
|
@first.define_global_variable('$number', '10')
|
|
134
127
|
|
|
135
|
-
found = @first.lookup(:
|
|
128
|
+
found = @first.lookup(:gvar, '$number')
|
|
136
129
|
|
|
137
130
|
found.is_a?(ruby_object).should == true
|
|
138
|
-
found.type.should
|
|
139
|
-
found.name.should
|
|
131
|
+
found.type.should == :gvar
|
|
132
|
+
found.name.should == '$number'
|
|
140
133
|
end
|
|
141
134
|
end
|
|
142
135
|
end
|
|
@@ -1,175 +1,92 @@
|
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
|
2
2
|
|
|
3
|
-
describe
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:method_definition,
|
|
8
|
-
'example',
|
|
9
|
-
s(
|
|
10
|
-
:arguments,
|
|
11
|
-
s(:argument, s(:local_variable, 'required')),
|
|
12
|
-
s(
|
|
13
|
-
:optional_argument,
|
|
14
|
-
s(:local_variable, 'number', s(:integer, '10'))
|
|
15
|
-
),
|
|
16
|
-
s(:rest_argument, s(:local_variable, 'rest')),
|
|
17
|
-
s(:more_argument, s(:local_variable, 'more')),
|
|
18
|
-
s(:block_argument, s(:local_variable, 'block'))
|
|
19
|
-
),
|
|
20
|
-
s(:constant, 'String'),
|
|
21
|
-
s(:body, [s(:return, s(:local_variable, 'required'))])
|
|
22
|
-
)
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
@method_call = ruby_method.new_from_node(
|
|
26
|
-
s(
|
|
27
|
-
:method,
|
|
28
|
-
'example',
|
|
29
|
-
s(:arguments, s(:argument, s(:integer, '10'))),
|
|
30
|
-
s(:constant, 'String')
|
|
31
|
-
)
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
should 'return the correct method names' do
|
|
36
|
-
@method_def.name.should == 'example'
|
|
37
|
-
@method_call.name.should == 'example'
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
should 'return the correct object types' do
|
|
41
|
-
@method_def.type.should == :method_definition
|
|
42
|
-
@method_call.type.should == :method
|
|
43
|
-
|
|
44
|
-
@method_def.method?.should == false
|
|
45
|
-
@method_call.method?.should == true
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
should 'return the method definition receiver' do
|
|
49
|
-
@method_def.receiver.is_a?(ruby_object).should == true
|
|
50
|
-
@method_def.receiver.name.should == 'String'
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
should 'return the method call receiver' do
|
|
54
|
-
@method_call.receiver.is_a?(ruby_object).should == true
|
|
55
|
-
@method_call.receiver.name.should == 'String'
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
should 'set the correct method definition type' do
|
|
59
|
-
@method_def.method_type.should == :method
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe 'method definition arguments' do
|
|
63
|
-
should 'return the required arguments' do
|
|
64
|
-
@method_def.arguments.length.should == 1
|
|
65
|
-
|
|
66
|
-
required = @method_def.arguments[0]
|
|
67
|
-
|
|
68
|
-
required.is_a?(ruby_object).should == true
|
|
69
|
-
|
|
70
|
-
required.name.should == 'required'
|
|
3
|
+
describe RubyLint::Definition::RubyObject do
|
|
4
|
+
describe 'method definition DSL' do
|
|
5
|
+
before do
|
|
6
|
+
@method = ruby_method.new(:name => 'example', :type => :instance_method)
|
|
71
7
|
end
|
|
72
8
|
|
|
73
|
-
|
|
74
|
-
|
|
9
|
+
describe 'return values' do
|
|
10
|
+
should 'return a static value' do
|
|
11
|
+
@method.returns(10)
|
|
75
12
|
|
|
76
|
-
|
|
13
|
+
@method.return_value.should == 10
|
|
14
|
+
end
|
|
77
15
|
|
|
78
|
-
|
|
16
|
+
should 'return a value using a block' do
|
|
17
|
+
@method.returns do
|
|
18
|
+
20
|
|
19
|
+
end
|
|
79
20
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
number.value.value.should == '10'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
should 'return the rest argument' do
|
|
88
|
-
@method_def.rest_argument.nil?.should == false
|
|
89
|
-
@method_def.rest_argument.name.should == 'rest'
|
|
21
|
+
@method.return_value.is_a?(Proc).should == true
|
|
22
|
+
@method.return_value.call.should == 20
|
|
23
|
+
end
|
|
90
24
|
end
|
|
91
25
|
|
|
92
|
-
|
|
93
|
-
|
|
26
|
+
describe 'calling methods' do
|
|
27
|
+
before do
|
|
28
|
+
@method.returns(10)
|
|
29
|
+
end
|
|
94
30
|
|
|
95
|
-
|
|
31
|
+
should 'call the method directly' do
|
|
32
|
+
@method.call.should == 10
|
|
33
|
+
end
|
|
96
34
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
@method_def.block_argument.name.should == 'block'
|
|
104
|
-
end
|
|
35
|
+
should 'call the method by name' do
|
|
36
|
+
container = ruby_object.new(
|
|
37
|
+
:name => 'String',
|
|
38
|
+
:type => :const,
|
|
39
|
+
:instance_type => :instance
|
|
40
|
+
)
|
|
105
41
|
|
|
106
|
-
|
|
107
|
-
@method_def.lookup(:local_variable, 'required') \
|
|
108
|
-
.is_a?(ruby_object) \
|
|
109
|
-
.should == true
|
|
42
|
+
container.add_definition(@method)
|
|
110
43
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.should == true
|
|
114
|
-
end
|
|
115
|
-
end
|
|
44
|
+
container.call_method('example').should == 10
|
|
45
|
+
end
|
|
116
46
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
47
|
+
should 'raise for calling an undefined method' do
|
|
48
|
+
container = ruby_object.new(
|
|
49
|
+
:name => 'String',
|
|
50
|
+
:type => :const,
|
|
51
|
+
:instance_type => :instance
|
|
52
|
+
)
|
|
120
53
|
|
|
121
|
-
|
|
54
|
+
error = should.raise?(NoMethodError) do
|
|
55
|
+
container.call_method('derp')
|
|
56
|
+
end
|
|
122
57
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
param.value.should == '10'
|
|
58
|
+
error.message.should =~ /undefined method derp for/i
|
|
59
|
+
end
|
|
126
60
|
end
|
|
127
61
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
:method,
|
|
132
|
-
'example',
|
|
133
|
-
s(
|
|
134
|
-
:arguments,
|
|
135
|
-
s(
|
|
136
|
-
:argument,
|
|
137
|
-
s(:constant_path, s(:constant, 'First'), s(:constant, 'Second'))
|
|
138
|
-
)
|
|
139
|
-
),
|
|
140
|
-
nil,
|
|
141
|
-
nil
|
|
142
|
-
)
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
param = method.arguments[0]
|
|
62
|
+
describe 'defining arguments' do
|
|
63
|
+
should 'define an argument' do
|
|
64
|
+
@method.define_argument('number')
|
|
146
65
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
66
|
+
@method.lookup(:arg, 'number').is_a?(ruby_object).should == true
|
|
67
|
+
@method.lookup(:lvar, 'number').is_a?(ruby_object).should == true
|
|
68
|
+
end
|
|
150
69
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
param.receiver.name.should == 'First'
|
|
154
|
-
end
|
|
155
|
-
end
|
|
70
|
+
should 'define an optional argument' do
|
|
71
|
+
@method.define_optional_argument('number')
|
|
156
72
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
:name => 'Example'
|
|
161
|
-
)
|
|
73
|
+
@method.lookup(:optarg, 'number').is_a?(ruby_object).should == true
|
|
74
|
+
@method.lookup(:lvar, 'number').is_a?(ruby_object).should == true
|
|
75
|
+
end
|
|
162
76
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
:receiver => klass.lookup(:keyword, 'self')
|
|
166
|
-
)
|
|
77
|
+
should 'define a rest argument' do
|
|
78
|
+
@method.define_rest_argument('number')
|
|
167
79
|
|
|
168
|
-
|
|
80
|
+
@method.lookup(:restarg, 'number').is_a?(ruby_object).should == true
|
|
81
|
+
@method.lookup(:lvar, 'number').is_a?(ruby_object).should == true
|
|
82
|
+
end
|
|
169
83
|
|
|
170
|
-
|
|
84
|
+
should 'define a block argument' do
|
|
85
|
+
@method.define_block_argument('number')
|
|
171
86
|
|
|
172
|
-
|
|
173
|
-
|
|
87
|
+
@method.lookup(:blockarg, 'number').is_a?(ruby_object).should == true
|
|
88
|
+
@method.lookup(:lvar, 'number').is_a?(ruby_object).should == true
|
|
89
|
+
end
|
|
90
|
+
end
|
|
174
91
|
end
|
|
175
92
|
end
|