ruby-lint 1.1.0 → 2.0.0

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.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +43 -29
  3. data/LICENSE +1 -1
  4. data/README.md +0 -1
  5. data/bin/ruby-lint +91 -3
  6. data/checksum/ruby-lint-1.1.0.gem.sha512 +1 -0
  7. data/doc/changelog.md +30 -0
  8. data/doc/code_analysis.md +13 -0
  9. data/doc/configuration.md +5 -24
  10. data/lib/ruby-lint.rb +7 -10
  11. data/lib/ruby-lint/analysis/argument_amount.rb +2 -0
  12. data/lib/ruby-lint/analysis/base.rb +12 -0
  13. data/lib/ruby-lint/analysis/pedantics.rb +2 -0
  14. data/lib/ruby-lint/analysis/shadowing_variables.rb +2 -0
  15. data/lib/ruby-lint/analysis/undefined_methods.rb +5 -2
  16. data/lib/ruby-lint/analysis/undefined_variables.rb +2 -0
  17. data/lib/ruby-lint/analysis/unused_variables.rb +2 -0
  18. data/lib/ruby-lint/analysis/useless_equality_checks.rb +2 -0
  19. data/lib/ruby-lint/ast/node.rb +0 -15
  20. data/lib/ruby-lint/command.rb +100 -0
  21. data/lib/ruby-lint/configuration.rb +35 -66
  22. data/lib/ruby-lint/constant_path.rb +7 -2
  23. data/lib/ruby-lint/definition/ruby_object.rb +20 -6
  24. data/lib/ruby-lint/definitions/core/argf.rb +3 -3
  25. data/lib/ruby-lint/definitions/gems/minitest.rb +792 -0
  26. data/lib/ruby-lint/file_list.rb +1 -1
  27. data/lib/ruby-lint/file_loader.rb +2 -20
  28. data/lib/ruby-lint/file_scanner.rb +11 -2
  29. data/lib/ruby-lint/method_evaluation.rb +21 -0
  30. data/lib/ruby-lint/presenter/base.rb +18 -0
  31. data/lib/ruby-lint/presenter/json.rb +3 -1
  32. data/lib/ruby-lint/presenter/syntastic.rb +3 -1
  33. data/lib/ruby-lint/presenter/text.rb +3 -1
  34. data/lib/ruby-lint/runner.rb +6 -63
  35. data/lib/ruby-lint/variable_predicates.rb +3 -3
  36. data/lib/ruby-lint/version.rb +1 -1
  37. data/lib/ruby-lint/virtual_machine.rb +4 -1
  38. data/ruby-lint.gemspec +13 -4
  39. metadata +12 -187
  40. data/.editorconfig +0 -15
  41. data/.gitignore +0 -6
  42. data/.ruby-version +0 -1
  43. data/.travis.yml +0 -19
  44. data/Gemfile +0 -15
  45. data/MANIFEST +0 -469
  46. data/Rakefile +0 -25
  47. data/benchmark/bootup.rb +0 -13
  48. data/benchmark/virtual_machine.rb +0 -17
  49. data/checksum/.gitkeep +0 -0
  50. data/doc/.gitkeep +0 -0
  51. data/doc/css/.gitkeep +0 -0
  52. data/doc/images/.gitkeep +0 -0
  53. data/gen/rails/constants.txt +0 -12
  54. data/gen/rails/requires.rb +0 -2
  55. data/gen/stdlib/constants.rb +0 -30
  56. data/gen/stdlib/constants.txt +0 -214
  57. data/gen/stdlib/requires.rb +0 -64
  58. data/lib/ruby-lint/benchmark/average.rb +0 -115
  59. data/lib/ruby-lint/cache.rb +0 -121
  60. data/lib/ruby-lint/cache_entry.rb +0 -44
  61. data/lib/ruby-lint/cli.rb +0 -4
  62. data/lib/ruby-lint/cli/analyze.rb +0 -209
  63. data/lib/ruby-lint/cli/base.rb +0 -103
  64. data/lib/ruby-lint/cli/cache.rb +0 -60
  65. data/lib/ruby-lint/default_names.rb +0 -19
  66. data/lib/ruby-lint/definitions/gems/.gitkeep +0 -0
  67. data/lib/ruby-lint/node_hash.rb +0 -105
  68. data/misc/stdlib.rb +0 -66
  69. data/profiling/virtual_machine.rb +0 -20
  70. data/ruby-lint.yml +0 -7
  71. data/spec/fixtures/associating.rb +0 -7
  72. data/spec/fixtures/complex/rails/basic_controller.rb +0 -9
  73. data/spec/fixtures/complex/rcap.rb +0 -67
  74. data/spec/fixtures/complex/slop.rb +0 -701
  75. data/spec/fixtures/config.yml +0 -8
  76. data/spec/fixtures/deeply/nested/file.rb +0 -1
  77. data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +0 -6
  78. data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +0 -8
  79. data/spec/fixtures/file_scanner/lib/example/user.rb +0 -6
  80. data/spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb +0 -6
  81. data/spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb +0 -6
  82. data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +0 -4
  83. data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +0 -6
  84. data/spec/fixtures/file_scanner/rails/app/models/user.rb +0 -4
  85. data/spec/fixtures/invalid.rb +0 -3
  86. data/spec/fixtures/invalid_2.rb +0 -3
  87. data/spec/fixtures/syntax_error.rb +0 -1
  88. data/spec/fixtures/uses_external.rb +0 -1
  89. data/spec/fixtures/uses_external_invalid.rb +0 -3
  90. data/spec/fixtures/uses_external_namespace.rb +0 -1
  91. data/spec/fixtures/valid.rb +0 -3
  92. data/spec/ruby-lint/analysis/argument_amount_spec.rb +0 -131
  93. data/spec/ruby-lint/analysis/base_spec.rb +0 -24
  94. data/spec/ruby-lint/analysis/pedantics_spec.rb +0 -63
  95. data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +0 -85
  96. data/spec/ruby-lint/analysis/undefined_methods_spec.rb +0 -337
  97. data/spec/ruby-lint/analysis/undefined_variables_spec.rb +0 -138
  98. data/spec/ruby-lint/analysis/unused_variables_spec.rb +0 -270
  99. data/spec/ruby-lint/analysis/useless_equality_checks_spec.rb +0 -107
  100. data/spec/ruby-lint/ast/node_spec.rb +0 -39
  101. data/spec/ruby-lint/cache_entry_spec.rb +0 -25
  102. data/spec/ruby-lint/cache_spec.rb +0 -53
  103. data/spec/ruby-lint/cli/analyze_spec.rb +0 -52
  104. data/spec/ruby-lint/configuration_spec.rb +0 -126
  105. data/spec/ruby-lint/constant_loader_spec.rb +0 -79
  106. data/spec/ruby-lint/constant_path.rb +0 -63
  107. data/spec/ruby-lint/definition/constant_proxy_spec.rb +0 -85
  108. data/spec/ruby-lint/definition/dsl_spec.rb +0 -135
  109. data/spec/ruby-lint/definition/registry_spec.rb +0 -106
  110. data/spec/ruby-lint/definition/ruby_method_spec.rb +0 -106
  111. data/spec/ruby-lint/definition/ruby_object_spec.rb +0 -264
  112. data/spec/ruby-lint/definition_builder/primitive_spec.rb +0 -62
  113. data/spec/ruby-lint/definition_builder/ruby_class_spec.rb +0 -107
  114. data/spec/ruby-lint/definition_builder/ruby_method_spec.rb +0 -53
  115. data/spec/ruby-lint/definition_builder/ruby_module_spec.rb +0 -52
  116. data/spec/ruby-lint/definitions/argv_spec.rb +0 -18
  117. data/spec/ruby-lint/definitions/env_spec.rb +0 -13
  118. data/spec/ruby-lint/definitions/file_spec.rb +0 -17
  119. data/spec/ruby-lint/definitions/fixnum_spec.rb +0 -18
  120. data/spec/ruby-lint/definitions/io_spec.rb +0 -15
  121. data/spec/ruby-lint/definitions/kernel_spec.rb +0 -18
  122. data/spec/ruby-lint/definitions/range_spec.rb +0 -21
  123. data/spec/ruby-lint/definitions/string_spec.rb +0 -20
  124. data/spec/ruby-lint/docstring/mapping.rb +0 -27
  125. data/spec/ruby-lint/docstring/parser_spec.rb +0 -88
  126. data/spec/ruby-lint/extensions/string_spec.rb +0 -7
  127. data/spec/ruby-lint/file_list_spec.rb +0 -25
  128. data/spec/ruby-lint/file_loader_spec.rb +0 -69
  129. data/spec/ruby-lint/file_scanner_spec.rb +0 -84
  130. data/spec/ruby-lint/inspector_spec.rb +0 -224
  131. data/spec/ruby-lint/iterator_spec.rb +0 -151
  132. data/spec/ruby-lint/method_call/.gitkeep +0 -0
  133. data/spec/ruby-lint/nested_stack_spec.rb +0 -23
  134. data/spec/ruby-lint/node_hash_spec.rb +0 -56
  135. data/spec/ruby-lint/parser_spec.rb +0 -38
  136. data/spec/ruby-lint/presenter/json_spec.rb +0 -58
  137. data/spec/ruby-lint/presenter/syntastic_spec.rb +0 -49
  138. data/spec/ruby-lint/presenter/text_spec.rb +0 -49
  139. data/spec/ruby-lint/report/entry_spec.rb +0 -58
  140. data/spec/ruby-lint/report_spec.rb +0 -39
  141. data/spec/ruby-lint/runner_spec.rb +0 -74
  142. data/spec/ruby-lint/variable_predicates_spec.rb +0 -30
  143. data/spec/ruby-lint/virtual_machine/alias_spec.rb +0 -55
  144. data/spec/ruby-lint/virtual_machine/assignments/arrays_spec.rb +0 -87
  145. data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +0 -14
  146. data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +0 -23
  147. data/spec/ruby-lint/virtual_machine/assignments/hashes_spec.rb +0 -52
  148. data/spec/ruby-lint/virtual_machine/assignments/optional_spec.rb +0 -41
  149. data/spec/ruby-lint/virtual_machine/assignments/range_spec.rb +0 -28
  150. data/spec/ruby-lint/virtual_machine/assignments/return_values_spec.rb +0 -78
  151. data/spec/ruby-lint/virtual_machine/assignments/variables_spec.rb +0 -130
  152. data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +0 -61
  153. data/spec/ruby-lint/virtual_machine/autoloading_spec.rb +0 -18
  154. data/spec/ruby-lint/virtual_machine/blocks_spec.rb +0 -90
  155. data/spec/ruby-lint/virtual_machine/classes/class_methods_spec.rb +0 -21
  156. data/spec/ruby-lint/virtual_machine/classes/extending_spec.rb +0 -109
  157. data/spec/ruby-lint/virtual_machine/classes/redefining_spec.rb +0 -51
  158. data/spec/ruby-lint/virtual_machine/classes/sclass_spec.rb +0 -96
  159. data/spec/ruby-lint/virtual_machine/classes/scoping_spec.rb +0 -60
  160. data/spec/ruby-lint/virtual_machine/complex/rails_spec.rb +0 -21
  161. data/spec/ruby-lint/virtual_machine/complex/rcap_spec.rb +0 -15
  162. data/spec/ruby-lint/virtual_machine/complex/slop_spec.rb +0 -16
  163. data/spec/ruby-lint/virtual_machine/constants_spec.rb +0 -31
  164. data/spec/ruby-lint/virtual_machine/for_spec.rb +0 -16
  165. data/spec/ruby-lint/virtual_machine/freeze_spec.rb +0 -13
  166. data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +0 -15
  167. data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +0 -15
  168. data/spec/ruby-lint/virtual_machine/interpolation_spec.rb +0 -12
  169. data/spec/ruby-lint/virtual_machine/location_spec.rb +0 -64
  170. data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +0 -57
  171. data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +0 -182
  172. data/spec/ruby-lint/virtual_machine/methods/calls_spec.rb +0 -25
  173. data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +0 -41
  174. data/spec/ruby-lint/virtual_machine/methods/defining_spec.rb +0 -40
  175. data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +0 -80
  176. data/spec/ruby-lint/virtual_machine/methods/exporting_spec.rb +0 -19
  177. data/spec/ruby-lint/virtual_machine/methods/kernel_spec.rb +0 -25
  178. data/spec/ruby-lint/virtual_machine/methods/parameters_spec.rb +0 -89
  179. data/spec/ruby-lint/virtual_machine/methods/patching_spec.rb +0 -20
  180. data/spec/ruby-lint/virtual_machine/methods/scoping_spec.rb +0 -63
  181. data/spec/ruby-lint/virtual_machine/methods/square_bracket_spec.rb +0 -32
  182. data/spec/ruby-lint/virtual_machine/methods/visibility_spec.rb +0 -64
  183. data/spec/ruby-lint/virtual_machine/modules_spec.rb +0 -205
  184. data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +0 -81
  185. data/spec/ruby-lint/virtual_machine/self_spec.rb +0 -37
  186. data/spec/ruby-lint/virtual_machine/unused_spec.rb +0 -17
  187. data/spec/spec_helper.rb +0 -28
  188. data/spec/support/building.rb +0 -50
  189. data/spec/support/coveralls.rb +0 -5
  190. data/spec/support/definitions.rb +0 -39
  191. data/spec/support/fixtures.rb +0 -20
  192. data/spec/support/parsing.rb +0 -30
  193. data/spec/support/simplecov.rb +0 -18
  194. data/spec/support/versions.rb +0 -9
  195. data/task/build.rake +0 -4
  196. data/task/checksum.rake +0 -13
  197. data/task/coverage.rake +0 -6
  198. data/task/doc.rake +0 -16
  199. data/task/generate.rake +0 -77
  200. data/task/graphviz.rake +0 -12
  201. data/task/manifest.rake +0 -8
  202. data/task/tag.rake +0 -6
  203. data/task/test.rake +0 -4
  204. data/task/todo.rake +0 -6
  205. data/task/travis.rake +0 -8
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'redefining classes' do
5
- example 'update a class when it is redefined' do
6
- code = <<-CODE
7
- class First
8
- end
9
-
10
- class First
11
- def example
12
- end
13
- end
14
- CODE
15
-
16
- defs = build_definitions(code)
17
-
18
- defs.lookup(:const, 'First') \
19
- .lookup(:instance_method, 'example') \
20
- .is_a?(ruby_method) \
21
- .should == true
22
- end
23
-
24
- context 'updating built-in definitions' do
25
- before :all do
26
- code = <<-CODE
27
- class Integer < Numeric
28
- def foobar
29
- end
30
- end
31
- CODE
32
-
33
- defs = build_definitions(code)
34
- @integer = defs.lookup(:const, 'Integer')
35
- @fixnum = defs.lookup(:const, 'Fixnum')
36
- end
37
-
38
- example 'include newly defined methods' do
39
- @integer.has_definition?(:instance_method, 'foobar').should == true
40
- end
41
-
42
- example 'include existing methods' do
43
- @integer.has_definition?(:instance_method, '%').should == true
44
- end
45
-
46
- example 'update definitions that point to the redefined definition' do
47
- @fixnum.has_definition?(:instance_method, 'foobar').should == true
48
- end
49
- end
50
- end
51
- end
@@ -1,96 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'using sclass blocks' do
5
- example 'define a class method using `class << self`' do
6
- code = <<-CODE
7
- class First
8
- class << self
9
- def example
10
- end
11
- end
12
- end
13
- CODE
14
-
15
- defs = build_definitions(code)
16
-
17
- defs.lookup(:const, 'First') \
18
- .lookup(:method, 'example') \
19
- .is_a?(ruby_method) \
20
- .should == true
21
- end
22
-
23
- example 'define an instance method using `class << self` in the global scope' do
24
- code = <<-CODE
25
- class << self
26
- def example
27
- end
28
- end
29
- CODE
30
-
31
- defs = build_definitions(code)
32
-
33
- defs.lookup(:instance_method, 'example')
34
- .is_a?(ruby_method)
35
- .should == true
36
- end
37
-
38
- example 'define a class method using `class << String`' do
39
- code = <<-CODE
40
- class << String
41
- def example
42
- end
43
- end
44
- CODE
45
-
46
- defs = build_definitions(code)
47
-
48
- defs.lookup(:const, 'String') \
49
- .lookup(:method, 'example') \
50
- .is_a?(ruby_method) \
51
- .should == true
52
- end
53
-
54
- example 'define a class method using `class << String` nested in a class' do
55
- code = <<-CODE
56
- class First
57
- class << String
58
- def example
59
- end
60
- end
61
- end
62
- CODE
63
-
64
- defs = build_definitions(code)
65
-
66
- defs.lookup(:const, 'First') \
67
- .lookup(:method, 'example') \
68
- .is_a?(ruby_method) \
69
- .should == false
70
-
71
- defs.lookup(:const, 'String') \
72
- .lookup(:method, 'example') \
73
- .is_a?(ruby_method) \
74
- .should == true
75
- end
76
-
77
- example 'define an instance method using `class << variable`' do
78
- code = <<-CODE
79
- variable = "foo"
80
-
81
- class << variable
82
- def example
83
- end
84
- end
85
- CODE
86
-
87
- defs = build_definitions(code)
88
-
89
- defs.lookup(:lvar, 'variable') \
90
- .value \
91
- .lookup(:instance_method, 'example') \
92
- .is_a?(ruby_object) \
93
- .should == true
94
- end
95
- end
96
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'scoping class definitions' do
5
- example 'process a global class' do
6
- defs = build_definitions('class Example; end')
7
- example = defs.lookup(:const, 'Example')
8
-
9
- example.is_a?(ruby_object).should == true
10
-
11
- example.type.should == :const
12
- example.name.should == 'Example'
13
- end
14
-
15
- example 'process a nested class' do
16
- code = <<-CODE
17
- class First
18
- class Second
19
- end
20
- end
21
- CODE
22
-
23
- defs = build_definitions(code)
24
- first = defs.lookup(:const, 'First')
25
-
26
- first.is_a?(ruby_object).should == true
27
-
28
- defs.lookup(:const, 'Second').nil?.should == true
29
-
30
- first.lookup(:const, 'Second') \
31
- .is_a?(ruby_object) \
32
- .should == true
33
- end
34
-
35
- example 'process a global and nested class' do
36
- code = <<-CODE
37
- class First
38
- class Second
39
- end
40
- end
41
-
42
- class Third
43
- end
44
- CODE
45
-
46
- defs = build_definitions(code)
47
- first = defs.lookup(:const, 'First')
48
-
49
- first.lookup(:const, 'Second').is_a?(ruby_object).should == true
50
- first.lookup(:const, 'Third').is_a?(ruby_object).should == true
51
-
52
- first.lookup(:const, 'Second') \
53
- .lookup(:const, 'Third') \
54
- .is_a?(ruby_object) \
55
- .should == true
56
-
57
- defs.lookup(:const, 'Third').is_a?(ruby_object).should == true
58
- end
59
- end
60
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'rails' do
5
- before :all do
6
- code = fixture('complex/rails/basic_controller.rb')
7
- @defs = build_definitions(code)
8
- @controller = @defs.lookup(:const, 'ApplicationController')
9
- end
10
-
11
- example 'inherit the parent controller' do
12
- @controller.has_definition?(:instance_method, 'login_required')
13
- .should == true
14
- end
15
-
16
- example 'include built-in Rails definitions' do
17
- @controller.has_definition?(:method, 'allow_forgery_protection')
18
- .should == true
19
- end
20
- end
21
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- # https://github.com/farrel/RCAP/blob/master/lib/rcap/cap_1_2/alert.rb
5
- describe 'rcap' do
6
- example 'process the Alert class' do
7
- code = fixture('complex/rcap.rb')
8
- defs = build_definitions(code)
9
- const = defs.lookup_constant_path('RCAP::CAP_1_2::Alert')
10
-
11
- const.lookup(:const, 'CAP_VERSION').value.value.should == '1.2'
12
- const.has_definition?(:instance_method, 'xmlns').should == true
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'slop' do
5
- example 'process the Slop gem' do
6
- code = fixture('complex/slop.rb')
7
- defs = build_definitions(code)
8
- const = defs.lookup(:const, 'Slop')
9
-
10
- const.lookup(:const, 'VERSION').value.value.should == '3.4.5'
11
-
12
- const.has_definition?(:method, 'parse').should == true
13
- const.has_definition?(:method, 'parse!').should == true
14
- end
15
- end
16
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- context 'generic constants' do
5
- # These tests are put in place to ensure that a class/module can refer to
6
- # itself without having to look anything up in parent scopes. An example:
7
- #
8
- # class Foo
9
- # Foo # => points to the class
10
- # end
11
- #
12
- example 'add the constant to itself' do
13
- code = <<-CODE
14
- module A
15
- end
16
-
17
- class B
18
- end
19
- CODE
20
-
21
- defs = build_definitions(code)
22
- mod = defs.lookup(:const, 'A')
23
- klass = defs.lookup(:const, 'B')
24
-
25
- # `lookup_parent` is set to false to ensure that the code doesn't use
26
- # parent scopes to find the constant.
27
- mod.lookup(:const, 'A', false).should == mod
28
- klass.lookup(:const, 'B', false).should == klass
29
- end
30
- end
31
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Building variable definitions using for loops' do
4
- example 'create local variables' do
5
- code = <<-CODE
6
- for key, value in something
7
-
8
- end
9
- CODE
10
-
11
- defs = build_definitions(code)
12
-
13
- defs.lookup(:lvar, 'key').is_a?(ruby_object).should == true
14
- defs.lookup(:lvar, 'value').is_a?(ruby_object).should == true
15
- end
16
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- example 'freeze the VM and all instance variables' do
5
- vm = RubyLint::VirtualMachine.new
6
-
7
- vm.freeze
8
-
9
- vm.frozen?.should == true
10
- vm.definitions.frozen?.should == true
11
- vm.associations.frozen?.should == true
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'global variables' do
5
- before :all do
6
- @vm = RubyLint::VirtualMachine.new
7
- @defs = @vm.definitions
8
- end
9
-
10
- example 'provide a list of default global variables' do
11
- @defs.lookup(:gvar, '$LOAD_PATH').is_a?(ruby_object).should == true
12
- @defs.lookup(:gvar, '$9').is_a?(ruby_object).should == true
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- context 'inheriting definitions using modules' do
5
- example 'modules should inherit from Kernel' do
6
- code = 'module Foo; end'
7
- defs = build_definitions(code)
8
-
9
- defs.lookup(:const, 'Foo')
10
- .lookup(:method, 'alias_method')
11
- .is_a?(ruby_method)
12
- .should == true
13
- end
14
- end
15
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- describe 'string interpolation' do
5
- example 'process an assignment in a string' do
6
- code = '"hello #{number = 10}"'
7
- defs = build_definitions(code)
8
-
9
- defs.lookup(:lvar, 'number').value.value.should == 10
10
- end
11
- end
12
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- context 'definition location information' do
5
- example 'store location information of a class' do
6
- code = <<-CODE
7
- # Example class.
8
- class Example
9
- end
10
- CODE
11
-
12
- defs = build_definitions(code)
13
- obj = defs.lookup(:const, 'Example')
14
-
15
- obj.line.should == 2
16
- obj.column.should == 1
17
- obj.file.should == '(ruby-lint)'
18
- end
19
-
20
- example 'store location information of a module' do
21
- code = <<-CODE
22
- # Example module.
23
- module Example
24
- end
25
- CODE
26
-
27
- defs = build_definitions(code)
28
- obj = defs.lookup(:const, 'Example')
29
-
30
- obj.line.should == 2
31
- obj.column.should == 1
32
- obj.file.should == '(ruby-lint)'
33
- end
34
-
35
- example 'store location information of a method' do
36
- code = <<-CODE
37
- # Example module.
38
- def example
39
- end
40
- CODE
41
-
42
- defs = build_definitions(code)
43
- obj = defs.lookup(:instance_method, 'example')
44
-
45
- obj.line.should == 2
46
- obj.column.should == 1
47
- obj.file.should == '(ruby-lint)'
48
- end
49
-
50
- example 'store location information of a variable' do
51
- code = <<-CODE
52
- # Example assignment
53
- number = 10
54
- CODE
55
-
56
- defs = build_definitions(code)
57
- obj = defs.lookup(:lvar, 'number')
58
-
59
- obj.line.should == 2
60
- obj.column.should == 1
61
- obj.file.should == '(ruby-lint)'
62
- end
63
- end
64
- end
@@ -1,57 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::VirtualMachine do
4
- context 'method call tracking' do
5
- before :all do
6
- code = <<-CODE
7
- def first_method
8
- end
9
-
10
- def second_method
11
- end
12
-
13
- def third_method
14
- first_method
15
- second_method
16
- String.new
17
- end
18
- CODE
19
-
20
- definitions = build_definitions(code)
21
- @first = definitions.lookup(:instance_method, 'first_method')
22
- @second = definitions.lookup(:instance_method, 'second_method')
23
- @third = definitions.lookup(:instance_method, 'third_method')
24
- @string = definitions.lookup(:const, 'String')
25
- end
26
-
27
- example 'track the right amount of method calls' do
28
- @third.calls.length.should == 3
29
- end
30
-
31
- example 'track call location information' do
32
- @third.calls[0].line.should == 8
33
- @third.calls[0].column.should == 3
34
-
35
- @third.calls[1].line.should == 9
36
- @third.calls[1].column.should == 3
37
- end
38
-
39
- example 'track the call definitions' do
40
- @third.calls[0].definition.should == @first
41
- @third.calls[1].definition.should == @second
42
- end
43
-
44
- example 'track call location information in inverse direction' do
45
- @first.callers[0].line.should == 8
46
- @first.callers[0].column.should == 3
47
-
48
- @second.callers[0].line.should == 9
49
- @second.callers[0].column.should == 3
50
- end
51
-
52
- example 'track method calls in inverse direction' do
53
- @first.callers[0].definition.should == @third
54
- @second.callers[0].definition.should == @third
55
- end
56
- end
57
- end