ruby-lint 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.asc +14 -14
- data/.gitignore +1 -2
- data/.rubocop.yml +59 -0
- data/.travis.yml +3 -7
- data/.yardopts +2 -2
- data/Gemfile +4 -0
- data/MANIFEST +103 -67
- data/README.md +13 -31
- data/Rakefile +1 -6
- data/checksum/ruby-lint-0.0.3.gem.sha512 +1 -0
- data/debug/memory_usage.rb +14 -0
- data/debug/profile.rb +18 -0
- data/doc/architecture.md +14 -18
- data/doc/changelog.md +29 -0
- data/doc/code_analysis.md +12 -12
- data/doc/configuration.md +21 -50
- data/doc/graphviz/flow.dot +1 -1
- data/doc/images/flow.png +0 -0
- data/lib/ruby-lint.rb +33 -19
- data/lib/ruby-lint/analysis/argument_amount.rb +84 -0
- data/lib/ruby-lint/analysis/base.rb +132 -0
- data/lib/ruby-lint/analysis/confusing_variables.rb +26 -0
- data/lib/ruby-lint/analysis/pedantics.rb +36 -0
- data/lib/ruby-lint/analysis/shadowing_variables.rb +47 -0
- data/lib/ruby-lint/analysis/undefined_methods.rb +91 -0
- data/lib/ruby-lint/analysis/undefined_variables.rb +46 -0
- data/lib/ruby-lint/analysis/unused_variables.rb +49 -0
- data/lib/ruby-lint/ast/builder.rb +17 -0
- data/lib/ruby-lint/ast/node.rb +39 -0
- data/lib/ruby-lint/cli.rb +0 -19
- data/lib/ruby-lint/cli/analyze.rb +54 -28
- data/lib/ruby-lint/cli/ast.rb +21 -6
- data/lib/ruby-lint/cli/base.rb +0 -23
- data/lib/ruby-lint/configuration.rb +112 -42
- data/lib/ruby-lint/constant_loader.rb +10 -28
- data/lib/ruby-lint/default_names.rb +19 -0
- data/lib/ruby-lint/definition/constant_proxy.rb +56 -0
- data/lib/ruby-lint/definition/ruby_method.rb +21 -143
- data/lib/ruby-lint/definition/ruby_object.rb +142 -246
- data/lib/ruby-lint/definition_builder/base.rb +43 -0
- data/lib/ruby-lint/definition_builder/primitive.rb +39 -0
- data/lib/ruby-lint/definition_builder/ruby_array.rb +77 -0
- data/lib/ruby-lint/definition_builder/ruby_block.rb +34 -0
- data/lib/ruby-lint/definition_builder/ruby_class.rb +24 -0
- data/lib/ruby-lint/definition_builder/ruby_hash.rb +37 -0
- data/lib/ruby-lint/definition_builder/ruby_method.rb +84 -0
- data/lib/ruby-lint/definition_builder/ruby_module.rb +68 -0
- data/lib/ruby-lint/definition_generator.rb +41 -15
- data/lib/ruby-lint/definitions/core/arg0.rb +1 -1
- data/lib/ruby-lint/definitions/core/argf.rb +1 -1
- data/lib/ruby-lint/definitions/core/argument_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/argv.rb +1 -1
- data/lib/ruby-lint/definitions/core/array.rb +6 -6
- data/lib/ruby-lint/definitions/core/autoload.rb +2 -2
- data/lib/ruby-lint/definitions/core/basic_object.rb +3 -3
- data/lib/ruby-lint/definitions/core/bignum.rb +2 -2
- data/lib/ruby-lint/definitions/core/binding.rb +2 -2
- data/lib/ruby-lint/definitions/core/class.rb +2 -2
- data/lib/ruby-lint/definitions/core/comparable.rb +1 -1
- data/lib/ruby-lint/definitions/core/complex.rb +4 -4
- data/lib/ruby-lint/definitions/core/condition_variable.rb +2 -2
- data/lib/ruby-lint/definitions/core/continuation.rb +2 -2
- data/lib/ruby-lint/definitions/core/data.rb +2 -2
- data/lib/ruby-lint/definitions/core/date.rb +34 -34
- data/lib/ruby-lint/definitions/core/date_time.rb +26 -26
- data/lib/ruby-lint/definitions/core/default_record_separator.rb +1 -1
- data/lib/ruby-lint/definitions/core/digest.rb +14 -14
- data/lib/ruby-lint/definitions/core/dir.rb +34 -34
- data/lib/ruby-lint/definitions/core/encoding.rb +237 -237
- data/lib/ruby-lint/definitions/core/encoding_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/enumerable.rb +15 -15
- data/lib/ruby-lint/definitions/core/enumerator.rb +2 -2
- data/lib/ruby-lint/definitions/core/env.rb +1 -1
- data/lib/ruby-lint/definitions/core/eoferror.rb +2 -2
- data/lib/ruby-lint/definitions/core/erb.rb +22 -22
- data/lib/ruby-lint/definitions/core/errno.rb +525 -525
- data/lib/ruby-lint/definitions/core/etc.rb +6 -6
- data/lib/ruby-lint/definitions/core/exception.rb +2 -2
- data/lib/ruby-lint/definitions/core/false.rb +1 -1
- data/lib/ruby-lint/definitions/core/false_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/fatal_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/fiber.rb +2 -2
- data/lib/ruby-lint/definitions/core/fiber_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/file.rb +68 -68
- data/lib/ruby-lint/definitions/core/file_list.rb +2 -2
- data/lib/ruby-lint/definitions/core/file_test.rb +1 -1
- data/lib/ruby-lint/definitions/core/file_utils.rb +16 -16
- data/lib/ruby-lint/definitions/core/fixnum.rb +4 -4
- data/lib/ruby-lint/definitions/core/float.rb +16 -16
- data/lib/ruby-lint/definitions/core/float_domain_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/gc.rb +2 -2
- data/lib/ruby-lint/definitions/core/gem.rb +119 -119
- data/lib/ruby-lint/definitions/core/hash.rb +14 -14
- data/lib/ruby-lint/definitions/core/immediate_value.rb +1 -1
- data/lib/ruby-lint/definitions/core/index_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/integer.rb +2 -2
- data/lib/ruby-lint/definitions/core/interrupt.rb +2 -2
- data/lib/ruby-lint/definitions/core/io.rb +38 -38
- data/lib/ruby-lint/definitions/core/ioerror.rb +2 -2
- data/lib/ruby-lint/definitions/core/kernel.rb +3 -3
- data/lib/ruby-lint/definitions/core/key_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/load_error.rb +6 -6
- data/lib/ruby-lint/definitions/core/local_jump_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/main.rb +1 -1
- data/lib/ruby-lint/definitions/core/marshal.rb +35 -35
- data/lib/ruby-lint/definitions/core/match_data.rb +2 -2
- data/lib/ruby-lint/definitions/core/math.rb +7 -7
- data/lib/ruby-lint/definitions/core/memory_segmention_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/method.rb +2 -2
- data/lib/ruby-lint/definitions/core/module.rb +1 -1
- data/lib/ruby-lint/definitions/core/monitor.rb +4 -4
- data/lib/ruby-lint/definitions/core/monitor_mixin.rb +5 -5
- data/lib/ruby-lint/definitions/core/mutex.rb +2 -2
- data/lib/ruby-lint/definitions/core/name_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/nil.rb +1 -1
- data/lib/ruby-lint/definitions/core/nil_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/no_memory_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/no_method_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/not_implemented_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/numeric.rb +2 -2
- data/lib/ruby-lint/definitions/core/object.rb +2 -2
- data/lib/ruby-lint/definitions/core/object_space.rb +1 -1
- data/lib/ruby-lint/definitions/core/open_struct.rb +3 -3
- data/lib/ruby-lint/definitions/core/option_parser.rb +83 -83
- data/lib/ruby-lint/definitions/core/precision.rb +1 -1
- data/lib/ruby-lint/definitions/core/primitive_failure.rb +2 -2
- data/lib/ruby-lint/definitions/core/proc.rb +2 -2
- data/lib/ruby-lint/definitions/core/process.rb +29 -29
- data/lib/ruby-lint/definitions/core/psych.rb +149 -149
- data/lib/ruby-lint/definitions/core/queue.rb +2 -2
- data/lib/ruby-lint/definitions/core/rake.rb +117 -117
- data/lib/ruby-lint/definitions/core/rake_file_utils.rb +1 -1
- data/lib/ruby-lint/definitions/core/rakeversion.rb +1 -1
- data/lib/ruby-lint/definitions/core/random.rb +2 -2
- data/lib/ruby-lint/definitions/core/range.rb +4 -4
- data/lib/ruby-lint/definitions/core/range_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/rational.rb +2 -2
- data/lib/ruby-lint/definitions/core/rb_config.rb +3 -3
- data/lib/ruby-lint/definitions/core/regexp.rb +28 -28
- data/lib/ruby-lint/definitions/core/regexp_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/rubinius.rb +1057 -1057
- data/lib/ruby-lint/definitions/core/ruby_copyright.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_description.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_engine.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_lint.rb +9 -9
- data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_platform.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_release_date.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_version.rb +1 -1
- data/lib/ruby-lint/definitions/core/runtime_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/scan_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/script_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/security_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/shellwords.rb +1 -1
- data/lib/ruby-lint/definitions/core/signal.rb +3 -3
- data/lib/ruby-lint/definitions/core/signal_exception.rb +2 -2
- data/lib/ruby-lint/definitions/core/singleton.rb +2 -2
- data/lib/ruby-lint/definitions/core/sized_queue.rb +2 -2
- data/lib/ruby-lint/definitions/core/standard_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/stderr.rb +1 -1
- data/lib/ruby-lint/definitions/core/stdin.rb +1 -1
- data/lib/ruby-lint/definitions/core/stdout.rb +1 -1
- data/lib/ruby-lint/definitions/core/stop_iteration.rb +2 -2
- data/lib/ruby-lint/definitions/core/string.rb +21 -21
- data/lib/ruby-lint/definitions/core/string_io.rb +7 -7
- data/lib/ruby-lint/definitions/core/string_scanner.rb +4 -4
- data/lib/ruby-lint/definitions/core/struct.rb +20 -20
- data/lib/ruby-lint/definitions/core/syck.rb +4 -4
- data/lib/ruby-lint/definitions/core/symbol.rb +2 -2
- data/lib/ruby-lint/definitions/core/syntax_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_call_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_exit.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_stack_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/thread.rb +6 -6
- data/lib/ruby-lint/definitions/core/thread_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/thread_group.rb +2 -2
- data/lib/ruby-lint/definitions/core/time.rb +3 -3
- data/lib/ruby-lint/definitions/core/toplevel_binding.rb +1 -1
- data/lib/ruby-lint/definitions/core/true.rb +1 -1
- data/lib/ruby-lint/definitions/core/true_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/type_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/unbound_method.rb +2 -2
- data/lib/ruby-lint/definitions/core/unmarshalable.rb +1 -1
- data/lib/ruby-lint/definitions/core/unsupported_library_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/weak_ref.rb +4 -4
- data/lib/ruby-lint/definitions/core/zero_division_error.rb +2 -2
- data/lib/ruby-lint/definitions/rails.rb +12 -0
- data/lib/ruby-lint/definitions/rails/abstract_controller.rb +335 -0
- data/lib/ruby-lint/definitions/rails/action_controller.rb +1244 -0
- data/lib/ruby-lint/definitions/rails/action_dispatch.rb +741 -0
- data/lib/ruby-lint/definitions/rails/action_mailer.rb +502 -0
- data/lib/ruby-lint/definitions/rails/action_pack.rb +16 -0
- data/lib/ruby-lint/definitions/rails/action_view.rb +898 -0
- data/lib/ruby-lint/definitions/rails/active_model.rb +437 -0
- data/lib/ruby-lint/definitions/rails/active_record.rb +2901 -0
- data/lib/ruby-lint/definitions/rails/active_support.rb +1963 -0
- data/lib/ruby-lint/definitions/rails/arel.rb +665 -0
- data/lib/ruby-lint/definitions/rails/rails.rb +452 -0
- data/lib/ruby-lint/definitions/rails/sprockets.rb +968 -0
- data/lib/ruby-lint/generated_constant.rb +33 -0
- data/lib/ruby-lint/helper/constant_paths.rb +30 -21
- data/lib/ruby-lint/inspector.rb +20 -2
- data/lib/ruby-lint/iterator.rb +11 -171
- data/lib/ruby-lint/nested_stack.rb +46 -0
- data/lib/ruby-lint/parser.rb +24 -806
- data/lib/ruby-lint/report.rb +2 -30
- data/lib/ruby-lint/report/entry.rb +2 -2
- data/lib/ruby-lint/runner.rb +81 -0
- data/lib/ruby-lint/template/definition.erb +12 -8
- data/lib/ruby-lint/variable_predicates.rb +16 -58
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +1044 -0
- data/ruby-lint.gemspec +17 -7
- data/spec/fixtures/complex/rails/basic_controller.rb +9 -0
- data/spec/fixtures/complex/rcap.rb +38 -0
- data/spec/fixtures/complex/slop.rb +680 -0
- data/spec/fixtures/config.yml +8 -0
- data/spec/fixtures/invalid.rb +3 -0
- data/spec/fixtures/invalid_2.rb +3 -0
- data/spec/fixtures/syntax_error.rb +1 -0
- data/spec/fixtures/valid.rb +3 -0
- data/spec/helper.rb +6 -0
- data/spec/ruby-lint/{analyze → analysis}/argument_amount.rb +7 -7
- data/spec/ruby-lint/analysis/confusing_variables.rb +46 -0
- data/spec/ruby-lint/analysis/pedantics.rb +43 -0
- data/spec/ruby-lint/{analyze → analysis}/shadowing_variables.rb +5 -5
- data/spec/ruby-lint/{analyze → analysis}/undefined_methods.rb +18 -18
- data/spec/ruby-lint/{analyze → analysis}/undefined_variables.rb +19 -25
- data/spec/ruby-lint/{analyze → analysis}/unused_variables.rb +29 -16
- data/spec/ruby-lint/ast/node.rb +33 -0
- data/spec/ruby-lint/cli/analyze.rb +31 -0
- data/spec/ruby-lint/cli/ast.rb +23 -0
- data/spec/ruby-lint/configuration.rb +45 -6
- data/spec/ruby-lint/definition/constant_proxy.rb +31 -0
- data/spec/ruby-lint/definition/dsl.rb +13 -20
- data/spec/ruby-lint/definition/ruby_method.rb +65 -148
- data/spec/ruby-lint/definition/ruby_object.rb +60 -96
- data/spec/ruby-lint/definition_builder/primitive.rb +62 -0
- data/spec/ruby-lint/definition_builder/ruby_class.rb +108 -0
- data/spec/ruby-lint/definition_builder/ruby_method.rb +53 -0
- data/spec/ruby-lint/definition_builder/ruby_module.rb +50 -0
- data/spec/ruby-lint/iterator.rb +40 -16
- data/spec/ruby-lint/nested_stack.rb +23 -0
- data/spec/ruby-lint/parser.rb +14 -0
- data/spec/ruby-lint/report.rb +0 -10
- data/spec/ruby-lint/report/entry.rb +8 -4
- data/spec/ruby-lint/runner.rb +32 -0
- data/spec/ruby-lint/virtual_machine/assignments/arrays.rb +87 -0
- data/spec/ruby-lint/virtual_machine/assignments/hashes.rb +52 -0
- data/spec/ruby-lint/virtual_machine/assignments/optional.rb +41 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/assignments/return_values.rb +11 -11
- data/spec/ruby-lint/virtual_machine/assignments/variables.rb +85 -0
- data/spec/ruby-lint/virtual_machine/associate_nodes.rb +17 -0
- data/spec/ruby-lint/virtual_machine/autoloading.rb +31 -0
- data/spec/ruby-lint/virtual_machine/blocks.rb +64 -0
- data/spec/ruby-lint/virtual_machine/classes/class_methods.rb +21 -0
- data/spec/ruby-lint/virtual_machine/classes/extending.rb +104 -0
- data/spec/ruby-lint/virtual_machine/classes/redefining.rb +24 -0
- data/spec/ruby-lint/virtual_machine/classes/sclass.rb +94 -0
- data/spec/ruby-lint/virtual_machine/classes/scoping.rb +60 -0
- data/spec/ruby-lint/virtual_machine/complex/rails.rb +18 -0
- data/spec/ruby-lint/virtual_machine/complex/rcap.rb +15 -0
- data/spec/ruby-lint/virtual_machine/complex/slop.rb +16 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/for.rb +2 -2
- data/spec/ruby-lint/virtual_machine/freeze.rb +13 -0
- data/spec/ruby-lint/virtual_machine/interpolation.rb +12 -0
- data/spec/ruby-lint/virtual_machine/methods/defining.rb +40 -0
- data/spec/ruby-lint/virtual_machine/methods/exporting.rb +19 -0
- data/spec/ruby-lint/virtual_machine/methods/parameters.rb +77 -0
- data/spec/ruby-lint/virtual_machine/methods/patching.rb +26 -0
- data/spec/ruby-lint/virtual_machine/methods/scoping.rb +63 -0
- data/spec/ruby-lint/virtual_machine/methods/visibility.rb +64 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/modules.rb +16 -16
- data/spec/ruby-lint/virtual_machine/reference_amount.rb +33 -0
- data/spec/ruby-lint/virtual_machine/unused.rb +17 -0
- data/spec/support/bacon.rb +13 -13
- data/spec/support/building.rb +23 -16
- data/spec/support/coveralls.rb +5 -0
- data/spec/support/fixtures.rb +20 -0
- data/spec/support/parsing.rb +3 -5
- data/spec/support/simplecov.rb +5 -3
- data/task/build.rake +1 -1
- data/task/cop.rake +11 -0
- data/task/generate.rake +40 -2
- data/task/profile.rake +27 -0
- data/task/todo.rake +6 -0
- data/task/travis.rake +7 -0
- metadata +160 -75
- metadata.gz.asc +14 -14
- data/doc/build/.gitkeep +0 -0
- data/lib/ruby-lint/analyze/argument_amount.rb +0 -73
- data/lib/ruby-lint/analyze/shadowing_variables.rb +0 -32
- data/lib/ruby-lint/analyze/undefined_methods.rb +0 -68
- data/lib/ruby-lint/analyze/undefined_variables.rb +0 -72
- data/lib/ruby-lint/analyze/unused_variables.rb +0 -48
- data/lib/ruby-lint/base.rb +0 -85
- data/lib/ruby-lint/definitions_builder.rb +0 -692
- data/lib/ruby-lint/helper/conversion.rb +0 -33
- data/lib/ruby-lint/helper/current_scope.rb +0 -98
- data/lib/ruby-lint/helper/methods.rb +0 -91
- data/lib/ruby-lint/node.rb +0 -107
- data/lib/ruby-lint/parser_error.rb +0 -30
- data/spec/ruby-lint/constant_loader.rb +0 -32
- data/spec/ruby-lint/definition/method_calls.rb +0 -26
- data/spec/ruby-lint/definitions_builder/assignments/arrays.rb +0 -71
- data/spec/ruby-lint/definitions_builder/assignments/hashes.rb +0 -65
- data/spec/ruby-lint/definitions_builder/assignments/objects.rb +0 -23
- data/spec/ruby-lint/definitions_builder/assignments/optional.rb +0 -22
- data/spec/ruby-lint/definitions_builder/assignments/variables.rb +0 -71
- data/spec/ruby-lint/definitions_builder/associate_nodes.rb +0 -17
- data/spec/ruby-lint/definitions_builder/blocks.rb +0 -40
- data/spec/ruby-lint/definitions_builder/classes.rb +0 -230
- data/spec/ruby-lint/definitions_builder/methods.rb +0 -147
- data/spec/ruby-lint/definitions_builder/reference_amount.rb +0 -31
- data/spec/ruby-lint/definitions_builder/unused.rb +0 -15
- data/spec/ruby-lint/node.rb +0 -38
- data/spec/ruby-lint/parser/assignments.rb +0 -225
- data/spec/ruby-lint/parser/classes.rb +0 -110
- data/spec/ruby-lint/parser/errors.rb +0 -12
- data/spec/ruby-lint/parser/metadata.rb +0 -17
- data/spec/ruby-lint/parser/method_definitions.rb +0 -111
- data/spec/ruby-lint/parser/methods.rb +0 -217
- data/spec/ruby-lint/parser/modules.rb +0 -70
- data/spec/ruby-lint/parser/operators.rb +0 -40
- data/spec/ruby-lint/parser/statements/begin.rb +0 -55
- data/spec/ruby-lint/parser/statements/case.rb +0 -34
- data/spec/ruby-lint/parser/statements/defined.rb +0 -11
- data/spec/ruby-lint/parser/statements/for.rb +0 -34
- data/spec/ruby-lint/parser/statements/if.rb +0 -46
- data/spec/ruby-lint/parser/statements/return.rb +0 -14
- data/spec/ruby-lint/parser/statements/super.rb +0 -49
- data/spec/ruby-lint/parser/statements/unless.rb +0 -42
- data/spec/ruby-lint/parser/statements/until.rb +0 -25
- data/spec/ruby-lint/parser/statements/while.rb +0 -25
- data/spec/ruby-lint/parser/statements/yield.rb +0 -18
- data/spec/ruby-lint/parser/types/arrays.rb +0 -47
- data/spec/ruby-lint/parser/types/booleans.rb +0 -11
- data/spec/ruby-lint/parser/types/constants.rb +0 -32
- data/spec/ruby-lint/parser/types/hashes.rb +0 -55
- data/spec/ruby-lint/parser/types/nil.rb +0 -7
- data/spec/ruby-lint/parser/types/numbers.rb +0 -11
- data/spec/ruby-lint/parser/types/procs.rb +0 -11
- data/spec/ruby-lint/parser/types/ranges.rb +0 -11
- data/spec/ruby-lint/parser/types/regexp.rb +0 -27
- data/spec/ruby-lint/parser/types/strings.rb +0 -44
- data/spec/ruby-lint/parser/types/symbols.rb +0 -15
- data/task/stdlib.rake +0 -23
@@ -0,0 +1 @@
|
|
1
|
+
module Foo
|
data/spec/helper.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
require 'bacon'
|
2
2
|
require 'bacon/colored_output'
|
3
|
+
require 'stringio'
|
3
4
|
require_relative 'support/bacon'
|
4
5
|
|
5
6
|
if ENV['COVERAGE']
|
6
7
|
require_relative 'support/simplecov'
|
7
8
|
end
|
8
9
|
|
10
|
+
if ENV['COVERALLS']
|
11
|
+
require_relative 'support/coveralls'
|
12
|
+
end
|
13
|
+
|
9
14
|
require_relative '../lib/ruby-lint'
|
10
15
|
require_relative 'support/building'
|
11
16
|
require_relative 'support/parsing'
|
12
17
|
require_relative 'support/definitions'
|
18
|
+
require_relative 'support/fixtures'
|
13
19
|
|
14
20
|
Bacon.summary_on_exit
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe RubyLint::
|
3
|
+
describe RubyLint::Analysis::ArgumentAmount do
|
4
4
|
should 'validate the amount of required arguments' do
|
5
5
|
code = <<-CODE
|
6
6
|
def example(first, second)
|
@@ -9,7 +9,7 @@ end
|
|
9
9
|
example
|
10
10
|
CODE
|
11
11
|
|
12
|
-
report = build_report(code, RubyLint::
|
12
|
+
report = build_report(code, RubyLint::Analysis::ArgumentAmount)
|
13
13
|
entry = report.entries[0]
|
14
14
|
|
15
15
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -27,7 +27,7 @@ end
|
|
27
27
|
example
|
28
28
|
CODE
|
29
29
|
|
30
|
-
report = build_report(code, RubyLint::
|
30
|
+
report = build_report(code, RubyLint::Analysis::ArgumentAmount)
|
31
31
|
entry = report.entries[0]
|
32
32
|
|
33
33
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -46,7 +46,7 @@ end
|
|
46
46
|
example
|
47
47
|
CODE
|
48
48
|
|
49
|
-
report = build_report(code, RubyLint::
|
49
|
+
report = build_report(code, RubyLint::Analysis::ArgumentAmount)
|
50
50
|
entry = report.entries[0]
|
51
51
|
|
52
52
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -65,7 +65,7 @@ end
|
|
65
65
|
example(10, 20, 30)
|
66
66
|
CODE
|
67
67
|
|
68
|
-
report = build_report(code, RubyLint::
|
68
|
+
report = build_report(code, RubyLint::Analysis::ArgumentAmount)
|
69
69
|
|
70
70
|
report.entries.length.should == 0
|
71
71
|
end
|
@@ -77,14 +77,14 @@ name = 'Ruby'
|
|
77
77
|
name.downcase
|
78
78
|
CODE
|
79
79
|
|
80
|
-
report = build_report(code, RubyLint::
|
80
|
+
report = build_report(code, RubyLint::Analysis::ArgumentAmount)
|
81
81
|
|
82
82
|
report.entries.empty?.should == true
|
83
83
|
end
|
84
84
|
|
85
85
|
should 'not validate methods called on undefined receivers' do
|
86
86
|
code = 'A.example_method'
|
87
|
-
report = build_report(code, RubyLint::
|
87
|
+
report = build_report(code, RubyLint::Analysis::ArgumentAmount)
|
88
88
|
|
89
89
|
report.entries.empty?.should == true
|
90
90
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
2
|
+
|
3
|
+
describe RubyLint::Analysis::ConfusingVariables do
|
4
|
+
should 'warn when assigning a variable with the same name as a method' do
|
5
|
+
code = <<-CODE
|
6
|
+
def number
|
7
|
+
end
|
8
|
+
|
9
|
+
number = 10
|
10
|
+
CODE
|
11
|
+
|
12
|
+
report = build_report(code, RubyLint::Analysis::ConfusingVariables)
|
13
|
+
entry = report.entries[0]
|
14
|
+
|
15
|
+
entry.line.should == 4
|
16
|
+
entry.column.should == 0
|
17
|
+
entry.message.should =~ /variable assignment using the same name/
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'not warn when the variable is assigned inside the method itself' do
|
21
|
+
code = <<-CODE
|
22
|
+
def number
|
23
|
+
number = 10
|
24
|
+
end
|
25
|
+
CODE
|
26
|
+
|
27
|
+
report = build_report(code, RubyLint::Analysis::ConfusingVariables)
|
28
|
+
|
29
|
+
report.entries.empty?.should == true
|
30
|
+
end
|
31
|
+
|
32
|
+
should 'not warn when the method is defined in a different scope' do
|
33
|
+
code = <<-CODE
|
34
|
+
module Foo
|
35
|
+
def number
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
number = 10
|
40
|
+
CODE
|
41
|
+
|
42
|
+
report = build_report(code, RubyLint::Analysis::ConfusingVariables)
|
43
|
+
|
44
|
+
report.entries.empty?.should == true
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../../../helper', __FILE__)
|
2
|
+
|
3
|
+
describe RubyLint::Analysis::Pedantics do
|
4
|
+
should 'warn when using do/then in various statements' do
|
5
|
+
code = <<-CODE
|
6
|
+
if true then; end
|
7
|
+
unless true then; end
|
8
|
+
while true do; end
|
9
|
+
CODE
|
10
|
+
|
11
|
+
report = build_report(code, RubyLint::Analysis::Pedantics)
|
12
|
+
entries = report.entries
|
13
|
+
|
14
|
+
entries.length.should == 3
|
15
|
+
|
16
|
+
entries[0].line.should == 1
|
17
|
+
entries[0].message.should == 'the use of then/do is not needed here'
|
18
|
+
|
19
|
+
entries[1].line.should == 2
|
20
|
+
entries[1].message.should == 'the use of then/do is not needed here'
|
21
|
+
|
22
|
+
entries[2].line.should == 3
|
23
|
+
entries[2].message.should == 'the use of then/do is not needed here'
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'warn for the use of BEGIN/END' do
|
27
|
+
code = <<-CODE
|
28
|
+
BEGIN {}
|
29
|
+
END {}
|
30
|
+
CODE
|
31
|
+
|
32
|
+
report = build_report(code, RubyLint::Analysis::Pedantics)
|
33
|
+
entries = report.entries
|
34
|
+
|
35
|
+
entries.length.should == 2
|
36
|
+
|
37
|
+
entries[0].line.should == 1
|
38
|
+
entries[0].message.should == 'BEGIN/END is useless'
|
39
|
+
|
40
|
+
entries[1].line.should == 2
|
41
|
+
entries[1].message.should == 'BEGIN/END is useless'
|
42
|
+
end
|
43
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe RubyLint::
|
3
|
+
describe RubyLint::Analysis::ShadowingVariables do
|
4
4
|
should 'warn for shadowing outer variables' do
|
5
5
|
code = <<-CODE
|
6
6
|
number = 10
|
@@ -10,7 +10,7 @@ number = 10
|
|
10
10
|
end
|
11
11
|
CODE
|
12
12
|
|
13
|
-
report = build_report(code, RubyLint::
|
13
|
+
report = build_report(code, RubyLint::Analysis::ShadowingVariables)
|
14
14
|
entry = report.entries[0]
|
15
15
|
|
16
16
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -31,7 +31,7 @@ def example
|
|
31
31
|
end
|
32
32
|
CODE
|
33
33
|
|
34
|
-
report = build_report(code, RubyLint::
|
34
|
+
report = build_report(code, RubyLint::Analysis::ShadowingVariables)
|
35
35
|
|
36
36
|
report.entries.empty?.should == true
|
37
37
|
end
|
@@ -47,7 +47,7 @@ def example; end
|
|
47
47
|
end
|
48
48
|
CODE
|
49
49
|
|
50
|
-
report = build_report(code, RubyLint::
|
50
|
+
report = build_report(code, RubyLint::Analysis::ShadowingVariables)
|
51
51
|
entry = report.entries[0]
|
52
52
|
|
53
53
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -70,7 +70,7 @@ A::B.example do |number|
|
|
70
70
|
end
|
71
71
|
CODE
|
72
72
|
|
73
|
-
report = build_report(code, RubyLint::
|
73
|
+
report = build_report(code, RubyLint::Analysis::ShadowingVariables)
|
74
74
|
|
75
75
|
report.entries.length.should == 2
|
76
76
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe RubyLint::
|
3
|
+
describe RubyLint::Analysis::UndefinedMethods do
|
4
4
|
should 'add an error for calling an undefined method' do
|
5
|
-
report = build_report('example_method', RubyLint::
|
5
|
+
report = build_report('example_method', RubyLint::Analysis::UndefinedMethods)
|
6
6
|
entry = report.entries[0]
|
7
7
|
|
8
8
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -22,25 +22,25 @@ end
|
|
22
22
|
String.example_method
|
23
23
|
CODE
|
24
24
|
|
25
|
-
report = build_report(code, RubyLint::
|
25
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
26
26
|
entry = report.entries[0]
|
27
27
|
|
28
28
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
29
29
|
|
30
30
|
entry.line.should == 6
|
31
|
-
entry.column.should ==
|
31
|
+
entry.column.should == 0
|
32
32
|
entry.message.should == 'undefined method example_method on String'
|
33
33
|
end
|
34
34
|
|
35
35
|
should 'add an error for calling an undefined method on a receiver instance' do
|
36
36
|
code = '"hello".example_method'
|
37
|
-
report = build_report(code, RubyLint::
|
37
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
38
38
|
entry = report.entries[0]
|
39
39
|
|
40
40
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
41
41
|
|
42
42
|
entry.line.should == 1
|
43
|
-
entry.column.should ==
|
43
|
+
entry.column.should == 0
|
44
44
|
entry.message.should == 'undefined method example_method ' \
|
45
45
|
'on an instance of String'
|
46
46
|
end
|
@@ -60,7 +60,7 @@ end
|
|
60
60
|
name
|
61
61
|
CODE
|
62
62
|
|
63
|
-
report = build_report(code, RubyLint::
|
63
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
64
64
|
|
65
65
|
report.entries.length.should == 1
|
66
66
|
|
@@ -75,31 +75,31 @@ name
|
|
75
75
|
|
76
76
|
describe 'core Ruby types' do
|
77
77
|
should 'not add errors for calling defined methods on a Fixnum' do
|
78
|
-
report = build_report('10.to_s', RubyLint::
|
78
|
+
report = build_report('10.to_s', RubyLint::Analysis::UndefinedMethods)
|
79
79
|
|
80
80
|
report.entries.empty?.should == true
|
81
81
|
end
|
82
82
|
|
83
83
|
should 'not add errors for calling defined methods on a Float' do
|
84
|
-
report = build_report('(10.0).to_s', RubyLint::
|
84
|
+
report = build_report('(10.0).to_s', RubyLint::Analysis::UndefinedMethods)
|
85
85
|
|
86
86
|
report.entries.empty?.should == true
|
87
87
|
end
|
88
88
|
|
89
89
|
should 'not add errors for calling defined methods on a String' do
|
90
|
-
report = build_report('"10".to_s', RubyLint::
|
90
|
+
report = build_report('"10".to_s', RubyLint::Analysis::UndefinedMethods)
|
91
91
|
|
92
92
|
report.entries.empty?.should == true
|
93
93
|
end
|
94
94
|
|
95
95
|
should 'not add errors for calling defined methods on a Hash' do
|
96
|
-
report = build_report('{}.to_s', RubyLint::
|
96
|
+
report = build_report('{}.to_s', RubyLint::Analysis::UndefinedMethods)
|
97
97
|
|
98
98
|
report.entries.empty?.should == true
|
99
99
|
end
|
100
100
|
|
101
101
|
should 'not add errors for calling defined methods on an Array' do
|
102
|
-
report = build_report('[].to_s', RubyLint::
|
102
|
+
report = build_report('[].to_s', RubyLint::Analysis::UndefinedMethods)
|
103
103
|
|
104
104
|
report.entries.empty?.should == true
|
105
105
|
end
|
@@ -112,7 +112,7 @@ name
|
|
112
112
|
end
|
113
113
|
CODE
|
114
114
|
|
115
|
-
report = build_report(code, RubyLint::
|
115
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
116
116
|
|
117
117
|
report.entries.empty?.should == true
|
118
118
|
end
|
@@ -125,21 +125,21 @@ name.downcase
|
|
125
125
|
name.downcasex
|
126
126
|
CODE
|
127
127
|
|
128
|
-
report = build_report(code, RubyLint::
|
128
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
129
129
|
|
130
130
|
report.entries.length.should == 1
|
131
131
|
|
132
132
|
entry = report.entries[0]
|
133
133
|
|
134
134
|
entry.line.should == 4
|
135
|
-
entry.column.should ==
|
135
|
+
entry.column.should == 0
|
136
136
|
entry.message.should == 'undefined method downcasex on an instance of String'
|
137
137
|
end
|
138
138
|
|
139
139
|
should 'not add errors when calling a method on an undefined constant' do
|
140
140
|
code = 'A.example_method'
|
141
141
|
|
142
|
-
report = build_report(code, RubyLint::
|
142
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
143
143
|
|
144
144
|
report.entries.empty?.should == true
|
145
145
|
end
|
@@ -151,7 +151,7 @@ def example(number)
|
|
151
151
|
end
|
152
152
|
CODE
|
153
153
|
|
154
|
-
report = build_report(code, RubyLint::
|
154
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
155
155
|
|
156
156
|
report.entries.empty?.should == true
|
157
157
|
end
|
@@ -163,7 +163,7 @@ number = 10
|
|
163
163
|
first = second = number.foobar
|
164
164
|
CODE
|
165
165
|
|
166
|
-
report = build_report(code, RubyLint::
|
166
|
+
report = build_report(code, RubyLint::Analysis::UndefinedMethods)
|
167
167
|
|
168
168
|
report.entries.length.should == 1
|
169
169
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path('../../../helper', __FILE__)
|
2
2
|
|
3
|
-
describe RubyLint::
|
3
|
+
describe RubyLint::Analysis::UndefinedVariables do
|
4
4
|
should 'add an error for using an undefined instance variable' do
|
5
|
-
report = build_report('@number', RubyLint::
|
5
|
+
report = build_report('@number', RubyLint::Analysis::UndefinedVariables)
|
6
6
|
entry = report.entries[0]
|
7
7
|
|
8
8
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -13,7 +13,7 @@ describe RubyLint::Analyze::UndefinedVariables do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
should 'add an error for using an undefined class variable' do
|
16
|
-
report = build_report('@@number', RubyLint::
|
16
|
+
report = build_report('@@number', RubyLint::Analysis::UndefinedVariables)
|
17
17
|
entry = report.entries[0]
|
18
18
|
|
19
19
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -24,7 +24,7 @@ describe RubyLint::Analyze::UndefinedVariables do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
should 'add an error for using an undefined global variable' do
|
27
|
-
report = build_report('$number', RubyLint::
|
27
|
+
report = build_report('$number', RubyLint::Analysis::UndefinedVariables)
|
28
28
|
entry = report.entries[0]
|
29
29
|
|
30
30
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -35,7 +35,7 @@ describe RubyLint::Analyze::UndefinedVariables do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
should 'add an error for using an undefined constant' do
|
38
|
-
report = build_report('NUMBER', RubyLint::
|
38
|
+
report = build_report('NUMBER', RubyLint::Analysis::UndefinedVariables)
|
39
39
|
entry = report.entries[0]
|
40
40
|
|
41
41
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
@@ -45,9 +45,9 @@ describe RubyLint::Analyze::UndefinedVariables do
|
|
45
45
|
entry.message.should == 'undefined constant NUMBER'
|
46
46
|
end
|
47
47
|
|
48
|
-
should 'add an error for using an undefined constant
|
48
|
+
should 'add an error for using an undefined constant path' do
|
49
49
|
code = <<-CODE
|
50
|
-
# This is to ensure that the
|
50
|
+
# This is to ensure that the on_const() callback isn't used to check for "B"
|
51
51
|
# in the global scope.
|
52
52
|
B = 10
|
53
53
|
|
@@ -57,27 +57,14 @@ end
|
|
57
57
|
A::B
|
58
58
|
CODE
|
59
59
|
|
60
|
-
report = build_report(code, RubyLint::
|
60
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
61
61
|
entry = report.entries[0]
|
62
62
|
|
63
63
|
entry.is_a?(RubyLint::Report::Entry).should == true
|
64
64
|
|
65
65
|
entry.line.should == 8
|
66
|
-
entry.column.should == 3
|
67
|
-
entry.message.should == 'undefined constant B'
|
68
|
-
end
|
69
|
-
|
70
|
-
should 'add an error when the entire constant path does not exist' do
|
71
|
-
code = 'A::B::C'
|
72
|
-
report = build_report(code, RubyLint::Analyze::UndefinedVariables)
|
73
|
-
|
74
|
-
report.entries.length.should == 1
|
75
|
-
|
76
|
-
entry = report.entries[0]
|
77
|
-
|
78
|
-
entry.line.should == 1
|
79
66
|
entry.column.should == 0
|
80
|
-
entry.message.should == 'undefined constant A'
|
67
|
+
entry.message.should == 'undefined constant A::B'
|
81
68
|
end
|
82
69
|
|
83
70
|
should 'not depend on the order of variable definitions' do
|
@@ -93,14 +80,14 @@ class Person
|
|
93
80
|
end
|
94
81
|
CODE
|
95
82
|
|
96
|
-
report = build_report(code, RubyLint::
|
83
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
97
84
|
|
98
85
|
report.entries.empty?.should == true
|
99
86
|
end
|
100
87
|
|
101
88
|
should 'not add errors when autoloading constants' do
|
102
89
|
code = 'Encoding::BIG5'
|
103
|
-
report = build_report(code, RubyLint::
|
90
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
104
91
|
|
105
92
|
report.entries.empty?.should == true
|
106
93
|
end
|
@@ -114,7 +101,14 @@ example_method do
|
|
114
101
|
end
|
115
102
|
CODE
|
116
103
|
|
117
|
-
report = build_report(code, RubyLint::
|
104
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
105
|
+
|
106
|
+
report.entries.empty?.should == true
|
107
|
+
end
|
108
|
+
|
109
|
+
should 'not add errors for variable references in string interpolation' do
|
110
|
+
code = 'number = 10; "#{number}"'
|
111
|
+
report = build_report(code, RubyLint::Analysis::UndefinedVariables)
|
118
112
|
|
119
113
|
report.entries.empty?.should == true
|
120
114
|
end
|