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,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::DefinitionBuilder::RubyMethod do
|
4
4
|
describe 'defining a method without a receiver' do
|
@@ -8,19 +8,19 @@ describe RubyLint::DefinitionBuilder::RubyMethod do
|
|
8
8
|
@builder = RubyLint::DefinitionBuilder::RubyMethod.new(node, @root)
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
example 'return the name of the method' do
|
12
12
|
@builder.build.name.should == 'example'
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
example 'return the type of the method' do
|
16
16
|
@builder.build.type.should == :instance_method
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
example 'return the parent definitions' do
|
20
20
|
@builder.build.parents.should == [@root]
|
21
21
|
end
|
22
22
|
|
23
|
-
|
23
|
+
example 'return the scope to define the method in' do
|
24
24
|
@builder.scope.should == @root
|
25
25
|
end
|
26
26
|
end
|
@@ -38,16 +38,16 @@ describe RubyLint::DefinitionBuilder::RubyMethod do
|
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
example 'return the name of the method' do
|
42
42
|
@builder.build.name.should == 'example'
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
example 'return the parent definitions' do
|
46
46
|
@builder.build.parents.should == [@root.lookup(:const, 'A')]
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
example 'return the scope to define the method in' do
|
50
50
|
@builder.scope.should == @root.lookup(:const, 'A')
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::DefinitionBuilder::RubyModule do
|
4
4
|
describe 'building a simple module' do
|
@@ -6,21 +6,22 @@ describe RubyLint::DefinitionBuilder::RubyModule do
|
|
6
6
|
node = s(:module, s(:const, nil, :A), s(:nil))
|
7
7
|
@root = ruby_object.new(:name => 'root')
|
8
8
|
@builder = RubyLint::DefinitionBuilder::RubyModule.new(node, @root)
|
9
|
+
@module = RubyLint::GlobalScope.global_constant('Module')
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
+
example 'return the name of the module' do
|
12
13
|
@builder.build.name.should == 'A'
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
@builder.build.parents.should == [@root]
|
16
|
+
example 'return the parent definitions' do
|
17
|
+
@builder.build.parents.should == [@module, @root]
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
example 'return the reference amount' do
|
20
21
|
@builder.build.reference_amount.should == 1
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
example 'return the scope to define the module in' do
|
24
25
|
@builder.scope.should == @root
|
25
26
|
end
|
26
27
|
end
|
@@ -33,17 +34,18 @@ describe RubyLint::DefinitionBuilder::RubyModule do
|
|
33
34
|
@root.define_constant('A')
|
34
35
|
|
35
36
|
@builder = RubyLint::DefinitionBuilder::RubyModule.new(node, @root)
|
37
|
+
@module = RubyLint::GlobalScope.global_constant('Module')
|
36
38
|
end
|
37
39
|
|
38
|
-
|
40
|
+
example 'return the name of the module' do
|
39
41
|
@builder.build.name.should == 'B'
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
|
-
@builder.build.parents.should == [@root]
|
44
|
+
example 'return the parent definitions' do
|
45
|
+
@builder.build.parents.should == [@module, @root]
|
44
46
|
end
|
45
47
|
|
46
|
-
|
48
|
+
example 'return the scope to define the module in' do
|
47
49
|
@builder.scope.should == @root.lookup(:const, 'A')
|
48
50
|
end
|
49
51
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Docstring::Mapping do
|
4
|
+
let(:param_tag) { RubyLint::Docstring::ParamTag }
|
5
|
+
let(:return_tag) { RubyLint::Docstring::ReturnTag }
|
6
|
+
|
7
|
+
let(:tags) do
|
8
|
+
[
|
9
|
+
param_tag.new(:name => 'number', :types => ['Numeric']),
|
10
|
+
param_tag.new(:name => 'number2', :types => ['Integer']),
|
11
|
+
return_tag.new(:types => ['Numeric'])
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
example 'map parameter tags by their names' do
|
16
|
+
mapping = RubyLint::Docstring::Mapping.new(tags)
|
17
|
+
|
18
|
+
mapping.param_tags['number'].types.should == ['Numeric']
|
19
|
+
mapping.param_tags['number2'].types.should == ['Integer']
|
20
|
+
end
|
21
|
+
|
22
|
+
example 'map a return tag' do
|
23
|
+
mapping = RubyLint::Docstring::Mapping.new(tags)
|
24
|
+
|
25
|
+
mapping.return_tag.types.should == ['Numeric']
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Docstring::Parser do
|
4
|
+
let(:parser) { RubyLint::Docstring::Parser.new }
|
5
|
+
|
6
|
+
context '@param tags' do
|
7
|
+
example 'parse a tag with just the parameter name' do
|
8
|
+
comments = ['# @param number']
|
9
|
+
tag = parser.parse(comments)[0]
|
10
|
+
|
11
|
+
tag.is_a?(RubyLint::Docstring::ParamTag).should == true
|
12
|
+
|
13
|
+
tag.name.should == 'number'
|
14
|
+
end
|
15
|
+
|
16
|
+
example 'parse a tag with a parameter name and description' do
|
17
|
+
comments = ['# @param number The number.']
|
18
|
+
tag = parser.parse(comments)[0]
|
19
|
+
|
20
|
+
tag.name.should == 'number'
|
21
|
+
tag.description.should == 'The number.'
|
22
|
+
end
|
23
|
+
|
24
|
+
example 'parse a tag with a type' do
|
25
|
+
comments = ['# @param [Numeric] number']
|
26
|
+
tag = parser.parse(comments)[0]
|
27
|
+
|
28
|
+
tag.name.should == 'number'
|
29
|
+
tag.types.should == ['Numeric']
|
30
|
+
end
|
31
|
+
|
32
|
+
example 'parse a tag with a type and description' do
|
33
|
+
comments = ['# @param [Numeric] number The number.']
|
34
|
+
tag = parser.parse(comments)[0]
|
35
|
+
|
36
|
+
tag.name.should == 'number'
|
37
|
+
tag.types.should == ['Numeric']
|
38
|
+
tag.description.should == 'The number.'
|
39
|
+
end
|
40
|
+
|
41
|
+
example 'parse a tag with a compound type' do
|
42
|
+
comments = ['# @param [Array<String>] names The names']
|
43
|
+
tag = parser.parse(comments)[0]
|
44
|
+
|
45
|
+
tag.name.should == 'names'
|
46
|
+
tag.description.should == 'The names'
|
47
|
+
tag.types.should == ['Array']
|
48
|
+
end
|
49
|
+
|
50
|
+
example 'should parse a tag with a namespace in it' do
|
51
|
+
comments = ['# @param [Foo::Bar] baz']
|
52
|
+
tag = parser.parse(comments)[0]
|
53
|
+
|
54
|
+
tag.name.should == 'baz'
|
55
|
+
tag.types.should == ['Foo::Bar']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context '@return tags' do
|
60
|
+
example 'parse a tag with just the type' do
|
61
|
+
comments = ['# @return [Numeric]']
|
62
|
+
tag = parser.parse(comments)[0]
|
63
|
+
|
64
|
+
tag.is_a?(RubyLint::Docstring::ReturnTag).should == true
|
65
|
+
|
66
|
+
tag.description.nil?.should == true
|
67
|
+
tag.types.should == ['Numeric']
|
68
|
+
end
|
69
|
+
|
70
|
+
example 'parse a tag with the type and description' do
|
71
|
+
comments = ['# @return [Numeric] The number.']
|
72
|
+
tag = parser.parse(comments)[0]
|
73
|
+
|
74
|
+
tag.is_a?(RubyLint::Docstring::ReturnTag).should == true
|
75
|
+
|
76
|
+
tag.types.should == ['Numeric']
|
77
|
+
tag.description.should == 'The number.'
|
78
|
+
end
|
79
|
+
|
80
|
+
example 'parse a tag with the description' do
|
81
|
+
comments = ['# @return Hello']
|
82
|
+
tag = parser.parse(comments)[0]
|
83
|
+
|
84
|
+
tag.types.should == []
|
85
|
+
tag.description.should == 'Hello'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'RubyLint String extensions' do
|
4
|
-
|
4
|
+
example 'snake_case a String' do
|
5
5
|
'HelloWorld::Foo::Bar'.snake_case.should == 'hello_world_foo_bar'
|
6
6
|
end
|
7
|
-
end
|
7
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::FileLoader do
|
4
|
+
before :all do
|
5
|
+
@rails_dir = fixture_path('file_scanner/rails')
|
6
|
+
@lib_dir = fixture_path('file_scanner/lib')
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'rails projects' do
|
10
|
+
example 'finding a class' do
|
11
|
+
loader = RubyLint::FileLoader.new(:directories => [@rails_dir])
|
12
|
+
ast = parse('User')
|
13
|
+
|
14
|
+
loader.iterate(ast)
|
15
|
+
|
16
|
+
loader.nodes.empty?.should == false
|
17
|
+
|
18
|
+
const = loader.nodes[1][0].children[0]
|
19
|
+
|
20
|
+
const.file
|
21
|
+
.should == fixture_path('file_scanner/rails/app/models/user.rb')
|
22
|
+
end
|
23
|
+
|
24
|
+
example 'finding a namespaced class' do
|
25
|
+
loader = RubyLint::FileLoader.new(:directories => [@rails_dir])
|
26
|
+
ast = parse('Example::User')
|
27
|
+
|
28
|
+
loader.iterate(ast)
|
29
|
+
|
30
|
+
loader.nodes.empty?.should == false
|
31
|
+
|
32
|
+
const = loader.nodes[1][0].children[0]
|
33
|
+
|
34
|
+
const.file
|
35
|
+
.should == fixture_path('file_scanner/rails/app/models/example/user.rb')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'regular Ruby projects' do
|
40
|
+
example 'finding a class' do
|
41
|
+
loader = RubyLint::FileLoader.new(:directories => [@lib_dir])
|
42
|
+
ast = parse('Example::User')
|
43
|
+
|
44
|
+
loader.iterate(ast)
|
45
|
+
|
46
|
+
loader.nodes.empty?.should == false
|
47
|
+
|
48
|
+
const = loader.nodes[0][0].children[0]
|
49
|
+
|
50
|
+
const.file.should == fixture_path('file_scanner/lib/example/user.rb')
|
51
|
+
end
|
52
|
+
|
53
|
+
example 'recursively find dependencies' do
|
54
|
+
loader = RubyLint::FileLoader.new(:directories => [@lib_dir])
|
55
|
+
ast = parse('Example::Recursive::Source')
|
56
|
+
|
57
|
+
loader.iterate(ast)
|
58
|
+
|
59
|
+
nodes = loader.nodes.map do |pair|
|
60
|
+
pair[0].children[0]
|
61
|
+
end
|
62
|
+
|
63
|
+
nodes.length.should == 2
|
64
|
+
|
65
|
+
File.basename(nodes[0].file).should == 'target.rb'
|
66
|
+
File.basename(nodes[1].file).should == 'source.rb'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::FileScanner do
|
4
|
+
before :all do
|
5
|
+
@rails_dir = fixture_path('file_scanner/rails')
|
6
|
+
@lib_dir = fixture_path('file_scanner/lib')
|
7
|
+
end
|
8
|
+
|
9
|
+
example 'raise when a non enumerable argument is given' do
|
10
|
+
lambda { RubyLint::FileScanner.new(10) }.should raise_error(TypeError)
|
11
|
+
end
|
12
|
+
|
13
|
+
example 'finding a class' do
|
14
|
+
scanner = RubyLint::FileScanner.new([@lib_dir])
|
15
|
+
paths = scanner.scan('Example::User')
|
16
|
+
|
17
|
+
paths.should == [fixture_path('file_scanner/lib/example/user.rb')]
|
18
|
+
end
|
19
|
+
|
20
|
+
example 'finding a class using dashes for the directory names' do
|
21
|
+
scanner = RubyLint::FileScanner.new([@lib_dir])
|
22
|
+
paths = scanner.scan('TestDashes::Foo')
|
23
|
+
|
24
|
+
paths.should == [fixture_path('file_scanner/lib/test-dashes/foo.rb')]
|
25
|
+
end
|
26
|
+
|
27
|
+
example 'finding a class using a Rails structure' do
|
28
|
+
scanner = RubyLint::FileScanner.new([@rails_dir])
|
29
|
+
paths = scanner.scan('User')
|
30
|
+
|
31
|
+
paths.should == [
|
32
|
+
fixture_path('file_scanner/rails/app/models/user.rb'),
|
33
|
+
fixture_path('file_scanner/rails/app/models/example/user.rb')
|
34
|
+
]
|
35
|
+
end
|
36
|
+
|
37
|
+
example 'finding a namespaced class using a Rails structure' do
|
38
|
+
scanner = RubyLint::FileScanner.new([@rails_dir])
|
39
|
+
paths = scanner.scan('Example::User')
|
40
|
+
|
41
|
+
paths.should == [
|
42
|
+
fixture_path('file_scanner/rails/app/models/example/user.rb')
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
example 'ignoring directories' do
|
47
|
+
scanner = RubyLint::FileScanner.new([@lib_dir], [@lib_dir])
|
48
|
+
|
49
|
+
scanner.scan('Example::User').empty?.should == true
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/ruby-lint/inspector'
|
3
|
+
|
4
|
+
describe RubyLint::Inspector do
|
5
|
+
let(:inspector) { RubyLint::Inspector.new(Encoding) }
|
6
|
+
|
7
|
+
example 'return a list of child constants' do
|
8
|
+
inspector.inspect_constants.include?('Encoding::BINARY').should == true
|
9
|
+
end
|
10
|
+
|
11
|
+
example 'ignore a given constant' do
|
12
|
+
ins = inspector
|
13
|
+
constants = ins.inspect_constants(ins.constant, ['Encoding::BINARY'])
|
14
|
+
|
15
|
+
constants.include?('Encoding::BINARY').should == false
|
16
|
+
end
|
17
|
+
|
18
|
+
example 'return the methods' do
|
19
|
+
names = inspector.inspect_methods.map(&:name)
|
20
|
+
|
21
|
+
names.include?(:find).should == true
|
22
|
+
end
|
23
|
+
|
24
|
+
example 'return the instance methods' do
|
25
|
+
names = inspector.inspect_instance_methods.map(&:name)
|
26
|
+
|
27
|
+
names.include?(:to_s).should == true
|
28
|
+
end
|
29
|
+
|
30
|
+
example 'ignore methods defined in Object' do
|
31
|
+
method = double(:fake_method, :name => :tainted?)
|
32
|
+
const = double(:fake_constant, :methods => [:tainted?], :method => method)
|
33
|
+
|
34
|
+
inspector = RubyLint::Inspector.new(const)
|
35
|
+
methods = inspector.inspect_methods.map(&:name)
|
36
|
+
|
37
|
+
methods.include?(:frozen?).should == false
|
38
|
+
methods.include?(:tainted?).should == true
|
39
|
+
end
|
40
|
+
|
41
|
+
example 'return the superclass' do
|
42
|
+
inspector.inspect_superclass.should == Object
|
43
|
+
end
|
44
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'RubyLint::Iterator' do
|
4
|
-
|
4
|
+
example 'call after_initialize if it is defined' do
|
5
5
|
iterator = Class.new(RubyLint::Iterator) do
|
6
6
|
attr_reader :number
|
7
7
|
|
@@ -13,7 +13,7 @@ describe 'RubyLint::Iterator' do
|
|
13
13
|
iterator.new.number.should == 10
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
example 'iterate over a simple AST' do
|
17
17
|
ast = parse('10; 20; 30', false)
|
18
18
|
|
19
19
|
iterator = Class.new(RubyLint::Iterator) do
|
@@ -59,7 +59,7 @@ describe 'RubyLint::Iterator' do
|
|
59
59
|
]
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
example 'iterate over a multi dimensional AST' do
|
63
63
|
code = <<-CODE
|
64
64
|
class Example
|
65
65
|
def some_method
|
@@ -98,4 +98,39 @@ end
|
|
98
98
|
iterator.options[:method].should == :some_method
|
99
99
|
iterator.options[:call].should == :puts
|
100
100
|
end
|
101
|
+
|
102
|
+
example 'skipping child nodes' do
|
103
|
+
code = <<-CODE
|
104
|
+
module A
|
105
|
+
class B
|
106
|
+
end
|
107
|
+
end
|
108
|
+
CODE
|
109
|
+
|
110
|
+
ast = parse(code, false)
|
111
|
+
iterator = Class.new(RubyLint::Iterator) do
|
112
|
+
attr_reader :options
|
113
|
+
|
114
|
+
def after_initialize
|
115
|
+
@options = {:module => false, :class => false}
|
116
|
+
end
|
117
|
+
|
118
|
+
def on_module(node)
|
119
|
+
options[:module] = true
|
120
|
+
|
121
|
+
skip_child_nodes!(node)
|
122
|
+
end
|
123
|
+
|
124
|
+
def on_class(node)
|
125
|
+
options[:class] = true
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
iterator = iterator.new
|
130
|
+
|
131
|
+
iterator.iterate(ast)
|
132
|
+
|
133
|
+
iterator.options[:module].should == true
|
134
|
+
iterator.options[:class].should == false
|
135
|
+
end
|
101
136
|
end
|