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,151 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'RubyLint::Iterator' do
4
- example 'call after_initialize if it is defined' do
5
- iterator = Class.new(RubyLint::Iterator) do
6
- attr_reader :number
7
-
8
- def after_initialize
9
- @number = 10
10
- end
11
- end
12
-
13
- iterator.new.number.should == 10
14
- end
15
-
16
- example 'iterate over a simple AST' do
17
- ast = parse('10; 20; 30', false)
18
-
19
- iterator = Class.new(RubyLint::Iterator) do
20
- attr_reader :options
21
-
22
- def after_initialize
23
- @options = {:events => [], :numbers => []}
24
- end
25
-
26
- def on_root(node)
27
- @options[:events] << :on_root
28
- end
29
-
30
- def after_root(node)
31
- @options[:events] << :after_root
32
- end
33
-
34
- def on_int(node)
35
- unless @options[:events].include?(:on_int)
36
- @options[:events] << :on_int
37
- end
38
-
39
- @options[:numbers] << node.children[0]
40
- end
41
-
42
- def after_int(node)
43
- unless @options[:events].include?(:after_int)
44
- @options[:events] << :after_int
45
- end
46
- end
47
- end
48
-
49
- iterator = iterator.new(:numbers => [], :events => [])
50
-
51
- iterator.iterate(ast)
52
-
53
- iterator.options[:numbers].should == [10, 20, 30]
54
- iterator.options[:events].should == [
55
- :on_root,
56
- :on_int,
57
- :after_int,
58
- :after_root
59
- ]
60
- end
61
-
62
- example 'iterate over a multi dimensional AST' do
63
- code = <<-CODE
64
- class Example
65
- def some_method
66
- puts '10'
67
- end
68
- end
69
- CODE
70
-
71
- ast = parse(code, false)
72
-
73
- iterator = Class.new(RubyLint::Iterator) do
74
- attr_reader :options
75
-
76
- def after_initialize
77
- @options = {}
78
- end
79
-
80
- def on_class(node)
81
- @options[:class] = node.children[0].children[1]
82
- end
83
-
84
- def on_def(node)
85
- @options[:method] = node.children[0]
86
- end
87
-
88
- def on_send(node)
89
- @options[:call] = node.children[1]
90
- end
91
- end
92
-
93
- iterator = iterator.new
94
-
95
- iterator.iterate(ast)
96
-
97
- iterator.options[:class].should == :Example
98
- iterator.options[:method].should == :some_method
99
- iterator.options[:call].should == :puts
100
- end
101
-
102
- example 'skipping child nodes' do
103
- code = <<-CODE
104
- module A
105
- class B
106
- end
107
- end
108
- CODE
109
-
110
- ast = parse(code, false)
111
- iterator = Class.new(RubyLint::Iterator) do
112
- attr_reader :options
113
-
114
- def after_initialize
115
- @options = {:module => false, :class => false}
116
- end
117
-
118
- def on_module(node)
119
- options[:module] = true
120
-
121
- skip_child_nodes!(node)
122
- end
123
-
124
- def on_class(node)
125
- options[:class] = true
126
- end
127
- end
128
-
129
- iterator = iterator.new
130
-
131
- iterator.iterate(ast)
132
-
133
- iterator.options[:module].should == true
134
- iterator.options[:class].should == false
135
- end
136
-
137
- example 'allow callbacks without arguments' do
138
- ast = parse('10', false)
139
- iterator = Class.new(RubyLint::Iterator) do
140
- attr_reader :number
141
-
142
- def on_int
143
- @number = true
144
- end
145
- end.new
146
-
147
- iterator.iterate(ast)
148
-
149
- iterator.number.should == true
150
- end
151
- end
File without changes
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::NestedStack do
4
- before do
5
- @stack = RubyLint::NestedStack.new
6
- end
7
-
8
- example 'add a new stack' do
9
- @stack.empty?.should == true
10
-
11
- @stack.add_stack
12
-
13
- @stack.empty?.should == false
14
- end
15
-
16
- example 'push and pop values from the stack' do
17
- @stack.add_stack
18
- @stack.push(10)
19
-
20
- @stack.pop.should == [10]
21
- @stack.empty?.should == true
22
- end
23
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::NodeHash do
4
- before do
5
- @node_hash = RubyLint::NodeHash.new
6
- @node = s(:integer, 10)
7
- end
8
-
9
- example 'set and get information associated with a node' do
10
- @node_hash[@node] = 10
11
-
12
- @node_hash[@node].should == 10
13
- end
14
-
15
- example 'check if a node has been added' do
16
- @node_hash.key?(@node).should == false
17
-
18
- @node_hash[@node] = 10
19
-
20
- @node_hash.key?(@node).should == true
21
- end
22
-
23
- example 'return all keys' do
24
- @node_hash[@node] = 10
25
-
26
- @node_hash.keys.should == [@node.sha1]
27
- end
28
-
29
- example 'return all values' do
30
- @node_hash[@node] = 10
31
-
32
- @node_hash.values.should == [10]
33
- end
34
-
35
- example 'convert to an Array' do
36
- @node_hash[@node] = 10
37
-
38
- @node_hash.to_a.should == [[@node.sha1, 10]]
39
- end
40
-
41
- example 'merge with another node hash' do
42
- other = RubyLint::NodeHash.new(@node.sha1 => 10)
43
-
44
- @node_hash.merge!(other)
45
-
46
- @node_hash.key?(@node).should == true
47
- end
48
-
49
- example 'merge with another hash' do
50
- other = {@node => 10}
51
-
52
- @node_hash.merge_hash!(other)
53
-
54
- @node_hash.key?(@node).should == true
55
- end
56
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::Parser do
4
- example 'parse a block of Ruby code' do
5
- ast = parse('10', false)
6
-
7
- ast.type.should == :root
8
- ast.children.length.should == 1
9
- end
10
-
11
- example 'use a custom node class' do
12
- parse('10').class.should == RubyLint::AST::Node
13
- end
14
-
15
- example 'parse and return the comments mapping' do
16
- code = <<-CODE
17
- # Hello world
18
- def foobar
19
- end
20
- CODE
21
-
22
- ast, comments = parse_with_comments(code)
23
- def_node = ast.children[0]
24
- comment = comments[def_node][0]
25
-
26
- comment.is_a?(Parser::Source::Comment).should == true
27
-
28
- comment.text.should == '# Hello world'
29
- comment.location.line.should == 1
30
- end
31
-
32
- example 'parse an empty file' do
33
- ast = parse('', false)
34
-
35
- ast.type.should == :root
36
- ast.children.empty?.should == true
37
- end
38
- end
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
- require 'json'
3
-
4
- describe RubyLint::Presenter::JSON do
5
- example 'format a set of entries' do
6
- report = RubyLint::Report.new
7
- presenter = RubyLint::Presenter::JSON.new
8
-
9
- report.add(
10
- :level => :error,
11
- :message => 'error message',
12
- :line => 1,
13
- :column => 1,
14
- :file => 'a.rb'
15
- )
16
-
17
- report.add(
18
- :level => :error,
19
- :message => 'error message 2',
20
- :line => 2,
21
- :column => 1,
22
- :file => 'a.rb'
23
- )
24
-
25
- report.add(
26
- :level => :warning,
27
- :message => 'warning message',
28
- :line => 1,
29
- :column => 1,
30
- :file => 'b.rb'
31
- )
32
-
33
- report.add(
34
- :level => :info,
35
- :message => 'info message',
36
- :line => 1,
37
- :column => 1,
38
- :file => 'c.rb'
39
- )
40
-
41
- output = presenter.present(report)
42
- decoded = JSON(output)
43
-
44
- decoded.length.should == 4
45
-
46
- decoded[0]['file'].should == 'a.rb'
47
- decoded[0]['level'].should == 'error'
48
-
49
- decoded[1]['file'].should == 'a.rb'
50
- decoded[1]['level'].should == 'error'
51
-
52
- decoded[2]['file'].should == 'b.rb'
53
- decoded[2]['level'].should == 'warning'
54
-
55
- decoded[3]['file'].should == 'c.rb'
56
- decoded[3]['level'].should == 'info'
57
- end
58
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::Presenter::Syntastic do
4
- example 'format a set of entries' do
5
- report = RubyLint::Report.new
6
- presenter = RubyLint::Presenter::Syntastic.new
7
-
8
- report.add(
9
- :level => :error,
10
- :message => 'error message',
11
- :line => 1,
12
- :column => 1,
13
- :file => '/foo/a.rb'
14
- )
15
-
16
- report.add(
17
- :level => :error,
18
- :message => 'error message 2',
19
- :line => 2,
20
- :column => 1,
21
- :file => '/foo/a.rb'
22
- )
23
-
24
- report.add(
25
- :level => :warning,
26
- :message => 'warning message',
27
- :line => 1,
28
- :column => 1,
29
- :file => '/foo/b.rb'
30
- )
31
-
32
- report.add(
33
- :level => :info,
34
- :message => 'info message',
35
- :line => 1,
36
- :column => 1,
37
- :file => '/foo/c.rb'
38
- )
39
-
40
- output = presenter.present(report)
41
-
42
- output.should == <<-EOF.strip
43
- /foo/a.rb:E:1:1: error message
44
- /foo/a.rb:E:2:1: error message 2
45
- /foo/b.rb:W:1:1: warning message
46
- /foo/c.rb:I:1:1: info message
47
- EOF
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::Presenter::Text do
4
- example 'format a set of entries' do
5
- report = RubyLint::Report.new
6
- presenter = RubyLint::Presenter::Text.new
7
-
8
- report.add(
9
- :level => :error,
10
- :message => 'error message',
11
- :line => 1,
12
- :column => 1,
13
- :file => '/foo/a.rb'
14
- )
15
-
16
- report.add(
17
- :level => :error,
18
- :message => 'error message 2',
19
- :line => 2,
20
- :column => 1,
21
- :file => '/foo/a.rb'
22
- )
23
-
24
- report.add(
25
- :level => :warning,
26
- :message => 'warning message',
27
- :line => 1,
28
- :column => 1,
29
- :file => '/foo/b.rb'
30
- )
31
-
32
- report.add(
33
- :level => :info,
34
- :message => 'info message',
35
- :line => 1,
36
- :column => 1,
37
- :file => '/foo/c.rb'
38
- )
39
-
40
- output = presenter.present(report)
41
-
42
- output.should == <<-EOF.strip
43
- a.rb: error: line 1, column 1: error message
44
- a.rb: error: line 2, column 1: error message 2
45
- b.rb: warning: line 1, column 1: warning message
46
- c.rb: info: line 1, column 1: info message
47
- EOF
48
- end
49
- end
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RubyLint::Report::Entry do
4
- example 'sort a list of entries' do
5
- entries = [
6
- RubyLint::Report::Entry.new(
7
- :level => :info,
8
- :message => 'info',
9
- :line => 2,
10
- :column => 1,
11
- :file => 'a.rb'
12
- ),
13
- RubyLint::Report::Entry.new(
14
- :level => :error,
15
- :message => 'error',
16
- :line => 1,
17
- :column => 1,
18
- :file => 'a.rb'
19
- ),
20
- RubyLint::Report::Entry.new(
21
- :level => :warning,
22
- :message => 'warning',
23
- :line => 3,
24
- :column => 1,
25
- :file => 'a.rb'
26
- ),
27
- RubyLint::Report::Entry.new(
28
- :level => :warning,
29
- :message => 'warning',
30
- :line => 1,
31
- :column => 1,
32
- :file => 'b.rb'
33
- ),
34
- RubyLint::Report::Entry.new(
35
- :level => :error,
36
- :message => 'error',
37
- :line => 1,
38
- :column => 1,
39
- :file => 'c.rb'
40
- ),
41
- ].sort
42
-
43
- entries[0].file.should == 'a.rb'
44
- entries[0].level.should == :error
45
-
46
- entries[1].file.should == 'a.rb'
47
- entries[1].level.should == :info
48
-
49
- entries[2].file.should == 'a.rb'
50
- entries[2].level.should == :warning
51
-
52
- entries[3].file.should == 'b.rb'
53
- entries[3].level.should == :warning
54
-
55
- entries[4].file.should == 'c.rb'
56
- entries[4].level.should == :error
57
- end
58
- end