ruby-lint 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.asc +17 -0
- data/.gitignore +1 -0
- data/.travis.yml +25 -0
- data/.yardopts +4 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/MANIFEST +238 -49
- data/README.md +84 -131
- data/Rakefile +6 -0
- data/bin/ruby-lint +2 -2
- data/checksum/.gitkeep +0 -0
- data/doc/DCO.md +26 -0
- data/doc/architecture.md +63 -0
- data/doc/code_analysis.md +90 -0
- data/doc/configuration.md +86 -0
- data/doc/contributing.md +16 -0
- data/doc/graphviz/flow.dot +7 -0
- data/doc/images/.gitkeep +0 -0
- data/doc/images/flow.png +0 -0
- data/lib/ruby-lint.rb +35 -35
- data/lib/ruby-lint/analyze/argument_amount.rb +73 -0
- data/lib/ruby-lint/analyze/shadowing_variables.rb +19 -24
- data/lib/ruby-lint/analyze/undefined_methods.rb +68 -0
- data/lib/ruby-lint/analyze/undefined_variables.rb +42 -69
- data/lib/ruby-lint/analyze/unused_variables.rb +23 -78
- data/lib/ruby-lint/base.rb +85 -0
- data/lib/ruby-lint/cli.rb +23 -167
- data/lib/ruby-lint/cli/analyze.rb +99 -0
- data/lib/ruby-lint/cli/ast.rb +35 -0
- data/lib/ruby-lint/cli/base.rb +120 -0
- data/lib/ruby-lint/configuration.rb +112 -0
- data/lib/ruby-lint/constant_loader.rb +92 -0
- data/lib/ruby-lint/definition/ruby_method.rb +248 -0
- data/lib/ruby-lint/definition/ruby_object.rb +757 -0
- data/lib/ruby-lint/definition_generator.rb +155 -0
- data/lib/ruby-lint/definitions/core.rb +5 -0
- data/lib/ruby-lint/definitions/core/arg0.rb +7 -0
- data/lib/ruby-lint/definitions/core/argf.rb +7 -0
- data/lib/ruby-lint/definitions/core/argument_error.rb +12 -0
- data/lib/ruby-lint/definitions/core/argv.rb +7 -0
- data/lib/ruby-lint/definitions/core/array.rb +414 -0
- data/lib/ruby-lint/definitions/core/autoload.rb +39 -0
- data/lib/ruby-lint/definitions/core/basic_object.rb +46 -0
- data/lib/ruby-lint/definitions/core/bignum.rb +128 -0
- data/lib/ruby-lint/definitions/core/binding.rb +52 -0
- data/lib/ruby-lint/definitions/core/class.rb +23 -0
- data/lib/ruby-lint/definitions/core/comparable.rb +38 -0
- data/lib/ruby-lint/definitions/core/complex.rb +195 -0
- data/lib/ruby-lint/definitions/core/condition_variable.rb +19 -0
- data/lib/ruby-lint/definitions/core/continuation.rb +8 -0
- data/lib/ruby-lint/definitions/core/data.rb +8 -0
- data/lib/ruby-lint/definitions/core/date.rb +706 -0
- data/lib/ruby-lint/definitions/core/date_time.rb +381 -0
- data/lib/ruby-lint/definitions/core/default_record_separator.rb +7 -0
- data/lib/ruby-lint/definitions/core/digest.rb +166 -0
- data/lib/ruby-lint/definitions/core/dir.rb +496 -0
- data/lib/ruby-lint/definitions/core/encoding.rb +2030 -0
- data/lib/ruby-lint/definitions/core/encoding_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/enumerable.rb +352 -0
- data/lib/ruby-lint/definitions/core/enumerator.rb +37 -0
- data/lib/ruby-lint/definitions/core/env.rb +7 -0
- data/lib/ruby-lint/definitions/core/eoferror.rb +8 -0
- data/lib/ruby-lint/definitions/core/erb.rb +304 -0
- data/lib/ruby-lint/definitions/core/errno.rb +3331 -0
- data/lib/ruby-lint/definitions/core/etc.rb +138 -0
- data/lib/ruby-lint/definitions/core/exception.rb +72 -0
- data/lib/ruby-lint/definitions/core/false.rb +7 -0
- data/lib/ruby-lint/definitions/core/false_class.rb +30 -0
- data/lib/ruby-lint/definitions/core/fatal_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/fiber.rb +35 -0
- data/lib/ruby-lint/definitions/core/fiber_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/file.rb +1277 -0
- data/lib/ruby-lint/definitions/core/file_list.rb +727 -0
- data/lib/ruby-lint/definitions/core/file_test.rb +106 -0
- data/lib/ruby-lint/definitions/core/file_utils.rb +1027 -0
- data/lib/ruby-lint/definitions/core/fixnum.rb +156 -0
- data/lib/ruby-lint/definitions/core/float.rb +307 -0
- data/lib/ruby-lint/definitions/core/float_domain_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/gc.rb +57 -0
- data/lib/ruby-lint/definitions/core/gem.rb +3161 -0
- data/lib/ruby-lint/definitions/core/hash.rb +512 -0
- data/lib/ruby-lint/definitions/core/immediate_value.rb +19 -0
- data/lib/ruby-lint/definitions/core/index_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/integer.rb +100 -0
- data/lib/ruby-lint/definitions/core/interrupt.rb +14 -0
- data/lib/ruby-lint/definitions/core/io.rb +928 -0
- data/lib/ruby-lint/definitions/core/ioerror.rb +8 -0
- data/lib/ruby-lint/definitions/core/kernel.rb +504 -0
- data/lib/ruby-lint/definitions/core/key_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/load_error.rb +28 -0
- data/lib/ruby-lint/definitions/core/local_jump_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/main.rb +25 -0
- data/lib/ruby-lint/definitions/core/marshal.rb +466 -0
- data/lib/ruby-lint/definitions/core/match_data.rb +73 -0
- data/lib/ruby-lint/definitions/core/math.rb +205 -0
- data/lib/ruby-lint/definitions/core/memory_segmention_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/method.rb +61 -0
- data/lib/ruby-lint/definitions/core/module.rb +262 -0
- data/lib/ruby-lint/definitions/core/monitor.rb +39 -0
- data/lib/ruby-lint/definitions/core/monitor_mixin.rb +59 -0
- data/lib/ruby-lint/definitions/core/mutex.rb +32 -0
- data/lib/ruby-lint/definitions/core/name_error.rb +16 -0
- data/lib/ruby-lint/definitions/core/nil.rb +7 -0
- data/lib/ruby-lint/definitions/core/nil_class.rb +46 -0
- data/lib/ruby-lint/definitions/core/no_memory_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/no_method_error.rb +18 -0
- data/lib/ruby-lint/definitions/core/not_implemented_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/numeric.rb +123 -0
- data/lib/ruby-lint/definitions/core/object.rb +31 -0
- data/lib/ruby-lint/definitions/core/object_space.rb +41 -0
- data/lib/ruby-lint/definitions/core/open_struct.rb +49 -0
- data/lib/ruby-lint/definitions/core/option_parser.rb +1355 -0
- data/lib/ruby-lint/definitions/core/precision.rb +21 -0
- data/lib/ruby-lint/definitions/core/primitive_failure.rb +8 -0
- data/lib/ruby-lint/definitions/core/proc.rb +109 -0
- data/lib/ruby-lint/definitions/core/process.rb +602 -0
- data/lib/ruby-lint/definitions/core/psych.rb +2231 -0
- data/lib/ruby-lint/definitions/core/queue.rb +44 -0
- data/lib/ruby-lint/definitions/core/rake.rb +4784 -0
- data/lib/ruby-lint/definitions/core/rake_file_utils.rb +203 -0
- data/lib/ruby-lint/definitions/core/rakeversion.rb +7 -0
- data/lib/ruby-lint/definitions/core/random.rb +38 -0
- data/lib/ruby-lint/definitions/core/range.rb +104 -0
- data/lib/ruby-lint/definitions/core/range_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/rational.rb +96 -0
- data/lib/ruby-lint/definitions/core/rb_config.rb +36 -0
- data/lib/ruby-lint/definitions/core/regexp.rb +396 -0
- data/lib/ruby-lint/definitions/core/regexp_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/rubinius.rb +16637 -0
- data/lib/ruby-lint/definitions/core/ruby_copyright.rb +7 -0
- data/lib/ruby-lint/definitions/core/ruby_description.rb +7 -0
- data/lib/ruby-lint/definitions/core/ruby_engine.rb +7 -0
- data/lib/ruby-lint/definitions/core/ruby_lint.rb +93 -0
- data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +7 -0
- data/lib/ruby-lint/definitions/core/ruby_platform.rb +7 -0
- data/lib/ruby-lint/definitions/core/ruby_release_date.rb +7 -0
- data/lib/ruby-lint/definitions/core/ruby_version.rb +7 -0
- data/lib/ruby-lint/definitions/core/runtime_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/scan_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/script_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/security_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/shellwords.rb +37 -0
- data/lib/ruby-lint/definitions/core/signal.rb +37 -0
- data/lib/ruby-lint/definitions/core/signal_exception.rb +19 -0
- data/lib/ruby-lint/definitions/core/singleton.rb +37 -0
- data/lib/ruby-lint/definitions/core/sized_queue.rb +42 -0
- data/lib/ruby-lint/definitions/core/standard_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/stderr.rb +7 -0
- data/lib/ruby-lint/definitions/core/stdin.rb +7 -0
- data/lib/ruby-lint/definitions/core/stdout.rb +7 -0
- data/lib/ruby-lint/definitions/core/stop_iteration.rb +8 -0
- data/lib/ruby-lint/definitions/core/string.rb +713 -0
- data/lib/ruby-lint/definitions/core/string_io.rb +287 -0
- data/lib/ruby-lint/definitions/core/string_scanner.rb +158 -0
- data/lib/ruby-lint/definitions/core/struct.rb +357 -0
- data/lib/ruby-lint/definitions/core/syck.rb +30 -0
- data/lib/ruby-lint/definitions/core/symbol.rb +90 -0
- data/lib/ruby-lint/definitions/core/syntax_error.rb +44 -0
- data/lib/ruby-lint/definitions/core/system_call_error.rb +31 -0
- data/lib/ruby-lint/definitions/core/system_exit.rb +19 -0
- data/lib/ruby-lint/definitions/core/system_stack_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/thread.rb +209 -0
- data/lib/ruby-lint/definitions/core/thread_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/thread_group.rb +22 -0
- data/lib/ruby-lint/definitions/core/time.rb +233 -0
- data/lib/ruby-lint/definitions/core/toplevel_binding.rb +7 -0
- data/lib/ruby-lint/definitions/core/true.rb +7 -0
- data/lib/ruby-lint/definitions/core/true_class.rb +30 -0
- data/lib/ruby-lint/definitions/core/type_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/unbound_method.rb +51 -0
- data/lib/ruby-lint/definitions/core/unmarshalable.rb +13 -0
- data/lib/ruby-lint/definitions/core/unsupported_library_error.rb +8 -0
- data/lib/ruby-lint/definitions/core/weak_ref.rb +42 -0
- data/lib/ruby-lint/definitions/core/zero_division_error.rb +8 -0
- data/lib/ruby-lint/definitions_builder.rb +692 -0
- data/lib/ruby-lint/extensions/string.rb +15 -0
- data/lib/ruby-lint/helper/constant_paths.rb +41 -0
- data/lib/ruby-lint/helper/conversion.rb +33 -0
- data/lib/ruby-lint/helper/current_scope.rb +98 -0
- data/lib/ruby-lint/helper/methods.rb +91 -0
- data/lib/ruby-lint/inspector.rb +191 -0
- data/lib/ruby-lint/iterator.rb +187 -127
- data/lib/ruby-lint/node.rb +107 -0
- data/lib/ruby-lint/parser.rb +510 -1137
- data/lib/ruby-lint/parser_error.rb +15 -27
- data/lib/ruby-lint/presenter/json.rb +19 -0
- data/lib/ruby-lint/presenter/text.rb +37 -0
- data/lib/ruby-lint/report.rb +95 -53
- data/lib/ruby-lint/report/entry.rb +71 -0
- data/lib/ruby-lint/template/definition.erb +24 -0
- data/lib/ruby-lint/template/scope.rb +25 -0
- data/lib/ruby-lint/variable_predicates.rb +109 -0
- data/lib/ruby-lint/version.rb +1 -1
- data/ruby-lint.gemspec +19 -8
- data/spec/helper.rb +10 -2
- data/spec/ruby-lint/analyze/argument_amount.rb +91 -0
- data/spec/ruby-lint/analyze/shadowing_variables.rb +69 -14
- data/spec/ruby-lint/analyze/undefined_methods.rb +174 -0
- data/spec/ruby-lint/analyze/undefined_variables.rb +70 -179
- data/spec/ruby-lint/analyze/unused_variables.rb +63 -183
- data/spec/ruby-lint/configuration.rb +15 -0
- data/spec/ruby-lint/constant_loader.rb +32 -0
- data/spec/ruby-lint/definition/dsl.rb +142 -0
- data/spec/ruby-lint/definition/method_calls.rb +26 -0
- data/spec/ruby-lint/definition/ruby_method.rb +175 -0
- data/spec/ruby-lint/definition/ruby_object.rb +228 -0
- data/spec/ruby-lint/definitions_builder/assignments/arrays.rb +71 -0
- data/spec/ruby-lint/definitions_builder/assignments/hashes.rb +65 -0
- data/spec/ruby-lint/definitions_builder/assignments/objects.rb +23 -0
- data/spec/ruby-lint/definitions_builder/assignments/optional.rb +22 -0
- data/spec/ruby-lint/definitions_builder/assignments/return_values.rb +78 -0
- data/spec/ruby-lint/definitions_builder/assignments/variables.rb +71 -0
- data/spec/ruby-lint/definitions_builder/associate_nodes.rb +17 -0
- data/spec/ruby-lint/definitions_builder/blocks.rb +40 -0
- data/spec/ruby-lint/definitions_builder/classes.rb +230 -0
- data/spec/ruby-lint/definitions_builder/for.rb +16 -0
- data/spec/ruby-lint/definitions_builder/methods.rb +147 -0
- data/spec/ruby-lint/definitions_builder/modules.rb +175 -0
- data/spec/ruby-lint/definitions_builder/reference_amount.rb +31 -0
- data/spec/ruby-lint/definitions_builder/unused.rb +15 -0
- data/spec/ruby-lint/extensions/string.rb +7 -0
- data/spec/ruby-lint/iterator.rb +42 -417
- data/spec/ruby-lint/node.rb +38 -0
- data/spec/ruby-lint/parser/assignments.rb +225 -0
- data/spec/ruby-lint/parser/classes.rb +80 -122
- data/spec/ruby-lint/parser/errors.rb +7 -14
- data/spec/ruby-lint/parser/metadata.rb +17 -0
- data/spec/ruby-lint/parser/method_definitions.rb +111 -0
- data/spec/ruby-lint/parser/methods.rb +184 -216
- data/spec/ruby-lint/parser/modules.rb +54 -33
- data/spec/ruby-lint/parser/operators.rb +30 -65
- data/spec/ruby-lint/parser/statements/begin.rb +55 -0
- data/spec/ruby-lint/parser/statements/case.rb +34 -0
- data/spec/ruby-lint/parser/statements/defined.rb +11 -0
- data/spec/ruby-lint/parser/statements/for.rb +34 -0
- data/spec/ruby-lint/parser/statements/if.rb +46 -0
- data/spec/ruby-lint/parser/statements/return.rb +14 -0
- data/spec/ruby-lint/parser/statements/super.rb +49 -0
- data/spec/ruby-lint/parser/statements/unless.rb +42 -0
- data/spec/ruby-lint/parser/statements/until.rb +25 -0
- data/spec/ruby-lint/parser/statements/while.rb +25 -0
- data/spec/ruby-lint/parser/statements/yield.rb +18 -0
- data/spec/ruby-lint/parser/types/arrays.rb +47 -0
- data/spec/ruby-lint/parser/types/booleans.rb +11 -0
- data/spec/ruby-lint/parser/types/constants.rb +32 -0
- data/spec/ruby-lint/parser/types/hashes.rb +55 -0
- data/spec/ruby-lint/parser/types/nil.rb +7 -0
- data/spec/ruby-lint/parser/types/numbers.rb +11 -0
- data/spec/ruby-lint/parser/types/procs.rb +11 -0
- data/spec/ruby-lint/parser/types/ranges.rb +11 -0
- data/spec/ruby-lint/parser/types/regexp.rb +27 -0
- data/spec/ruby-lint/parser/types/strings.rb +44 -0
- data/spec/ruby-lint/parser/types/symbols.rb +15 -0
- data/spec/ruby-lint/presenter/json.rb +31 -0
- data/spec/ruby-lint/presenter/text.rb +22 -0
- data/spec/ruby-lint/report.rb +45 -15
- data/spec/ruby-lint/report/entry.rb +24 -0
- data/spec/support/bacon.rb +33 -0
- data/spec/support/building.rb +43 -0
- data/spec/support/definitions.rb +23 -0
- data/spec/support/parsing.rb +23 -0
- data/spec/support/simplecov.rb +16 -0
- data/task/build.rake +9 -0
- data/task/checksum.rake +13 -0
- data/task/coverage.rake +6 -0
- data/task/doc.rake +5 -0
- data/task/generate.rake +34 -0
- data/task/graphviz.rake +12 -0
- data/task/stdlib.rake +2 -9
- data/task/tag.rake +6 -0
- metadata +337 -68
- metadata.gz.asc +17 -0
- data/.rbenv-version +0 -1
- data/lib/ruby-lint/analyze/coding_style.rb +0 -407
- data/lib/ruby-lint/analyze/definitions.rb +0 -244
- data/lib/ruby-lint/analyze/method_validation.rb +0 -104
- data/lib/ruby-lint/callback.rb +0 -67
- data/lib/ruby-lint/constant_importer.rb +0 -112
- data/lib/ruby-lint/definition.rb +0 -230
- data/lib/ruby-lint/formatter/text.rb +0 -54
- data/lib/ruby-lint/helper/definition_resolver.rb +0 -143
- data/lib/ruby-lint/helper/scoping.rb +0 -138
- data/lib/ruby-lint/options.rb +0 -58
- data/lib/ruby-lint/token/assignment_token.rb +0 -35
- data/lib/ruby-lint/token/begin_rescue_token.rb +0 -57
- data/lib/ruby-lint/token/block_token.rb +0 -26
- data/lib/ruby-lint/token/case_token.rb +0 -44
- data/lib/ruby-lint/token/class_token.rb +0 -24
- data/lib/ruby-lint/token/keyword_token.rb +0 -43
- data/lib/ruby-lint/token/method_definition_token.rb +0 -64
- data/lib/ruby-lint/token/method_token.rb +0 -56
- data/lib/ruby-lint/token/parameters_token.rb +0 -99
- data/lib/ruby-lint/token/regexp_token.rb +0 -15
- data/lib/ruby-lint/token/statement_token.rb +0 -69
- data/lib/ruby-lint/token/token.rb +0 -176
- data/lib/ruby-lint/token/variable_token.rb +0 -18
- data/spec/benchmarks/memory.rb +0 -52
- data/spec/benchmarks/parse_parser.rb +0 -16
- data/spec/fixtures/stdlib/un.rb +0 -348
- data/spec/ruby-lint/analyze/coding_style.rb +0 -224
- data/spec/ruby-lint/analyze/complex/un.rb +0 -29
- data/spec/ruby-lint/analyze/definitions/classes.rb +0 -114
- data/spec/ruby-lint/analyze/definitions/methods.rb +0 -91
- data/spec/ruby-lint/analyze/definitions/modules.rb +0 -207
- data/spec/ruby-lint/analyze/definitions/variables.rb +0 -103
- data/spec/ruby-lint/analyze/method_validation.rb +0 -177
- data/spec/ruby-lint/callback.rb +0 -28
- data/spec/ruby-lint/constant_importer.rb +0 -27
- data/spec/ruby-lint/definition.rb +0 -96
- data/spec/ruby-lint/formatter/text.rb +0 -21
- data/spec/ruby-lint/parser/arrays.rb +0 -147
- data/spec/ruby-lint/parser/expander_assignments.rb +0 -183
- data/spec/ruby-lint/parser/hashes.rb +0 -136
- data/spec/ruby-lint/parser/keywords.rb +0 -89
- data/spec/ruby-lint/parser/objects.rb +0 -39
- data/spec/ruby-lint/parser/procs.rb +0 -113
- data/spec/ruby-lint/parser/ranges.rb +0 -49
- data/spec/ruby-lint/parser/regexp.rb +0 -31
- data/spec/ruby-lint/parser/scalars.rb +0 -93
- data/spec/ruby-lint/parser/statements.rb +0 -591
- data/spec/ruby-lint/parser/variables.rb +0 -230
data/spec/ruby-lint/callback.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe 'RubyLint::Callback' do
|
|
4
|
-
it 'Add an error to a report using RubyLint::Callback' do
|
|
5
|
-
report = RubyLint::Report.new
|
|
6
|
-
callback = RubyLint::Callback.new(report)
|
|
7
|
-
|
|
8
|
-
report.levels.each do |level|
|
|
9
|
-
report.messages[level].nil?.should == true
|
|
10
|
-
|
|
11
|
-
callback.send(level, "test #{level}", 1, 1)
|
|
12
|
-
|
|
13
|
-
report.messages[level].class.should == Array
|
|
14
|
-
report.messages[level].length.should == 1
|
|
15
|
-
|
|
16
|
-
report.messages[level][0][:message].should == "test #{level}"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'Ignore errors (when disabled) when adding one using RubyLint::Callback' do
|
|
21
|
-
report = RubyLint::Report.new('(ruby-lint)', [:warning])
|
|
22
|
-
callback = RubyLint::Callback.new(report)
|
|
23
|
-
|
|
24
|
-
callback.send(:error, 'test error', 1, 1)
|
|
25
|
-
|
|
26
|
-
report.messages[:error].nil?.should == true
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe 'RubyLint::ConstantImporter' do
|
|
4
|
-
it 'Import methods from the Kernel constant' do
|
|
5
|
-
imported = RubyLint::ConstantImporter.import([:Kernel])
|
|
6
|
-
|
|
7
|
-
imported.key?('Kernel').should == true
|
|
8
|
-
|
|
9
|
-
found = imported['Kernel'].lookup(:method, 'puts')
|
|
10
|
-
|
|
11
|
-
found.class.should == RubyLint::Definition
|
|
12
|
-
|
|
13
|
-
found.token.class.should == RubyLint::Token::MethodDefinitionToken
|
|
14
|
-
found.token.name.should == 'puts'
|
|
15
|
-
found.token.visibility.should == :public
|
|
16
|
-
|
|
17
|
-
found.token.parameters.class.should == RubyLint::Token::ParametersToken
|
|
18
|
-
|
|
19
|
-
found.token.parameters.value.class.should == Array
|
|
20
|
-
found.token.parameters.value.length.should == 0
|
|
21
|
-
|
|
22
|
-
found.token.parameters.rest.class.should == RubyLint::Token::VariableToken
|
|
23
|
-
found.token.parameters.rest.name.should == ''
|
|
24
|
-
found.token.parameters.rest.type.should == :local_variable
|
|
25
|
-
found.token.parameters.rest.event.should == :local_variable
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe 'RubyLint::Definition' do
|
|
4
|
-
it 'Look up a symbol in a scope' do
|
|
5
|
-
scope = RubyLint::Definition.new
|
|
6
|
-
|
|
7
|
-
scope.lookup(:local_variable, 'number').should == nil
|
|
8
|
-
|
|
9
|
-
scope.add(:local_variable, 'number', 10)
|
|
10
|
-
|
|
11
|
-
scope.lookup(:local_variable, 'number').should == 10
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it 'Look up a symbol in a parent scope' do
|
|
15
|
-
parent = RubyLint::Definition.new
|
|
16
|
-
child = RubyLint::Definition.new(parent)
|
|
17
|
-
|
|
18
|
-
parent.add(:local_variable, 'number', 10)
|
|
19
|
-
parent.add(:global_variable, '$number', 20)
|
|
20
|
-
|
|
21
|
-
parent.lookup(:local_variable, 'number').should == 10
|
|
22
|
-
parent.lookup(:global_variable, '$number').should == 20
|
|
23
|
-
|
|
24
|
-
child.lookup(:local_variable, 'number').should == nil
|
|
25
|
-
child.lookup(:global_variable, '$number').should == 20
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'Create a scope with default Ruby constants and methods' do
|
|
29
|
-
scope = RubyLint::Definition.new(nil, :lazy => true, :kernel => true)
|
|
30
|
-
found = scope.lookup(:constant, 'Kernel')
|
|
31
|
-
|
|
32
|
-
found.class.should == RubyLint::Definition
|
|
33
|
-
|
|
34
|
-
method = found.lookup(:method, 'warn')
|
|
35
|
-
|
|
36
|
-
method.class.should == RubyLint::Definition
|
|
37
|
-
|
|
38
|
-
method.token.class.should == RubyLint::Token::MethodDefinitionToken
|
|
39
|
-
method.token.name.should == 'warn'
|
|
40
|
-
|
|
41
|
-
method.token.parameters.value.class.should == Array
|
|
42
|
-
method.token.parameters.value.length.should == 1
|
|
43
|
-
|
|
44
|
-
param = method.token.parameters.value[0]
|
|
45
|
-
|
|
46
|
-
param.class.should == RubyLint::Token::VariableToken
|
|
47
|
-
param.name.should == ''
|
|
48
|
-
param.type.should == :local_variable
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'Lazy import the Time class' do
|
|
52
|
-
scope = RubyLint::Definition.new
|
|
53
|
-
|
|
54
|
-
scope.lookup(:constant, 'Time').nil?.should == true
|
|
55
|
-
|
|
56
|
-
scope = RubyLint::Definition.new(nil, :lazy => true)
|
|
57
|
-
|
|
58
|
-
scope.lookup(:constant, 'Time').class.should == RubyLint::Definition
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'Lazy import the Encoding class and a child constant' do
|
|
62
|
-
scope = RubyLint::Definition.new(nil, :lazy => true)
|
|
63
|
-
enc = scope.lookup(:constant, 'Encoding')
|
|
64
|
-
|
|
65
|
-
enc.class.should == RubyLint::Definition
|
|
66
|
-
|
|
67
|
-
enc.lookup(:constant, 'BINARY').class.should == RubyLint::Definition
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'Lazy import RubyLint::Definition' do
|
|
71
|
-
scope = RubyLint::Definition.new(nil, :lazy => true)
|
|
72
|
-
|
|
73
|
-
ruby_lint = scope.lookup(:constant, 'RubyLint')
|
|
74
|
-
|
|
75
|
-
ruby_lint.class.should == RubyLint::Definition
|
|
76
|
-
|
|
77
|
-
ruby_lint_scope = ruby_lint.lookup(:constant, 'Definition')
|
|
78
|
-
|
|
79
|
-
ruby_lint_scope.class.should == RubyLint::Definition
|
|
80
|
-
|
|
81
|
-
ruby_lint_scope.lookup(:constant, 'LOOKUP_PARENT').class.should == RubyLint::Definition
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it 'Create a scope with multiple parent scopes' do
|
|
85
|
-
scope_1 = RubyLint::Definition.new
|
|
86
|
-
scope_2 = RubyLint::Definition.new
|
|
87
|
-
|
|
88
|
-
scope_1.add(:method, 'method_1', true)
|
|
89
|
-
scope_2.add(:method, 'method_2', true)
|
|
90
|
-
|
|
91
|
-
scope_3 = RubyLint::Definition.new([scope_1, scope_2])
|
|
92
|
-
|
|
93
|
-
scope_3.lookup(:method, 'method_1').should == true
|
|
94
|
-
scope_3.lookup(:method, 'method_2').should == true
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe 'RubyLint::Formatter::Text' do
|
|
4
|
-
it 'Format a report in plain text' do
|
|
5
|
-
report_a = RubyLint::Report.new('a.rb')
|
|
6
|
-
report_b = RubyLint::Report.new('b.rb')
|
|
7
|
-
formatter = RubyLint::Formatter::Text.new
|
|
8
|
-
|
|
9
|
-
report_a.add(:info, 'test info', 2, 1)
|
|
10
|
-
|
|
11
|
-
report_b.add(:error, 'test error', 1, 1)
|
|
12
|
-
report_b.add(:info, 'test info b.rb', 3, 1)
|
|
13
|
-
|
|
14
|
-
output_a = 'a.rb: info: line 2, column 1: test info'
|
|
15
|
-
output_b = "b.rb: error: line 1, column 1: test error\n" \
|
|
16
|
-
'b.rb: info: line 3, column 1: test info b.rb'
|
|
17
|
-
|
|
18
|
-
formatter.format(report_a).should == output_a
|
|
19
|
-
formatter.format(report_b).should == output_b
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe 'RubyLint::Parser' do
|
|
4
|
-
it 'Parse an Array' do
|
|
5
|
-
token = RubyLint::Parser.new('[10, 20]').parse[0]
|
|
6
|
-
|
|
7
|
-
token.class.should == RubyLint::Token::Token
|
|
8
|
-
token.type.should == :array
|
|
9
|
-
|
|
10
|
-
token.value.class.should == Array
|
|
11
|
-
token.value.length.should == 2
|
|
12
|
-
|
|
13
|
-
token.line.should == 1
|
|
14
|
-
token.column.should == 8
|
|
15
|
-
token.code.should == '[10, 20]'
|
|
16
|
-
|
|
17
|
-
token.value[0].class.should == RubyLint::Token::Token
|
|
18
|
-
token.value[0].type.should == :integer
|
|
19
|
-
token.value[0].value.should == '10'
|
|
20
|
-
|
|
21
|
-
token.value[1].class.should == RubyLint::Token::Token
|
|
22
|
-
token.value[1].type.should == :integer
|
|
23
|
-
token.value[1].value.should == '20'
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'Parse an Array using %w{}' do
|
|
27
|
-
token = RubyLint::Parser.new('%w{10 20}').parse[0]
|
|
28
|
-
|
|
29
|
-
token.class.should == RubyLint::Token::Token
|
|
30
|
-
token.type.should == :array
|
|
31
|
-
|
|
32
|
-
token.value.class.should == Array
|
|
33
|
-
token.value.length.should == 2
|
|
34
|
-
|
|
35
|
-
token.line.should == 1
|
|
36
|
-
token.column.should == 9
|
|
37
|
-
token.code.should == '%w{10 20}'
|
|
38
|
-
|
|
39
|
-
token.value[0].class.should == RubyLint::Token::Token
|
|
40
|
-
token.value[0].type.should == :string
|
|
41
|
-
token.value[0].value.should == '10'
|
|
42
|
-
|
|
43
|
-
token.value[1].class.should == RubyLint::Token::Token
|
|
44
|
-
token.value[1].type.should == :string
|
|
45
|
-
token.value[1].value.should == '20'
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'Parse an Array using %W{}' do
|
|
49
|
-
token = RubyLint::Parser.new('%W{10 20}').parse[0]
|
|
50
|
-
|
|
51
|
-
token.class.should == RubyLint::Token::Token
|
|
52
|
-
token.type.should == :array
|
|
53
|
-
|
|
54
|
-
token.value.class.should == Array
|
|
55
|
-
token.value.length.should == 2
|
|
56
|
-
|
|
57
|
-
token.line.should == 1
|
|
58
|
-
token.column.should == 9
|
|
59
|
-
token.code.should == '%W{10 20}'
|
|
60
|
-
|
|
61
|
-
token.value[0].class.should == RubyLint::Token::Token
|
|
62
|
-
token.value[0].type.should == :string
|
|
63
|
-
token.value[0].value.should == '10'
|
|
64
|
-
|
|
65
|
-
token.value[1].class.should == RubyLint::Token::Token
|
|
66
|
-
token.value[1].type.should == :string
|
|
67
|
-
token.value[1].value.should == '20'
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'Parse an Array index reference' do
|
|
71
|
-
token = RubyLint::Parser.new("[10][0]").parse[0]
|
|
72
|
-
|
|
73
|
-
token.class.should == RubyLint::Token::Token
|
|
74
|
-
token.line.should == 1
|
|
75
|
-
token.column.should == 4
|
|
76
|
-
token.code.should == '[10][0]'
|
|
77
|
-
|
|
78
|
-
token.key.class.should == Array
|
|
79
|
-
token.key.length.should == 1
|
|
80
|
-
|
|
81
|
-
token.key[0].class.should == RubyLint::Token::Token
|
|
82
|
-
token.key[0].type.should == :integer
|
|
83
|
-
token.key[0].value.should == '0'
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it 'Parse an Array index reference using a variable' do
|
|
87
|
-
token = RubyLint::Parser.new("numbers = [10]\nnumbers[0]").parse[1]
|
|
88
|
-
|
|
89
|
-
token.class.should == RubyLint::Token::VariableToken
|
|
90
|
-
token.line.should == 2
|
|
91
|
-
token.column.should == 0
|
|
92
|
-
token.name.should == 'numbers'
|
|
93
|
-
token.code.should == 'numbers[0]'
|
|
94
|
-
|
|
95
|
-
token.key.class.should == Array
|
|
96
|
-
token.key.length.should == 1
|
|
97
|
-
|
|
98
|
-
token.key[0].class.should == RubyLint::Token::Token
|
|
99
|
-
token.key[0].type.should == :integer
|
|
100
|
-
token.key[0].value.should == '0'
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it 'Parse multiple Array index references' do
|
|
104
|
-
token = RubyLint::Parser.new("numbers = [10]\nnumbers[0,1]").parse[1]
|
|
105
|
-
|
|
106
|
-
token.class.should == RubyLint::Token::VariableToken
|
|
107
|
-
token.line.should == 2
|
|
108
|
-
token.column.should == 0
|
|
109
|
-
token.name.should == 'numbers'
|
|
110
|
-
token.code.should == 'numbers[0,1]'
|
|
111
|
-
|
|
112
|
-
token.key.class.should == Array
|
|
113
|
-
token.key.length.should == 2
|
|
114
|
-
|
|
115
|
-
token.key[0].class.should == RubyLint::Token::Token
|
|
116
|
-
token.key[0].type.should == :integer
|
|
117
|
-
token.key[0].value.should == '0'
|
|
118
|
-
|
|
119
|
-
token.key[1].class.should == RubyLint::Token::Token
|
|
120
|
-
token.key[1].type.should == :integer
|
|
121
|
-
token.key[1].value.should == '1'
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it 'Parse the assignment of a value to an array index' do
|
|
125
|
-
token = RubyLint::Parser.new("numbers = []\nnumbers[0] = 10").parse[1]
|
|
126
|
-
|
|
127
|
-
token.class.should == RubyLint::Token::AssignmentToken
|
|
128
|
-
|
|
129
|
-
token.line.should == 2
|
|
130
|
-
token.column.should == 12
|
|
131
|
-
token.code.should == 'numbers[0] = 10'
|
|
132
|
-
|
|
133
|
-
token.value.class.should == RubyLint::Token::Token
|
|
134
|
-
token.value.type.should == :integer
|
|
135
|
-
token.value.value.should == '10'
|
|
136
|
-
|
|
137
|
-
token.receiver.class.should == RubyLint::Token::VariableToken
|
|
138
|
-
token.receiver.name.should == 'numbers'
|
|
139
|
-
|
|
140
|
-
token.receiver.key.class.should == Array
|
|
141
|
-
token.receiver.key.length.should == 1
|
|
142
|
-
|
|
143
|
-
token.receiver.key[0].class.should == RubyLint::Token::Token
|
|
144
|
-
token.receiver.key[0].type.should == :integer
|
|
145
|
-
token.receiver.key[0].value.should == '0'
|
|
146
|
-
end
|
|
147
|
-
end
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe 'Rlint::Parser' do
|
|
4
|
-
it 'Parse the assignment of a value to a local and * variable' do
|
|
5
|
-
ast = RubyLint::Parser.new('a, * = 10').parse[0]
|
|
6
|
-
|
|
7
|
-
ast.class.should == Array
|
|
8
|
-
ast.length.should == 1
|
|
9
|
-
|
|
10
|
-
token = ast[0]
|
|
11
|
-
|
|
12
|
-
token.class.should == RubyLint::Token::AssignmentToken
|
|
13
|
-
token.type.should == :local_variable
|
|
14
|
-
token.name.should == 'a'
|
|
15
|
-
|
|
16
|
-
token.value.class.should == RubyLint::Token::Token
|
|
17
|
-
token.value.type.should == :integer
|
|
18
|
-
token.value.value.should == '10'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'Parse a left hand expand assignment' do
|
|
22
|
-
tokens = RubyLint::Parser.new('*numbers = 10').parse[0]
|
|
23
|
-
|
|
24
|
-
tokens.class.should == Array
|
|
25
|
-
tokens.length.should == 1
|
|
26
|
-
|
|
27
|
-
token = tokens[0]
|
|
28
|
-
|
|
29
|
-
token.class.should == RubyLint::Token::AssignmentToken
|
|
30
|
-
token.type.should == :local_variable
|
|
31
|
-
token.expand.should == true
|
|
32
|
-
token.name.should == 'numbers'
|
|
33
|
-
|
|
34
|
-
token.value.class.should == RubyLint::Token::Token
|
|
35
|
-
token.value.type.should == :array
|
|
36
|
-
|
|
37
|
-
token.value.value.class.should == Array
|
|
38
|
-
token.value.value.length.should == 1
|
|
39
|
-
|
|
40
|
-
val = token.value.value[0]
|
|
41
|
-
|
|
42
|
-
val.class.should == RubyLint::Token::Token
|
|
43
|
-
val.type.should == :integer
|
|
44
|
-
val.value.should == '10'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'Parse a left hand expand and local variable assignment' do
|
|
48
|
-
tokens = RubyLint::Parser.new('number, *numbers = 10').parse[0]
|
|
49
|
-
|
|
50
|
-
tokens.class.should == Array
|
|
51
|
-
tokens.length.should == 2
|
|
52
|
-
|
|
53
|
-
number = tokens[0]
|
|
54
|
-
numbers = tokens[1]
|
|
55
|
-
|
|
56
|
-
number.class.should == RubyLint::Token::AssignmentToken
|
|
57
|
-
number.name.should == 'number'
|
|
58
|
-
number.type.should == :local_variable
|
|
59
|
-
number.expand.should == false
|
|
60
|
-
|
|
61
|
-
number.value.class.should == RubyLint::Token::Token
|
|
62
|
-
number.value.type.should == :integer
|
|
63
|
-
number.value.value.should == '10'
|
|
64
|
-
|
|
65
|
-
numbers.class.should == RubyLint::Token::AssignmentToken
|
|
66
|
-
numbers.name.should == 'numbers'
|
|
67
|
-
numbers.type.should == :local_variable
|
|
68
|
-
numbers.expand.should == true
|
|
69
|
-
|
|
70
|
-
numbers.value.class.should == RubyLint::Token::Token
|
|
71
|
-
numbers.value.type.should == :array
|
|
72
|
-
numbers.value.value.length.should == 0
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'Parse a mass assignment using an expand variable on the left' do
|
|
76
|
-
tokens = RubyLint::Parser.new('*numbers, number, numberx = 10').parse[0]
|
|
77
|
-
|
|
78
|
-
tokens.class.should == Array
|
|
79
|
-
tokens.length.should == 3
|
|
80
|
-
|
|
81
|
-
numbers = tokens[0]
|
|
82
|
-
number = tokens[1]
|
|
83
|
-
numberx = tokens[2]
|
|
84
|
-
|
|
85
|
-
numbers.class.should == RubyLint::Token::AssignmentToken
|
|
86
|
-
numbers.name.should == 'numbers'
|
|
87
|
-
numbers.type.should == :local_variable
|
|
88
|
-
numbers.expand.should == true
|
|
89
|
-
|
|
90
|
-
numbers.value.class.should == RubyLint::Token::Token
|
|
91
|
-
numbers.value.type.should == :array
|
|
92
|
-
numbers.value.value.class.should == Array
|
|
93
|
-
numbers.value.value.length.should == 0
|
|
94
|
-
|
|
95
|
-
number.class.should == RubyLint::Token::AssignmentToken
|
|
96
|
-
number.name.should == 'number'
|
|
97
|
-
number.type.should == :local_variable
|
|
98
|
-
number.expand.should == false
|
|
99
|
-
|
|
100
|
-
number.value.class.should == RubyLint::Token::Token
|
|
101
|
-
number.value.type.should == :integer
|
|
102
|
-
number.value.value.should == '10'
|
|
103
|
-
|
|
104
|
-
numberx.class.should == RubyLint::Token::AssignmentToken
|
|
105
|
-
numberx.name.should == 'numberx'
|
|
106
|
-
numberx.type.should == :local_variable
|
|
107
|
-
numberx.expand.should == false
|
|
108
|
-
|
|
109
|
-
numberx.value.nil?.should == true
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it 'Parse the assignment of 2 values to 2 variables using an expander' do
|
|
113
|
-
tokens = RubyLint::Parser.new('*numbers, number = 10, 20').parse[0]
|
|
114
|
-
|
|
115
|
-
tokens.class.should == Array
|
|
116
|
-
tokens.length.should == 2
|
|
117
|
-
|
|
118
|
-
numbers = tokens[0]
|
|
119
|
-
number = tokens[1]
|
|
120
|
-
|
|
121
|
-
numbers.class.should == RubyLint::Token::AssignmentToken
|
|
122
|
-
numbers.name.should == 'numbers'
|
|
123
|
-
numbers.type.should == :local_variable
|
|
124
|
-
|
|
125
|
-
numbers.value.class.should == RubyLint::Token::Token
|
|
126
|
-
numbers.value.type.should == :array
|
|
127
|
-
|
|
128
|
-
numbers.value.value.class.should == Array
|
|
129
|
-
numbers.value.value.length.should == 1
|
|
130
|
-
|
|
131
|
-
numbers_val = numbers.value.value[0]
|
|
132
|
-
|
|
133
|
-
numbers_val.class.should == RubyLint::Token::Token
|
|
134
|
-
numbers_val.type.should == :integer
|
|
135
|
-
numbers_val.value.should == '10'
|
|
136
|
-
|
|
137
|
-
number.class.should == RubyLint::Token::AssignmentToken
|
|
138
|
-
number.name.should == 'number'
|
|
139
|
-
number.type.should == :local_variable
|
|
140
|
-
|
|
141
|
-
number.value.class.should == RubyLint::Token::Token
|
|
142
|
-
number.value.type.should == :integer
|
|
143
|
-
number.value.value.should == '20'
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it 'Parse the assignment of 2 values to 3 variables using an expander' do
|
|
147
|
-
tokens = RubyLint::Parser.new('*numbers, number, numberx = 10, 20') \
|
|
148
|
-
.parse[0]
|
|
149
|
-
|
|
150
|
-
tokens.class.should == Array
|
|
151
|
-
tokens.length.should == 3
|
|
152
|
-
|
|
153
|
-
numbers = tokens[0]
|
|
154
|
-
number = tokens[1]
|
|
155
|
-
numberx = tokens[2]
|
|
156
|
-
|
|
157
|
-
numbers.class.should == RubyLint::Token::AssignmentToken
|
|
158
|
-
numbers.name.should == 'numbers'
|
|
159
|
-
numbers.type.should == :local_variable
|
|
160
|
-
|
|
161
|
-
numbers.value.class.should == RubyLint::Token::Token
|
|
162
|
-
numbers.value.type.should == :array
|
|
163
|
-
|
|
164
|
-
numbers.value.value.class.should == Array
|
|
165
|
-
numbers.value.value.length.should == 0
|
|
166
|
-
|
|
167
|
-
number.class.should == RubyLint::Token::AssignmentToken
|
|
168
|
-
number.name.should == 'number'
|
|
169
|
-
number.type.should == :local_variable
|
|
170
|
-
|
|
171
|
-
number.value.class.should == RubyLint::Token::Token
|
|
172
|
-
number.value.type.should == :integer
|
|
173
|
-
number.value.value.should == '10'
|
|
174
|
-
|
|
175
|
-
numberx.class.should == RubyLint::Token::AssignmentToken
|
|
176
|
-
numberx.name.should == 'numberx'
|
|
177
|
-
numberx.type.should == :local_variable
|
|
178
|
-
|
|
179
|
-
numberx.value.class.should == RubyLint::Token::Token
|
|
180
|
-
numberx.value.type.should == :integer
|
|
181
|
-
numberx.value.value.should == '20'
|
|
182
|
-
end
|
|
183
|
-
end
|