ruby-lint 0.0.1a → 0.0.1a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.yardopts +1 -1
  2. data/MANIFEST +65 -62
  3. data/README.md +114 -13
  4. data/bin/ruby-lint +6 -0
  5. data/lib/ruby-lint.rb +36 -0
  6. data/lib/{rlint → ruby-lint}/analyze/coding_style.rb +32 -32
  7. data/lib/{rlint → ruby-lint}/analyze/definitions.rb +13 -13
  8. data/lib/{rlint → ruby-lint}/analyze/method_validation.rb +5 -5
  9. data/lib/{rlint → ruby-lint}/analyze/shadowing_variables.rb +5 -5
  10. data/lib/{rlint → ruby-lint}/analyze/undefined_variables.rb +7 -7
  11. data/lib/{rlint → ruby-lint}/analyze/unused_variables.rb +6 -6
  12. data/lib/{rlint → ruby-lint}/callback.rb +11 -11
  13. data/lib/{rlint → ruby-lint}/cli.rb +17 -17
  14. data/lib/{rlint → ruby-lint}/constant_importer.rb +18 -8
  15. data/lib/{rlint → ruby-lint}/definition.rb +10 -10
  16. data/lib/{rlint → ruby-lint}/formatter/text.rb +6 -6
  17. data/lib/{rlint → ruby-lint}/helper/definition_resolver.rb +11 -11
  18. data/lib/{rlint → ruby-lint}/helper/scoping.rb +14 -14
  19. data/lib/{rlint → ruby-lint}/iterator.rb +22 -22
  20. data/lib/{rlint → ruby-lint}/options.rb +9 -9
  21. data/lib/{rlint → ruby-lint}/parser.rb +111 -111
  22. data/lib/{rlint → ruby-lint}/parser_error.rb +3 -3
  23. data/lib/{rlint → ruby-lint}/report.rb +8 -8
  24. data/lib/{rlint → ruby-lint}/token/assignment_token.rb +4 -4
  25. data/lib/{rlint → ruby-lint}/token/begin_rescue_token.rb +7 -7
  26. data/lib/{rlint → ruby-lint}/token/block_token.rb +12 -3
  27. data/lib/{rlint → ruby-lint}/token/case_token.rb +5 -5
  28. data/lib/{rlint → ruby-lint}/token/class_token.rb +3 -3
  29. data/lib/{rlint → ruby-lint}/token/method_definition_token.rb +8 -8
  30. data/lib/{rlint → ruby-lint}/token/method_token.rb +9 -7
  31. data/lib/{rlint → ruby-lint}/token/parameters_token.rb +6 -6
  32. data/lib/{rlint → ruby-lint}/token/regexp_token.rb +2 -2
  33. data/lib/{rlint → ruby-lint}/token/statement_token.rb +6 -6
  34. data/lib/{rlint → ruby-lint}/token/token.rb +8 -6
  35. data/lib/{rlint → ruby-lint}/token/variable_token.rb +3 -3
  36. data/lib/ruby-lint/version.rb +3 -0
  37. data/ruby-lint.gemspec +5 -5
  38. data/spec/benchmarks/memory.rb +7 -7
  39. data/spec/benchmarks/parse_parser.rb +5 -5
  40. data/spec/fixtures/stdlib/un.rb +348 -0
  41. data/spec/helper.rb +3 -1
  42. data/spec/{rlint → ruby-lint}/analyze/coding_style.rb +30 -30
  43. data/spec/ruby-lint/analyze/complex/un.rb +29 -0
  44. data/spec/{rlint → ruby-lint}/analyze/definitions/classes.rb +25 -25
  45. data/spec/{rlint → ruby-lint}/analyze/definitions/methods.rb +22 -22
  46. data/spec/{rlint → ruby-lint}/analyze/definitions/modules.rb +42 -42
  47. data/spec/{rlint → ruby-lint}/analyze/definitions/variables.rb +27 -27
  48. data/spec/{rlint → ruby-lint}/analyze/method_validation.rb +31 -31
  49. data/spec/{rlint → ruby-lint}/analyze/shadowing_variables.rb +6 -6
  50. data/spec/{rlint → ruby-lint}/analyze/undefined_variables.rb +37 -37
  51. data/spec/{rlint → ruby-lint}/analyze/unused_variables.rb +21 -21
  52. data/spec/{rlint → ruby-lint}/callback.rb +7 -7
  53. data/spec/{rlint → ruby-lint}/constant_importer.rb +6 -6
  54. data/spec/{rlint → ruby-lint}/definition.rb +25 -25
  55. data/spec/{rlint → ruby-lint}/formatter/text.rb +4 -4
  56. data/spec/{rlint → ruby-lint}/iterator.rb +38 -38
  57. data/spec/{rlint → ruby-lint}/parser/arrays.rb +28 -28
  58. data/spec/{rlint → ruby-lint}/parser/classes.rb +23 -23
  59. data/spec/{rlint → ruby-lint}/parser/errors.rb +4 -4
  60. data/spec/{rlint → ruby-lint}/parser/hashes.rb +24 -24
  61. data/spec/{rlint → ruby-lint}/parser/methods.rb +50 -50
  62. data/spec/{rlint → ruby-lint}/parser/modules.rb +8 -8
  63. data/spec/{rlint → ruby-lint}/parser/objects.rb +8 -8
  64. data/spec/{rlint → ruby-lint}/parser/operators.rb +14 -14
  65. data/spec/{rlint → ruby-lint}/parser/procs.rb +26 -26
  66. data/spec/{rlint → ruby-lint}/parser/ranges.rb +9 -9
  67. data/spec/{rlint → ruby-lint}/parser/regexp.rb +5 -5
  68. data/spec/{rlint → ruby-lint}/parser/scalars.rb +17 -17
  69. data/spec/{rlint → ruby-lint}/parser/statements.rb +94 -94
  70. data/spec/{rlint → ruby-lint}/parser/variables.rb +37 -37
  71. data/spec/{rlint → ruby-lint}/report.rb +4 -4
  72. data/task/manifest.rake +8 -0
  73. data/task/test.rake +1 -1
  74. metadata +69 -66
  75. data/bin/rlint +0 -6
  76. data/lib/rlint.rb +0 -36
  77. data/lib/rlint/version.rb +0 -3
data/spec/helper.rb CHANGED
@@ -1,4 +1,6 @@
1
- require File.expand_path('../../lib/rlint', __FILE__)
1
+ require File.expand_path('../../lib/ruby-lint', __FILE__)
2
2
  require 'bacon'
3
3
 
4
+ RubyLint::FIXTURES = File.expand_path('../fixtures', __FILE__)
5
+
4
6
  Bacon.summary_on_exit
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../../helper', __FILE__)
2
2
 
3
- describe 'Rlint::Analyze::CodingStyle' do
3
+ describe 'RubyLint::Analyze::CodingStyle' do
4
4
  it 'Check the casing of method names and variables' do
5
5
  code = <<-CODE
6
6
  def getNumber(theNumber = 10)
@@ -10,11 +10,11 @@ def getNumber(theNumber = 10)
10
10
  end
11
11
  CODE
12
12
 
13
- tokens = Rlint::Parser.new(code).parse
14
- report = Rlint::Report.new
15
- iterator = Rlint::Iterator.new(report)
13
+ tokens = RubyLint::Parser.new(code).parse
14
+ report = RubyLint::Report.new
15
+ iterator = RubyLint::Iterator.new(report)
16
16
 
17
- iterator.bind(Rlint::Analyze::CodingStyle)
17
+ iterator.bind(RubyLint::Analyze::CodingStyle)
18
18
  iterator.run(tokens)
19
19
 
20
20
  messages = report.messages[:info]
@@ -51,16 +51,16 @@ this_variable_is_fine = 10
51
51
  THIS_CONSTANT_NAME_IS_WAY_TOO_LONG = 10
52
52
  CODE
53
53
 
54
- tokens = Rlint::Parser.new(code).parse
55
- report = Rlint::Report.new
56
- iterator = Rlint::Iterator.new(report)
54
+ tokens = RubyLint::Parser.new(code).parse
55
+ report = RubyLint::Report.new
56
+ iterator = RubyLint::Iterator.new(report)
57
57
 
58
- iterator.bind(Rlint::Analyze::CodingStyle)
58
+ iterator.bind(RubyLint::Analyze::CodingStyle)
59
59
  iterator.run(tokens)
60
60
 
61
61
  messages = report.messages[:info]
62
62
  message = "method and variable names should not be longer than " \
63
- "#{Rlint::Analyze::CodingStyle::MAXIMUM_NAME_LENGTH} characters"
63
+ "#{RubyLint::Analyze::CodingStyle::MAXIMUM_NAME_LENGTH} characters"
64
64
 
65
65
  messages[0][:message].should == message
66
66
  messages[0][:line].should == 1
@@ -76,11 +76,11 @@ THIS_CONSTANT_NAME_IS_WAY_TOO_LONG = 10
76
76
  end
77
77
 
78
78
  it 'Check for the use of class variables' do
79
- tokens = Rlint::Parser.new('@@number = 10').parse
80
- report = Rlint::Report.new
81
- iterator = Rlint::Iterator.new(report)
79
+ tokens = RubyLint::Parser.new('@@number = 10').parse
80
+ report = RubyLint::Report.new
81
+ iterator = RubyLint::Iterator.new(report)
82
82
 
83
- iterator.bind(Rlint::Analyze::CodingStyle)
83
+ iterator.bind(RubyLint::Analyze::CodingStyle)
84
84
  iterator.run(tokens)
85
85
 
86
86
  info = report.messages[:info][0]
@@ -118,11 +118,11 @@ unless ( foobar )
118
118
  end
119
119
  CODE
120
120
 
121
- tokens = Rlint::Parser.new(code).parse
122
- report = Rlint::Report.new
123
- iterator = Rlint::Iterator.new(report)
121
+ tokens = RubyLint::Parser.new(code).parse
122
+ report = RubyLint::Report.new
123
+ iterator = RubyLint::Iterator.new(report)
124
124
 
125
- iterator.bind(Rlint::Analyze::CodingStyle)
125
+ iterator.bind(RubyLint::Analyze::CodingStyle)
126
126
  iterator.run(tokens)
127
127
 
128
128
  report.messages[:info].class.should == Array
@@ -148,11 +148,11 @@ def valid_name?
148
148
  end
149
149
  CODE
150
150
 
151
- tokens = Rlint::Parser.new(code).parse
152
- report = Rlint::Report.new
153
- iterator = Rlint::Iterator.new(report)
151
+ tokens = RubyLint::Parser.new(code).parse
152
+ report = RubyLint::Report.new
153
+ iterator = RubyLint::Iterator.new(report)
154
154
 
155
- iterator.bind(Rlint::Analyze::CodingStyle)
155
+ iterator.bind(RubyLint::Analyze::CodingStyle)
156
156
  iterator.run(tokens)
157
157
 
158
158
  message = 'predicate methods should end with a question mark'
@@ -171,11 +171,11 @@ end
171
171
  [].map { |a| }
172
172
  CODE
173
173
 
174
- tokens = Rlint::Parser.new(code).parse
175
- report = Rlint::Report.new
176
- iterator = Rlint::Iterator.new(report)
174
+ tokens = RubyLint::Parser.new(code).parse
175
+ report = RubyLint::Report.new
176
+ iterator = RubyLint::Iterator.new(report)
177
177
 
178
- iterator.bind(Rlint::Analyze::CodingStyle)
178
+ iterator.bind(RubyLint::Analyze::CodingStyle)
179
179
  iterator.run(tokens)
180
180
 
181
181
  message = 'it is recommended to use the method "map" instead of "collect"'
@@ -201,11 +201,11 @@ def String.class_method
201
201
  end
202
202
  CODE
203
203
 
204
- tokens = Rlint::Parser.new(code).parse
205
- report = Rlint::Report.new
206
- iterator = Rlint::Iterator.new(report)
204
+ tokens = RubyLint::Parser.new(code).parse
205
+ report = RubyLint::Report.new
206
+ iterator = RubyLint::Iterator.new(report)
207
207
 
208
- iterator.bind(Rlint::Analyze::CodingStyle)
208
+ iterator.bind(RubyLint::Analyze::CodingStyle)
209
209
  iterator.run(tokens)
210
210
 
211
211
  report.messages[:warning].class.should == Array
@@ -0,0 +1,29 @@
1
+ require File.expand_path('../../../../helper', __FILE__)
2
+
3
+ describe 'Complex code analysis' do
4
+ it 'Analyze fixtures/stdlib/un.rb' do
5
+ code = File.read(File.join(RubyLint::FIXTURES, 'stdlib/un.rb'))
6
+ tokens = RubyLint::Parser.new(code).parse
7
+ iterator = RubyLint::Iterator.new
8
+
9
+ iterator.bind(RubyLint::Analyze::Definitions)
10
+ iterator.bind(RubyLint::Analyze::CodingStyle)
11
+ iterator.bind(RubyLint::Analyze::MethodValidation)
12
+ iterator.bind(RubyLint::Analyze::ShadowingVariables)
13
+ iterator.bind(RubyLint::Analyze::UndefinedVariables)
14
+ iterator.bind(RubyLint::Analyze::UnusedVariables)
15
+ iterator.run(tokens)
16
+
17
+ scope = iterator.storage[:scope]
18
+ methods = %w{setup cp ln mv rm mkdir rmdir install chmod
19
+ touch wait_writable mkmf httpd help}
20
+
21
+ scope.class.should == RubyLint::Definition
22
+
23
+ scope.lookup(:constant, 'FileUtils').class.should == RubyLint::Definition
24
+
25
+ methods.each do |method|
26
+ scope.lookup(:instance_method, method).class.should == RubyLint::Definition
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../../../helper', __FILE__)
2
2
 
3
- describe 'Rlint::Analyze::Definitions: classes' do
3
+ describe 'RubyLint::Analyze::Definitions: classes' do
4
4
  it 'Define a class in the global scope' do
5
5
  code = <<-CODE
6
6
  class Example
@@ -10,18 +10,18 @@ class Example
10
10
  end
11
11
  CODE
12
12
 
13
- tokens = Rlint::Parser.new(code).parse
14
- iterator = Rlint::Iterator.new
13
+ tokens = RubyLint::Parser.new(code).parse
14
+ iterator = RubyLint::Iterator.new
15
15
 
16
- iterator.bind(Rlint::Analyze::Definitions)
16
+ iterator.bind(RubyLint::Analyze::Definitions)
17
17
  iterator.run(tokens)
18
18
 
19
19
  scope = iterator.storage[:scope]
20
20
  const = scope.lookup(:constant, 'Example')
21
21
 
22
- const.class.should == Rlint::Definition
22
+ const.class.should == RubyLint::Definition
23
23
 
24
- const.token.class.should == Rlint::Token::ClassToken
24
+ const.token.class.should == RubyLint::Token::ClassToken
25
25
  const.token.name.should == ['Example']
26
26
  const.token.value.nil?.should == true
27
27
 
@@ -30,9 +30,9 @@ end
30
30
 
31
31
  method = const.lookup(:instance_method, 'example_method')
32
32
 
33
- method.class.should == Rlint::Definition
33
+ method.class.should == RubyLint::Definition
34
34
 
35
- method.token.class.should == Rlint::Token::MethodDefinitionToken
35
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
36
36
  method.token.name.should == 'example_method'
37
37
  end
38
38
 
@@ -45,10 +45,10 @@ class Example
45
45
  end
46
46
  CODE
47
47
 
48
- tokens = Rlint::Parser.new(code).parse
49
- iterator = Rlint::Iterator.new
48
+ tokens = RubyLint::Parser.new(code).parse
49
+ iterator = RubyLint::Iterator.new
50
50
 
51
- iterator.bind(Rlint::Analyze::Definitions)
51
+ iterator.bind(RubyLint::Analyze::Definitions)
52
52
  iterator.run(tokens)
53
53
 
54
54
  scope = iterator.storage[:scope]
@@ -57,10 +57,10 @@ end
57
57
 
58
58
  const = scope.lookup(:constant, 'Example')
59
59
 
60
- const.class.should == Rlint::Definition
60
+ const.class.should == RubyLint::Definition
61
61
 
62
62
  const.lookup(:instance_method, 'example_method').nil?.should == true
63
- const.lookup(:method, 'example_method').class.should == Rlint::Definition
63
+ const.lookup(:method, 'example_method').class.should == RubyLint::Definition
64
64
  end
65
65
 
66
66
  it 'Inherit methods from a parent class' do
@@ -76,10 +76,10 @@ class B < A
76
76
  end
77
77
  CODE
78
78
 
79
- tokens = Rlint::Parser.new(code).parse
80
- iterator = Rlint::Iterator.new
79
+ tokens = RubyLint::Parser.new(code).parse
80
+ iterator = RubyLint::Iterator.new
81
81
 
82
- iterator.bind(Rlint::Analyze::Definitions)
82
+ iterator.bind(RubyLint::Analyze::Definitions)
83
83
  iterator.run(tokens)
84
84
 
85
85
  scope = iterator.storage[:scope]
@@ -88,27 +88,27 @@ end
88
88
  b = scope.lookup(:constant, 'B')
89
89
 
90
90
  # check class A
91
- a.class.should == Rlint::Definition
91
+ a.class.should == RubyLint::Definition
92
92
 
93
- a.token.class.should == Rlint::Token::ClassToken
93
+ a.token.class.should == RubyLint::Token::ClassToken
94
94
  a.token.name.should == ['A']
95
95
  a.token.parent.should == ['Object']
96
96
 
97
- a.lookup(:method, :methods).class.should == Rlint::Definition
98
- a.lookup(:instance_method, :methods).class.should == Rlint::Definition
97
+ a.lookup(:method, :methods).class.should == RubyLint::Definition
98
+ a.lookup(:instance_method, :methods).class.should == RubyLint::Definition
99
99
 
100
100
  # check class B
101
- b.class.should == Rlint::Definition
101
+ b.class.should == RubyLint::Definition
102
102
 
103
- b.token.class.should == Rlint::Token::ClassToken
103
+ b.token.class.should == RubyLint::Token::ClassToken
104
104
  b.token.name.should == ['B']
105
105
  b.token.parent.should == ['A']
106
106
 
107
107
  b.lookup(:instance_method, 'parent_method') \
108
108
  .class \
109
- .should == Rlint::Definition
109
+ .should == RubyLint::Definition
110
110
 
111
- b.lookup(:method, :methods).class.should == Rlint::Definition
112
- b.lookup(:instance_method, :methods).class.should == Rlint::Definition
111
+ b.lookup(:method, :methods).class.should == RubyLint::Definition
112
+ b.lookup(:instance_method, :methods).class.should == RubyLint::Definition
113
113
  end
114
114
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../../../helper', __FILE__)
2
2
 
3
- describe 'Rlint::Analyze::Definitions: methods' do
3
+ describe 'RubyLint::Analyze::Definitions: methods' do
4
4
  it 'Build a list of globally defined methods' do
5
5
  code = <<-CODE
6
6
  def example_method
@@ -12,25 +12,25 @@ def another_example_method
12
12
  end
13
13
  CODE
14
14
 
15
- tokens = Rlint::Parser.new(code).parse
16
- iterator = Rlint::Iterator.new
15
+ tokens = RubyLint::Parser.new(code).parse
16
+ iterator = RubyLint::Iterator.new
17
17
 
18
- iterator.bind(Rlint::Analyze::Definitions)
18
+ iterator.bind(RubyLint::Analyze::Definitions)
19
19
  iterator.run(tokens)
20
20
 
21
21
  scope = iterator.storage[:scope]
22
22
 
23
- scope.class.should == Rlint::Definition
23
+ scope.class.should == RubyLint::Definition
24
24
 
25
25
  method_1 = scope.lookup(:instance_method, 'example_method')
26
26
  method_2 = scope.lookup(:instance_method, 'another_example_method')
27
27
 
28
- method_1.class.should == Rlint::Definition
29
- method_1.token.class.should == Rlint::Token::MethodDefinitionToken
28
+ method_1.class.should == RubyLint::Definition
29
+ method_1.token.class.should == RubyLint::Token::MethodDefinitionToken
30
30
  method_1.token.name.should == 'example_method'
31
31
 
32
- method_2.class.should == Rlint::Definition
33
- method_2.token.class.should == Rlint::Token::MethodDefinitionToken
32
+ method_2.class.should == RubyLint::Definition
33
+ method_2.token.class.should == RubyLint::Token::MethodDefinitionToken
34
34
  method_2.token.name.should == 'another_example_method'
35
35
  end
36
36
 
@@ -41,20 +41,20 @@ def self.example_method
41
41
  end
42
42
  CODE
43
43
 
44
- tokens = Rlint::Parser.new(code).parse
45
- iterator = Rlint::Iterator.new
44
+ tokens = RubyLint::Parser.new(code).parse
45
+ iterator = RubyLint::Iterator.new
46
46
 
47
- iterator.bind(Rlint::Analyze::Definitions)
47
+ iterator.bind(RubyLint::Analyze::Definitions)
48
48
  iterator.run(tokens)
49
49
 
50
50
  scope = iterator.storage[:scope]
51
51
 
52
- scope.class.should == Rlint::Definition
52
+ scope.class.should == RubyLint::Definition
53
53
 
54
54
  method = scope.lookup(:method, 'example_method')
55
55
 
56
- method.class.should == Rlint::Definition
57
- method.token.class.should == Rlint::Token::MethodDefinitionToken
56
+ method.class.should == RubyLint::Definition
57
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
58
58
  method.token.name.should == 'example_method'
59
59
  end
60
60
 
@@ -65,27 +65,27 @@ def String.example_method
65
65
  end
66
66
  CODE
67
67
 
68
- tokens = Rlint::Parser.new(code).parse
69
- iterator = Rlint::Iterator.new
68
+ tokens = RubyLint::Parser.new(code).parse
69
+ iterator = RubyLint::Iterator.new
70
70
 
71
- iterator.bind(Rlint::Analyze::Definitions)
71
+ iterator.bind(RubyLint::Analyze::Definitions)
72
72
  iterator.run(tokens)
73
73
 
74
74
  scope = iterator.storage[:scope]
75
75
 
76
- scope.class.should == Rlint::Definition
76
+ scope.class.should == RubyLint::Definition
77
77
 
78
78
  scope.lookup(:instance_method, 'example_method').nil?.should == true
79
79
  scope.lookup(:method, 'example_method').nil?.should == true
80
80
 
81
81
  string = scope.lookup(:constant, 'String')
82
82
 
83
- string.class.should == Rlint::Definition
83
+ string.class.should == RubyLint::Definition
84
84
 
85
85
  method = string.lookup(:method, 'example_method')
86
86
 
87
- method.class.should == Rlint::Definition
88
- method.token.class.should == Rlint::Token::MethodDefinitionToken
87
+ method.class.should == RubyLint::Definition
88
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
89
89
  method.token.name.should == 'example_method'
90
90
  end
91
91
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../../../helper', __FILE__)
2
2
 
3
- describe 'Rlint::Analyze::Definitions: modules' do
3
+ describe 'RubyLint::Analyze::Definitions: modules' do
4
4
  it 'Define a module in the global scope' do
5
5
  code = <<-CODE
6
6
  module Example
@@ -10,18 +10,18 @@ module Example
10
10
  end
11
11
  CODE
12
12
 
13
- tokens = Rlint::Parser.new(code).parse
14
- iterator = Rlint::Iterator.new
13
+ tokens = RubyLint::Parser.new(code).parse
14
+ iterator = RubyLint::Iterator.new
15
15
 
16
- iterator.bind(Rlint::Analyze::Definitions)
16
+ iterator.bind(RubyLint::Analyze::Definitions)
17
17
  iterator.run(tokens)
18
18
 
19
19
  scope = iterator.storage[:scope]
20
20
  const = scope.lookup(:constant, 'Example')
21
21
 
22
- const.class.should == Rlint::Definition
22
+ const.class.should == RubyLint::Definition
23
23
 
24
- const.token.class.should == Rlint::Token::Token
24
+ const.token.class.should == RubyLint::Token::Token
25
25
  const.token.type.should == :module
26
26
  const.token.name.should == ['Example']
27
27
 
@@ -29,9 +29,9 @@ end
29
29
 
30
30
  method = const.lookup(:instance_method, 'example_method')
31
31
 
32
- method.class.should == Rlint::Definition
32
+ method.class.should == RubyLint::Definition
33
33
 
34
- method.token.class.should == Rlint::Token::MethodDefinitionToken
34
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
35
35
  method.token.name.should == 'example_method'
36
36
  end
37
37
 
@@ -44,18 +44,18 @@ module Example
44
44
  end
45
45
  CODE
46
46
 
47
- tokens = Rlint::Parser.new(code).parse
48
- iterator = Rlint::Iterator.new
47
+ tokens = RubyLint::Parser.new(code).parse
48
+ iterator = RubyLint::Iterator.new
49
49
 
50
- iterator.bind(Rlint::Analyze::Definitions)
50
+ iterator.bind(RubyLint::Analyze::Definitions)
51
51
  iterator.run(tokens)
52
52
 
53
53
  scope = iterator.storage[:scope]
54
54
  const = scope.lookup(:constant, 'Example')
55
55
 
56
- const.class.should == Rlint::Definition
56
+ const.class.should == RubyLint::Definition
57
57
 
58
- const.token.class.should == Rlint::Token::Token
58
+ const.token.class.should == RubyLint::Token::Token
59
59
  const.token.type.should == :module
60
60
  const.token.name.should == ['Example']
61
61
 
@@ -63,9 +63,9 @@ end
63
63
 
64
64
  method = const.lookup(:method, 'example_method')
65
65
 
66
- method.class.should == Rlint::Definition
66
+ method.class.should == RubyLint::Definition
67
67
 
68
- method.token.class.should == Rlint::Token::MethodDefinitionToken
68
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
69
69
  method.token.name.should == 'example_method'
70
70
  end
71
71
 
@@ -82,24 +82,24 @@ class B
82
82
  end
83
83
  CODE
84
84
 
85
- tokens = Rlint::Parser.new(code).parse
86
- iterator = Rlint::Iterator.new
85
+ tokens = RubyLint::Parser.new(code).parse
86
+ iterator = RubyLint::Iterator.new
87
87
 
88
- iterator.bind(Rlint::Analyze::Definitions)
88
+ iterator.bind(RubyLint::Analyze::Definitions)
89
89
  iterator.run(tokens)
90
90
 
91
91
  scope = iterator.storage[:scope]
92
92
  const = scope.lookup(:constant, 'B')
93
93
 
94
- const.class.should == Rlint::Definition
94
+ const.class.should == RubyLint::Definition
95
95
 
96
96
  const.lookup(:method, 'example_method').nil?.should == true
97
97
 
98
98
  method = const.lookup(:instance_method, 'example_method')
99
99
 
100
- method.class.should == Rlint::Definition
100
+ method.class.should == RubyLint::Definition
101
101
 
102
- method.token.class.should == Rlint::Token::MethodDefinitionToken
102
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
103
103
  method.token.name.should == 'example_method'
104
104
  end
105
105
 
@@ -116,24 +116,24 @@ class B
116
116
  end
117
117
  CODE
118
118
 
119
- tokens = Rlint::Parser.new(code).parse
120
- iterator = Rlint::Iterator.new
119
+ tokens = RubyLint::Parser.new(code).parse
120
+ iterator = RubyLint::Iterator.new
121
121
 
122
- iterator.bind(Rlint::Analyze::Definitions)
122
+ iterator.bind(RubyLint::Analyze::Definitions)
123
123
  iterator.run(tokens)
124
124
 
125
125
  scope = iterator.storage[:scope]
126
126
  const = scope.lookup(:constant, 'B')
127
127
 
128
- const.class.should == Rlint::Definition
128
+ const.class.should == RubyLint::Definition
129
129
 
130
130
  const.lookup(:instance_method, 'example_method').nil?.should == true
131
131
 
132
132
  method = const.lookup(:method, 'example_method')
133
133
 
134
- method.class.should == Rlint::Definition
134
+ method.class.should == RubyLint::Definition
135
135
 
136
- method.token.class.should == Rlint::Token::MethodDefinitionToken
136
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
137
137
  method.token.name.should == 'example_method'
138
138
  end
139
139
 
@@ -152,55 +152,55 @@ class C
152
152
  end
153
153
  CODE
154
154
 
155
- tokens = Rlint::Parser.new(code).parse
156
- iterator = Rlint::Iterator.new
155
+ tokens = RubyLint::Parser.new(code).parse
156
+ iterator = RubyLint::Iterator.new
157
157
 
158
- iterator.bind(Rlint::Analyze::Definitions)
158
+ iterator.bind(RubyLint::Analyze::Definitions)
159
159
  iterator.run(tokens)
160
160
 
161
161
  scope = iterator.storage[:scope]
162
162
  const = scope.lookup(:constant, 'C')
163
163
 
164
- const.class.should == Rlint::Definition
164
+ const.class.should == RubyLint::Definition
165
165
 
166
166
  const.lookup(:method, 'example_method').nil?.should == true
167
167
 
168
168
  method = const.lookup(:instance_method, 'example_method')
169
169
 
170
- method.class.should == Rlint::Definition
170
+ method.class.should == RubyLint::Definition
171
171
 
172
- method.token.class.should == Rlint::Token::MethodDefinitionToken
172
+ method.token.class.should == RubyLint::Token::MethodDefinitionToken
173
173
  method.token.name.should == 'example_method'
174
174
  end
175
175
 
176
176
  it 'Define a module in an existing module' do
177
177
  code = <<-CODE
178
- module Rlint
178
+ module RubyLint
179
179
  module Derp
180
180
 
181
181
  end
182
182
  end
183
183
  CODE
184
184
 
185
- tokens = Rlint::Parser.new(code).parse
186
- iterator = Rlint::Iterator.new
185
+ tokens = RubyLint::Parser.new(code).parse
186
+ iterator = RubyLint::Iterator.new
187
187
 
188
- iterator.bind(Rlint::Analyze::Definitions)
188
+ iterator.bind(RubyLint::Analyze::Definitions)
189
189
  iterator.run(tokens)
190
190
 
191
191
  scope = iterator.storage[:scope]
192
192
 
193
193
  scope.lookup(:constant, 'Derp').nil?.should == true
194
194
 
195
- scope.lookup(:constant, 'Rlint').class.should == Rlint::Definition
195
+ scope.lookup(:constant, 'RubyLint').class.should == RubyLint::Definition
196
196
 
197
- scope.lookup(:constant, 'Rlint') \
197
+ scope.lookup(:constant, 'RubyLint') \
198
198
  .lookup(:constant, 'Derp') \
199
199
  .class \
200
- .should == Rlint::Definition
200
+ .should == RubyLint::Definition
201
201
 
202
- rlint = scope.lookup(:constant, 'Rlint')
203
- derp = rlint.lookup(:constant, 'Derp')
202
+ ruby_lint = scope.lookup(:constant, 'RubyLint')
203
+ derp = ruby_lint.lookup(:constant, 'Derp')
204
204
 
205
205
  derp.parent.length.should == 1
206
206
  end