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,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::NestedStack do
|
4
4
|
before do
|
5
5
|
@stack = RubyLint::NestedStack.new
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
example 'add a new stack' do
|
9
9
|
@stack.empty?.should == true
|
10
10
|
|
11
11
|
@stack.add_stack
|
@@ -13,11 +13,11 @@ describe RubyLint::NestedStack do
|
|
13
13
|
@stack.empty?.should == false
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
example 'push and pop values from the stack' do
|
17
17
|
@stack.add_stack
|
18
18
|
@stack.push(10)
|
19
19
|
|
20
20
|
@stack.pop.should == [10]
|
21
21
|
@stack.empty?.should == true
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Parser do
|
4
|
+
example 'parse a block of Ruby code' do
|
5
|
+
ast = parse('10', false)
|
6
|
+
|
7
|
+
ast.type.should == :root
|
8
|
+
ast.children.length.should == 1
|
9
|
+
end
|
10
|
+
|
11
|
+
example 'use a custom node class' do
|
12
|
+
parse('10').class.should == RubyLint::AST::Node
|
13
|
+
end
|
14
|
+
|
15
|
+
example 'parse and return the comments mapping' do
|
16
|
+
code = <<-CODE
|
17
|
+
# Hello world
|
18
|
+
def foobar
|
19
|
+
end
|
20
|
+
CODE
|
21
|
+
|
22
|
+
ast, comments = parse_with_comments(code)
|
23
|
+
def_node = ast.children[0]
|
24
|
+
comment = comments[def_node][0]
|
25
|
+
|
26
|
+
comment.is_a?(Parser::Source::Comment).should == true
|
27
|
+
|
28
|
+
comment.text.should == '# Hello world'
|
29
|
+
comment.location.line.should == 1
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe RubyLint::Presenter::JSON do
|
5
|
+
example 'format a set of entries' do
|
6
|
+
report = RubyLint::Report.new
|
7
|
+
presenter = RubyLint::Presenter::JSON.new
|
8
|
+
|
9
|
+
report.add(
|
10
|
+
:level => :error,
|
11
|
+
:message => 'error message',
|
12
|
+
:line => 1,
|
13
|
+
:column => 1,
|
14
|
+
:file => 'a.rb'
|
15
|
+
)
|
16
|
+
|
17
|
+
report.add(
|
18
|
+
:level => :error,
|
19
|
+
:message => 'error message 2',
|
20
|
+
:line => 2,
|
21
|
+
:column => 1,
|
22
|
+
:file => 'a.rb'
|
23
|
+
)
|
24
|
+
|
25
|
+
report.add(
|
26
|
+
:level => :warning,
|
27
|
+
:message => 'warning message',
|
28
|
+
:line => 1,
|
29
|
+
:column => 1,
|
30
|
+
:file => 'b.rb'
|
31
|
+
)
|
32
|
+
|
33
|
+
report.add(
|
34
|
+
:level => :info,
|
35
|
+
:message => 'info message',
|
36
|
+
:line => 1,
|
37
|
+
:column => 1,
|
38
|
+
:file => 'c.rb'
|
39
|
+
)
|
40
|
+
|
41
|
+
output = presenter.present(report)
|
42
|
+
decoded = JSON(output)
|
43
|
+
|
44
|
+
decoded.length.should == 4
|
45
|
+
|
46
|
+
decoded[0]['file'].should == 'a.rb'
|
47
|
+
decoded[0]['level'].should == 'error'
|
48
|
+
|
49
|
+
decoded[1]['file'].should == 'a.rb'
|
50
|
+
decoded[1]['level'].should == 'error'
|
51
|
+
|
52
|
+
decoded[2]['file'].should == 'b.rb'
|
53
|
+
decoded[2]['level'].should == 'warning'
|
54
|
+
|
55
|
+
decoded[3]['file'].should == 'c.rb'
|
56
|
+
decoded[3]['level'].should == 'info'
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Presenter::Text do
|
4
|
+
example 'format a set of entries' do
|
5
|
+
report = RubyLint::Report.new
|
6
|
+
presenter = RubyLint::Presenter::Text.new
|
7
|
+
|
8
|
+
report.add(
|
9
|
+
:level => :error,
|
10
|
+
:message => 'error message',
|
11
|
+
:line => 1,
|
12
|
+
:column => 1,
|
13
|
+
:file => '/foo/a.rb'
|
14
|
+
)
|
15
|
+
|
16
|
+
report.add(
|
17
|
+
:level => :error,
|
18
|
+
:message => 'error message 2',
|
19
|
+
:line => 2,
|
20
|
+
:column => 1,
|
21
|
+
:file => '/foo/a.rb'
|
22
|
+
)
|
23
|
+
|
24
|
+
report.add(
|
25
|
+
:level => :warning,
|
26
|
+
:message => 'warning message',
|
27
|
+
:line => 1,
|
28
|
+
:column => 1,
|
29
|
+
:file => '/foo/b.rb'
|
30
|
+
)
|
31
|
+
|
32
|
+
report.add(
|
33
|
+
:level => :info,
|
34
|
+
:message => 'info message',
|
35
|
+
:line => 1,
|
36
|
+
:column => 1,
|
37
|
+
:file => '/foo/c.rb'
|
38
|
+
)
|
39
|
+
|
40
|
+
output = presenter.present(report)
|
41
|
+
|
42
|
+
output.should == <<-EOF.strip
|
43
|
+
a.rb: error: line 1, column 1: error message
|
44
|
+
a.rb: error: line 2, column 1: error message 2
|
45
|
+
b.rb: warning: line 1, column 1: warning message
|
46
|
+
c.rb: info: line 1, column 1: info message
|
47
|
+
EOF
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Report::Entry do
|
4
|
+
example 'sort a list of entries' do
|
5
|
+
entries = [
|
6
|
+
RubyLint::Report::Entry.new(
|
7
|
+
:level => :info,
|
8
|
+
:message => 'info',
|
9
|
+
:line => 2,
|
10
|
+
:column => 1,
|
11
|
+
:file => 'a.rb'
|
12
|
+
),
|
13
|
+
RubyLint::Report::Entry.new(
|
14
|
+
:level => :error,
|
15
|
+
:message => 'error',
|
16
|
+
:line => 1,
|
17
|
+
:column => 1,
|
18
|
+
:file => 'a.rb'
|
19
|
+
),
|
20
|
+
RubyLint::Report::Entry.new(
|
21
|
+
:level => :warning,
|
22
|
+
:message => 'warning',
|
23
|
+
:line => 3,
|
24
|
+
:column => 1,
|
25
|
+
:file => 'a.rb'
|
26
|
+
),
|
27
|
+
RubyLint::Report::Entry.new(
|
28
|
+
:level => :warning,
|
29
|
+
:message => 'warning',
|
30
|
+
:line => 1,
|
31
|
+
:column => 1,
|
32
|
+
:file => 'b.rb'
|
33
|
+
),
|
34
|
+
RubyLint::Report::Entry.new(
|
35
|
+
:level => :error,
|
36
|
+
:message => 'error',
|
37
|
+
:line => 1,
|
38
|
+
:column => 1,
|
39
|
+
:file => 'c.rb'
|
40
|
+
),
|
41
|
+
].sort
|
42
|
+
|
43
|
+
entries[0].file.should == 'a.rb'
|
44
|
+
entries[0].level.should == :error
|
45
|
+
|
46
|
+
entries[1].file.should == 'a.rb'
|
47
|
+
entries[1].level.should == :info
|
48
|
+
|
49
|
+
entries[2].file.should == 'a.rb'
|
50
|
+
entries[2].level.should == :warning
|
51
|
+
|
52
|
+
entries[3].file.should == 'b.rb'
|
53
|
+
entries[3].level.should == :warning
|
54
|
+
|
55
|
+
entries[4].file.should == 'c.rb'
|
56
|
+
entries[4].level.should == :error
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'RubyLint::Report' do
|
4
|
+
example 'add a message using #add' do
|
5
|
+
report = RubyLint::Report.new
|
6
|
+
|
7
|
+
report.add(
|
8
|
+
:level => :info,
|
9
|
+
:message => 'info message',
|
10
|
+
:line => 1,
|
11
|
+
:column => 1,
|
12
|
+
:file => 'file.rb'
|
13
|
+
)
|
14
|
+
|
15
|
+
report.entries.length.should == 1
|
16
|
+
|
17
|
+
entry = report.entries[0]
|
18
|
+
|
19
|
+
entry.level.should == :info
|
20
|
+
entry.message.should == 'info message'
|
21
|
+
entry.line.should == 1
|
22
|
+
entry.column.should == 1
|
23
|
+
entry.file.should == 'file.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
example 'ignore invalid reporting levels' do
|
27
|
+
report = RubyLint::Report.new
|
28
|
+
|
29
|
+
report.add(
|
30
|
+
:level => :test,
|
31
|
+
:message => 'invalid message',
|
32
|
+
:line => 1,
|
33
|
+
:column => 1,
|
34
|
+
:file => 'file.rb'
|
35
|
+
)
|
36
|
+
|
37
|
+
report.entries.empty?.should == true
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::Runner do
|
4
|
+
before do
|
5
|
+
@configuration = RubyLint::Configuration.new
|
6
|
+
end
|
7
|
+
|
8
|
+
example 'run analysis on a single file' do
|
9
|
+
files = [fixture_path('invalid.rb')]
|
10
|
+
runner = RubyLint::Runner.new(@configuration)
|
11
|
+
output = runner.analyze(files)
|
12
|
+
|
13
|
+
output.should =~ /undefined method foobar on an instance of String/
|
14
|
+
end
|
15
|
+
|
16
|
+
example 'run analysis on multiple files' do
|
17
|
+
files = [fixture_path('invalid.rb'), fixture_path('invalid_2.rb')]
|
18
|
+
runner = RubyLint::Runner.new(@configuration)
|
19
|
+
output = runner.analyze(files)
|
20
|
+
|
21
|
+
output.should =~ /undefined method foobar on an instance of String/
|
22
|
+
output.should =~ /undefined method derp on an instance of String/
|
23
|
+
end
|
24
|
+
|
25
|
+
example 'add syntax errors to the report' do
|
26
|
+
files = [fixture_path('syntax_error.rb')]
|
27
|
+
runner = RubyLint::Runner.new(@configuration)
|
28
|
+
output = runner.analyze(files)
|
29
|
+
|
30
|
+
output.should =~ /unexpected token \$end/
|
31
|
+
end
|
32
|
+
|
33
|
+
example 'add errors when using externally defined constants' do
|
34
|
+
files = [fixture_path('uses_external_invalid.rb')]
|
35
|
+
dirs = [fixture_path('file_scanner/rails')]
|
36
|
+
config = RubyLint::Configuration.new(:directories => dirs)
|
37
|
+
runner = RubyLint::Runner.new(config)
|
38
|
+
output = runner.analyze(files)
|
39
|
+
|
40
|
+
output.should =~ /undefined method foobar on an instance of User/
|
41
|
+
end
|
42
|
+
|
43
|
+
example 'associating nodes with external definitions' do
|
44
|
+
files = [fixture_path('associating.rb')]
|
45
|
+
dirs = [fixture_path('../../lib')]
|
46
|
+
config = RubyLint::Configuration.new(:directories => dirs)
|
47
|
+
runner = RubyLint::Runner.new(config)
|
48
|
+
output = runner.analyze(files)
|
49
|
+
|
50
|
+
output.empty?.should == true
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyLint::VirtualMachine do
|
4
|
+
describe 'alias' do
|
5
|
+
example 'alias methods' do
|
6
|
+
code = <<-CODE
|
7
|
+
def bar
|
8
|
+
end
|
9
|
+
|
10
|
+
alias foo bar
|
11
|
+
CODE
|
12
|
+
|
13
|
+
defs = build_definitions(code)
|
14
|
+
|
15
|
+
defs.lookup(:instance_method, 'bar').is_a?(ruby_method).should == true
|
16
|
+
defs.lookup(:instance_method, 'foo').is_a?(ruby_method).should == true
|
17
|
+
end
|
18
|
+
|
19
|
+
example 'alias methods using symbols' do
|
20
|
+
code = <<-CODE
|
21
|
+
def bar
|
22
|
+
end
|
23
|
+
|
24
|
+
alias :foo :bar
|
25
|
+
CODE
|
26
|
+
|
27
|
+
defs = build_definitions(code)
|
28
|
+
|
29
|
+
defs.lookup(:instance_method, 'bar').is_a?(ruby_method).should == true
|
30
|
+
defs.lookup(:instance_method, 'foo').is_a?(ruby_method).should == true
|
31
|
+
end
|
32
|
+
|
33
|
+
example 'alias methods using alias_method' do
|
34
|
+
code = <<-CODE
|
35
|
+
def bar
|
36
|
+
end
|
37
|
+
|
38
|
+
alias_method :foo, :bar
|
39
|
+
CODE
|
40
|
+
|
41
|
+
defs = build_definitions(code)
|
42
|
+
|
43
|
+
defs.lookup(:instance_method, 'bar').is_a?(ruby_method).should == true
|
44
|
+
defs.lookup(:instance_method, 'foo').is_a?(ruby_method).should == true
|
45
|
+
end
|
46
|
+
|
47
|
+
example 'alias global variables' do
|
48
|
+
code = 'alias $ARGV $*'
|
49
|
+
defs = build_definitions(code)
|
50
|
+
|
51
|
+
defs.lookup(:gvar, '$*').is_a?(ruby_object).should == true
|
52
|
+
defs.lookup(:gvar, '$ARGV').is_a?(ruby_object).should == true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::VirtualMachine do
|
4
4
|
describe 'array assignments' do
|
5
|
-
|
5
|
+
example 'assign an empty array' do
|
6
6
|
defs = build_definitions('numbers = []')
|
7
7
|
value = defs.lookup(:lvar, 'numbers').value
|
8
8
|
|
@@ -12,7 +12,7 @@ describe RubyLint::VirtualMachine do
|
|
12
12
|
value.has_definition?(:instance_method, 'each').should == true
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
example 'assign an array with values' do
|
16
16
|
defs = build_definitions('numbers = [10, 20]')
|
17
17
|
array = defs.lookup(:lvar, 'numbers').value
|
18
18
|
members = [10, 20]
|
@@ -27,7 +27,7 @@ describe RubyLint::VirtualMachine do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
example 'process single index assignments' do
|
31
31
|
code = <<-CODE
|
32
32
|
numbers = []
|
33
33
|
numbers[0] = 10
|
@@ -50,7 +50,7 @@ describe RubyLint::VirtualMachine do
|
|
50
50
|
first.value.value.should == 10
|
51
51
|
end
|
52
52
|
|
53
|
-
|
53
|
+
example 'process multiple index assignments' do
|
54
54
|
code = <<-CODE
|
55
55
|
numbers = []
|
56
56
|
numbers[0,1] = 10
|
@@ -70,7 +70,7 @@ numbers[4,5,6] = 40, 50
|
|
70
70
|
numbers.lookup(:member, '6').value.should == nil
|
71
71
|
end
|
72
72
|
|
73
|
-
|
73
|
+
example 'process index assignments using variables' do
|
74
74
|
code = <<-CODE
|
75
75
|
index = 1
|
76
76
|
numbers = [10]
|
@@ -84,4 +84,4 @@ numbers[index] = 20
|
|
84
84
|
numbers.lookup(:member, '1').value.value.should == 20
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
87
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyLint::VirtualMachine do
|
4
4
|
describe 'hash assignments' do
|
5
|
-
|
5
|
+
example 'assign an empty hash' do
|
6
6
|
defs = build_definitions('numbers = {}')
|
7
7
|
value = defs.lookup(:lvar, 'numbers').value
|
8
8
|
|
@@ -12,7 +12,7 @@ describe RubyLint::VirtualMachine do
|
|
12
12
|
value.has_definition?(:instance_method, 'each').should == true
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
example 'assign a hash with values' do
|
16
16
|
defs = build_definitions('numbers = {:one => 1, :two => 2}')
|
17
17
|
hash = defs.lookup(:lvar, 'numbers').value
|
18
18
|
members = {'one' => 1, 'two' => 2}
|
@@ -26,7 +26,7 @@ describe RubyLint::VirtualMachine do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
example 'process single key assignments' do
|
30
30
|
defs = build_definitions('numbers = {}; numbers[:one] = 1')
|
31
31
|
hash = defs.lookup(:lvar, 'numbers').value
|
32
32
|
member = hash.lookup(:member, 'one')
|
@@ -35,7 +35,7 @@ describe RubyLint::VirtualMachine do
|
|
35
35
|
member.value.value.should == 1
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
example 'process key assignments using variables' do
|
39
39
|
code = <<-CODE
|
40
40
|
key = :two
|
41
41
|
numbers = {:one => 1}
|
@@ -49,4 +49,4 @@ numbers[key] = 2
|
|
49
49
|
hash.lookup(:member, 'two').value.value.should == 2
|
50
50
|
end
|
51
51
|
end
|
52
|
-
end
|
52
|
+
end
|