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,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::Analysis::UndefinedVariables do
|
4
|
-
|
4
|
+
example 'add an error for using an undefined instance variable' do
|
5
5
|
report = build_report('@number', RubyLint::Analysis::UndefinedVariables)
|
6
6
|
entry = report.entries[0]
|
7
7
|
|
@@ -12,7 +12,7 @@ describe RubyLint::Analysis::UndefinedVariables do
|
|
12
12
|
entry.message.should == 'undefined instance variable @number'
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
example 'add an error for using an undefined class variable' do
|
16
16
|
report = build_report('@@number', RubyLint::Analysis::UndefinedVariables)
|
17
17
|
entry = report.entries[0]
|
18
18
|
|
@@ -23,7 +23,7 @@ describe RubyLint::Analysis::UndefinedVariables do
|
|
23
23
|
entry.message.should == 'undefined class variable @@number'
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
example 'add an error for using an undefined global variable' do
|
27
27
|
report = build_report('$number', RubyLint::Analysis::UndefinedVariables)
|
28
28
|
entry = report.entries[0]
|
29
29
|
|
@@ -34,7 +34,7 @@ describe RubyLint::Analysis::UndefinedVariables do
|
|
34
34
|
entry.message.should == 'undefined global variable $number'
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
example 'add an error for using an undefined constant' do
|
38
38
|
report = build_report('NUMBER', RubyLint::Analysis::UndefinedVariables)
|
39
39
|
entry = report.entries[0]
|
40
40
|
|
@@ -45,7 +45,7 @@ describe RubyLint::Analysis::UndefinedVariables do
|
|
45
45
|
entry.message.should == 'undefined constant NUMBER'
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
example 'add an error for using an undefined constant path' do
|
49
49
|
code = <<-CODE
|
50
50
|
# This is to ensure that the on_const() callback isn't used to check for "B"
|
51
51
|
# in the global scope.
|
@@ -67,7 +67,7 @@ A::B
|
|
67
67
|
entry.message.should == 'undefined constant A::B'
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
example 'do not depend on the order of variable definitions' do
|
71
71
|
code = <<-CODE
|
72
72
|
class Person
|
73
73
|
def first
|
@@ -85,14 +85,14 @@ end
|
|
85
85
|
report.entries.empty?.should == true
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
example 'do not add errors when autoloading constants' do
|
89
89
|
code = 'Encoding::BIG5'
|
90
90
|
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
91
91
|
|
92
92
|
report.entries.empty?.should == true
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
example 'do not error when inheriting data in a block' do
|
96
96
|
code = <<-CODE
|
97
97
|
NUMBER = 10
|
98
98
|
|
@@ -106,10 +106,33 @@ CODE
|
|
106
106
|
report.entries.empty?.should == true
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
example 'do not add errors for variable references in string interpolation' do
|
110
110
|
code = 'number = 10; "#{number}"'
|
111
111
|
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
112
112
|
|
113
113
|
report.entries.empty?.should == true
|
114
114
|
end
|
115
|
+
|
116
|
+
example 'do not add errors for class names' do
|
117
|
+
code = <<-CODE
|
118
|
+
class Foo
|
119
|
+
end
|
120
|
+
|
121
|
+
module Namespace
|
122
|
+
class Bar
|
123
|
+
end
|
124
|
+
end
|
125
|
+
CODE
|
126
|
+
|
127
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
128
|
+
|
129
|
+
report.entries.empty?.should == true
|
130
|
+
end
|
131
|
+
|
132
|
+
example 'do not add errors when aliasing global variables' do
|
133
|
+
code = 'alias $ARGV $*'
|
134
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
135
|
+
|
136
|
+
report.entries.empty?.should == true
|
137
|
+
end
|
115
138
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::Analysis::UnusedVariables do
|
4
|
-
|
4
|
+
example 'warn for unused local variables' do
|
5
5
|
report = build_report('number = 1', RubyLint::Analysis::UnusedVariables)
|
6
6
|
entry = report.entries[0]
|
7
7
|
|
@@ -12,7 +12,16 @@ describe RubyLint::Analysis::UnusedVariables do
|
|
12
12
|
entry.message.should == 'unused local variable number'
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
example 'warn for unused instance variables' do
|
16
|
+
report = build_report('@number = 1', RubyLint::Analysis::UnusedVariables)
|
17
|
+
entry = report.entries[0]
|
18
|
+
|
19
|
+
entry.line.should == 1
|
20
|
+
entry.column.should == 0
|
21
|
+
entry.message.should == 'unused instance variable @number'
|
22
|
+
end
|
23
|
+
|
24
|
+
example 'do not warn for used variables' do
|
16
25
|
code = <<-CODE
|
17
26
|
number = 1
|
18
27
|
|
@@ -24,7 +33,7 @@ number
|
|
24
33
|
report.entries.empty?.should == true
|
25
34
|
end
|
26
35
|
|
27
|
-
|
36
|
+
example 'warn for unused constants' do
|
28
37
|
report = build_report('NUMBER = 10', RubyLint::Analysis::UnusedVariables)
|
29
38
|
entry = report.entries[0]
|
30
39
|
|
@@ -35,7 +44,7 @@ number
|
|
35
44
|
entry.message.should == 'unused constant NUMBER'
|
36
45
|
end
|
37
46
|
|
38
|
-
|
47
|
+
example 'do not warn for used constants' do
|
39
48
|
code = <<-CODE
|
40
49
|
A = 10
|
41
50
|
|
@@ -47,7 +56,7 @@ A
|
|
47
56
|
report.entries.empty?.should == true
|
48
57
|
end
|
49
58
|
|
50
|
-
|
59
|
+
example 'warn for unused constant paths' do
|
51
60
|
code = <<-CODE
|
52
61
|
module A
|
53
62
|
end
|
@@ -68,7 +77,7 @@ A::B = 10
|
|
68
77
|
entry.message.should == 'unused constant A::B'
|
69
78
|
end
|
70
79
|
|
71
|
-
|
80
|
+
example 'warn for unused variables in a method scope' do
|
72
81
|
code = <<-CODE
|
73
82
|
def some_method
|
74
83
|
number = 10
|
@@ -85,7 +94,7 @@ end
|
|
85
94
|
entry.message.should == 'unused local variable number'
|
86
95
|
end
|
87
96
|
|
88
|
-
|
97
|
+
example 'do not add a warning when assigning a variable to another variable' do
|
89
98
|
code = <<-CODE
|
90
99
|
first = 10
|
91
100
|
second = first
|
@@ -102,7 +111,7 @@ second = first
|
|
102
111
|
entry.message.should == 'unused local variable second'
|
103
112
|
end
|
104
113
|
|
105
|
-
|
114
|
+
example 'do not add warnings when defining classes and modules' do
|
106
115
|
code = <<-CODE
|
107
116
|
module A
|
108
117
|
end
|
@@ -115,4 +124,22 @@ end
|
|
115
124
|
|
116
125
|
report.entries.empty?.should == true
|
117
126
|
end
|
127
|
+
|
128
|
+
example 'ignore ivars if there is a corresponding method' do
|
129
|
+
code = <<-CODE
|
130
|
+
@number = 10
|
131
|
+
|
132
|
+
def number; end
|
133
|
+
CODE
|
134
|
+
|
135
|
+
report = build_report(code, RubyLint::Analysis::UnusedVariables)
|
136
|
+
|
137
|
+
report.entries.empty?.should == true
|
138
|
+
end
|
139
|
+
|
140
|
+
example 'ignore local variables that start with an underscore' do
|
141
|
+
report = build_report('_number = 10', RubyLint::Analysis::UnusedVariables)
|
142
|
+
|
143
|
+
report.entries.empty?.should == true
|
144
|
+
end
|
118
145
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::AST::Node do
|
4
|
-
|
4
|
+
example 'return the value for a scalar' do
|
5
5
|
s(:str, 'hello').children[0].should == 'hello'
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
example 'return the value for an Array' do
|
9
9
|
numbers = s(:array, s(:int, 10), s(:int, 20)).children
|
10
10
|
|
11
11
|
numbers.is_a?(Array).should == true
|
@@ -15,7 +15,7 @@ describe RubyLint::AST::Node do
|
|
15
15
|
numbers[1].children[0].should == 20
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
example 'return the value for a Hash' do
|
19
19
|
pairs = s(:hash, s(:pair, s(:str, 'number'), s(:int, 10))).children
|
20
20
|
|
21
21
|
pairs.is_a?(Array).should == true
|
@@ -23,11 +23,17 @@ describe RubyLint::AST::Node do
|
|
23
23
|
pairs[0].children[1].children[0].should == 10
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
example 'should try to guess the Ruby class of a node' do
|
27
27
|
s(:str, 'foo').ruby_class.should == 'String'
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
example 'check if a node is a constant path' do
|
31
31
|
s(:const, s(:const, nil, :A), :B).constant_path?.should == true
|
32
32
|
end
|
33
|
+
|
34
|
+
example 'inspect a node using #inspect_oneline' do
|
35
|
+
output = '(const (const nil :A) :B)'
|
36
|
+
|
37
|
+
s(:const, s(:const, nil, :A), :B).inspect_oneline.should == output
|
38
|
+
end
|
33
39
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require File.expand_path('../../../../lib/ruby-lint/cli', __FILE__)
|
3
3
|
|
4
4
|
describe RubyLint::CLI do
|
@@ -10,8 +10,8 @@ describe RubyLint::CLI do
|
|
10
10
|
@command.output_destination = @output
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
file =
|
13
|
+
example 'analyze a valid Ruby file' do
|
14
|
+
file = fixture_path('valid.rb')
|
15
15
|
|
16
16
|
@command.parse([file])
|
17
17
|
|
@@ -19,13 +19,24 @@ describe RubyLint::CLI do
|
|
19
19
|
@output.read.empty?.should == true
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
file =
|
22
|
+
example 'analyze an invalid Ruby file' do
|
23
|
+
file = fixture_path('invalid.rb')
|
24
24
|
|
25
25
|
@command.parse([file])
|
26
26
|
|
27
27
|
@output.rewind
|
28
28
|
@output.read.should =~ /undefined method foobar/
|
29
29
|
end
|
30
|
+
|
31
|
+
example 'include benchmarking output' do
|
32
|
+
@command.parse(['-b', fixture_path('valid.rb')])
|
33
|
+
|
34
|
+
@output.rewind
|
35
|
+
|
36
|
+
output = @output.read
|
37
|
+
|
38
|
+
output.should =~ /Execution time:/
|
39
|
+
output.should =~ /Memory usage:/
|
40
|
+
end
|
30
41
|
end
|
31
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require File.expand_path('../../../../lib/ruby-lint/cli', __FILE__)
|
3
3
|
|
4
4
|
describe RubyLint::CLI do
|
@@ -10,7 +10,7 @@ describe RubyLint::CLI do
|
|
10
10
|
@command.output_destination = @output
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
example 'show the AST of a Ruby file' do
|
14
14
|
file = File.expand_path('../../../fixtures/valid.rb', __FILE__)
|
15
15
|
output = RubyLint::Parser.new.parse(File.read(file)).inspect
|
16
16
|
|
@@ -20,4 +20,4 @@ describe RubyLint::CLI do
|
|
20
20
|
@output.read.strip.should == output
|
21
21
|
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Configuration do
|
4
|
+
context 'default options' do
|
5
|
+
before do
|
6
|
+
@configuration = RubyLint::Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
example 'set the default report levels' do
|
10
|
+
@configuration.report_levels.should == RubyLint::Report::DEFAULT_LEVELS
|
11
|
+
end
|
12
|
+
|
13
|
+
example 'set the default presenter' do
|
14
|
+
@configuration.default_presenter.should == RubyLint::Presenter::Text
|
15
|
+
end
|
16
|
+
|
17
|
+
example 'set the default analysis classes' do
|
18
|
+
@configuration.default_analysis_classes.empty?.should == false
|
19
|
+
end
|
20
|
+
|
21
|
+
example 'set the default debug mode' do
|
22
|
+
@configuration.debug.should == false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'empty and invalid arguments' do
|
27
|
+
before do
|
28
|
+
@configuration = RubyLint::Configuration.new
|
29
|
+
end
|
30
|
+
|
31
|
+
example 'set the report levels' do
|
32
|
+
@configuration.report_levels = []
|
33
|
+
|
34
|
+
@configuration.report_levels
|
35
|
+
.should == @configuration.default_report_levels
|
36
|
+
end
|
37
|
+
|
38
|
+
example 'set an invalid presenter' do
|
39
|
+
blk = lambda { @configuration.presenter = String }
|
40
|
+
|
41
|
+
blk.should raise_error(ArgumentError, /Invalid presenter/)
|
42
|
+
end
|
43
|
+
|
44
|
+
example 'set the analysis classes' do
|
45
|
+
@configuration.analysis_classes = []
|
46
|
+
|
47
|
+
@configuration.analysis_classes
|
48
|
+
.should == @configuration.default_analysis_classes
|
49
|
+
end
|
50
|
+
|
51
|
+
example 'set an invalid directory' do
|
52
|
+
blk = lambda do
|
53
|
+
@configuration.directories = ['idoubtthisdirectoryexists']
|
54
|
+
end
|
55
|
+
|
56
|
+
blk.should raise_error(ArgumentError, /does not exist/)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'setting options via the constructor' do
|
61
|
+
example 'set the report levels' do
|
62
|
+
conf = RubyLint::Configuration.new(:report_levels => ['info'])
|
63
|
+
|
64
|
+
conf.report_levels.should == [:info]
|
65
|
+
end
|
66
|
+
|
67
|
+
example 'set the presenter' do
|
68
|
+
conf = RubyLint::Configuration.new(:presenter => 'json')
|
69
|
+
|
70
|
+
conf.presenter.should == RubyLint::Presenter::JSON
|
71
|
+
end
|
72
|
+
|
73
|
+
example 'set the analysis classes' do
|
74
|
+
conf = RubyLint::Configuration.new(
|
75
|
+
:analysis_classes => ['undefined_methods']
|
76
|
+
)
|
77
|
+
|
78
|
+
conf.analysis_classes.should == [RubyLint::Analysis::UndefinedMethods]
|
79
|
+
end
|
80
|
+
|
81
|
+
example 'set the debug mode' do
|
82
|
+
conf = RubyLint::Configuration.new(:debug => true)
|
83
|
+
|
84
|
+
conf.debug.should == true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'setting options via a configuration file' do
|
89
|
+
example 'set the options from a YAML file' do
|
90
|
+
paths = [fixture_path('config.yml')]
|
91
|
+
conf = RubyLint::Configuration.load_from_file(paths)
|
92
|
+
|
93
|
+
conf.report_levels.should == [:info]
|
94
|
+
conf.analysis_classes.should == [RubyLint::Analysis::UndefinedMethods]
|
95
|
+
conf.presenter.should == RubyLint::Presenter::JSON
|
96
|
+
end
|
97
|
+
|
98
|
+
example 'return a default configuration file' do
|
99
|
+
conf = RubyLint::Configuration.load_from_file([])
|
100
|
+
|
101
|
+
conf.is_a?(RubyLint::Configuration).should == true
|
102
|
+
|
103
|
+
conf.report_levels.should == RubyLint::Report::DEFAULT_LEVELS
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
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
|
+
example 'create a new constant proxy' do
|
10
|
+
@proxy.proxy_source.should == @source
|
11
|
+
@proxy.proxy_name.should == 'Foo'
|
12
|
+
end
|
13
|
+
|
14
|
+
example 'act like a RubyObject definition' do
|
15
|
+
@proxy.lookup(:const, 'Bar').nil?.should == true
|
16
|
+
end
|
17
|
+
|
18
|
+
example '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
|
+
|
32
|
+
example 'autoload definitions from the global scope' do
|
33
|
+
proxy = RubyLint::Definition::ConstantProxy.new(
|
34
|
+
RubyLint::GlobalScope,
|
35
|
+
'ObjectSpace'
|
36
|
+
)
|
37
|
+
|
38
|
+
proxy.type.should == :const
|
39
|
+
proxy.name.should == 'ObjectSpace'
|
40
|
+
|
41
|
+
proxy.proxy_definition.is_a?(ruby_object).should == true
|
42
|
+
end
|
43
|
+
|
44
|
+
example 'delegating #inspect' do
|
45
|
+
proxy = RubyLint::Definition::ConstantProxy.new(
|
46
|
+
RubyLint::GlobalScope,
|
47
|
+
'ObjectSpace'
|
48
|
+
)
|
49
|
+
|
50
|
+
object_space = RubyLint::GlobalScope.global_constant('ObjectSpace')
|
51
|
+
|
52
|
+
proxy.inspect.should == object_space.inspect
|
53
|
+
end
|
54
|
+
end
|