rubocop 0.1.0 → 0.2.1

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 (62) hide show
  1. data/.rbenv-version +1 -0
  2. data/.travis.yml +4 -0
  3. data/CONTRIBUTING.md +9 -0
  4. data/Gemfile +7 -8
  5. data/Gemfile.lock +21 -33
  6. data/README.md +17 -11
  7. data/Rakefile +0 -3
  8. data/VERSION +1 -1
  9. data/bin/rubocop +1 -1
  10. data/features/step_definitions/rubocop_steps.rb +1 -0
  11. data/features/support/env.rb +3 -1
  12. data/lib/rubocop/cli.rb +50 -24
  13. data/lib/rubocop/cop/align_parameters.rb +112 -0
  14. data/lib/rubocop/cop/blocks.rb +48 -0
  15. data/lib/rubocop/cop/cop.rb +44 -21
  16. data/lib/rubocop/cop/def_parentheses.rb +38 -0
  17. data/lib/rubocop/cop/empty_lines.rb +7 -6
  18. data/lib/rubocop/cop/encoding.rb +1 -1
  19. data/lib/rubocop/cop/end_of_line.rb +17 -0
  20. data/lib/rubocop/cop/grammar.rb +69 -9
  21. data/lib/rubocop/cop/hash_syntax.rb +26 -0
  22. data/lib/rubocop/cop/if_then_else.rb +49 -0
  23. data/lib/rubocop/cop/indentation.rb +16 -27
  24. data/lib/rubocop/cop/line_length.rb +2 -2
  25. data/lib/rubocop/cop/numeric_literals.rb +19 -0
  26. data/lib/rubocop/cop/offence.rb +2 -3
  27. data/lib/rubocop/cop/parameter_lists.rb +17 -0
  28. data/lib/rubocop/cop/space_after_comma_etc.rb +10 -9
  29. data/lib/rubocop/cop/string_literals.rb +36 -0
  30. data/lib/rubocop/cop/surrounding_space.rb +66 -17
  31. data/lib/rubocop/cop/tab.rb +2 -2
  32. data/lib/rubocop/cop/ternary_operator.rb +24 -0
  33. data/lib/rubocop/cop/trailing_whitespace.rb +2 -2
  34. data/lib/rubocop/report/emacs_style.rb +4 -3
  35. data/lib/rubocop/version.rb +1 -1
  36. data/lib/rubocop.rb +10 -0
  37. data/rubocop.gemspec +37 -17
  38. data/spec/rubocop/cli_spec.rb +32 -5
  39. data/spec/rubocop/cops/align_parameters_spec.rb +201 -0
  40. data/spec/rubocop/cops/blocks_spec.rb +35 -0
  41. data/spec/rubocop/cops/cop_spec.rb +4 -2
  42. data/spec/rubocop/cops/def_parentheses_spec.rb +48 -0
  43. data/spec/rubocop/cops/empty_lines_spec.rb +9 -8
  44. data/spec/rubocop/cops/end_of_line_spec.rb +17 -0
  45. data/spec/rubocop/cops/grammar_spec.rb +54 -12
  46. data/spec/rubocop/cops/hash_syntax_spec.rb +44 -0
  47. data/spec/rubocop/cops/if_then_else_spec.rb +74 -0
  48. data/spec/rubocop/cops/indentation_spec.rb +29 -4
  49. data/spec/rubocop/cops/line_length_spec.rb +4 -2
  50. data/spec/rubocop/cops/numeric_literals_spec.rb +49 -0
  51. data/spec/rubocop/cops/offence_spec.rb +4 -3
  52. data/spec/rubocop/cops/parameter_lists_spec.rb +24 -0
  53. data/spec/rubocop/cops/space_after_comma_etc_spec.rb +7 -5
  54. data/spec/rubocop/cops/string_literals_spec.rb +32 -0
  55. data/spec/rubocop/cops/surrounding_space_spec.rb +89 -26
  56. data/spec/rubocop/cops/tab_spec.rb +4 -2
  57. data/spec/rubocop/cops/ternary_operator_spec.rb +24 -0
  58. data/spec/rubocop/cops/trailing_whitespace_spec.rb +5 -3
  59. data/spec/rubocop/reports/emacs_style_spec.rb +5 -3
  60. data/spec/rubocop/reports/report_spec.rb +3 -1
  61. data/spec/spec_helper.rb +11 -2
  62. metadata +39 -32
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
  require 'stringio'
3
5
 
@@ -8,14 +10,14 @@ module Rubocop
8
10
 
9
11
  it 'displays parsable text' do
10
12
  cop = Cop::Cop.new
11
- cop.add_offence(:convention, 0, 'line', 'message 1')
12
- cop.add_offence(:fatal, 10, 'line', 'message 2')
13
+ cop.add_offence(:convention, 1, 'message 1')
14
+ cop.add_offence(:fatal, 11, 'message 2')
13
15
 
14
16
  emacs_style << cop
15
17
 
16
18
  s = StringIO.new
17
19
  emacs_style.display(s)
18
- s.string.should == ["test:1: C: message 1",
20
+ s.string.should == ['test:1: C: message 1',
19
21
  "test:11: F: message 2\n"].join("\n")
20
22
  end
21
23
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  module Rubocop
@@ -15,7 +17,7 @@ module Rubocop
15
17
 
16
18
  it 'keeps track of offences' do
17
19
  cop = Cop::Cop.new
18
- cop.add_offence(:convention, 0, 'line', 'message')
20
+ cop.add_offence(:convention, 1, 'message')
19
21
 
20
22
  report << cop
21
23
 
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,14 @@
1
+ # encoding: utf-8
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
5
  require 'rspec'
4
6
  require 'rubocop'
7
+ require 'rubocop/cli'
5
8
 
6
9
  # Requires supporting files with custom matchers and macros, etc,
7
10
  # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
9
12
 
10
13
  module ExitCodeMatchers
11
14
  RSpec::Matchers.define :exit_with_code do |code|
@@ -20,7 +23,7 @@ module ExitCodeMatchers
20
23
  end
21
24
  failure_message_for_should do |block|
22
25
  "expected block to call exit(#{code}) but exit" +
23
- (actual.nil? ? " not called" : "(#{actual}) was called")
26
+ (actual.nil? ? ' not called' : "(#{actual}) was called")
24
27
  end
25
28
  failure_message_for_should_not do |block|
26
29
  "expected block not to call exit(#{code})"
@@ -34,3 +37,9 @@ end
34
37
  RSpec.configure do |config|
35
38
  config.include(ExitCodeMatchers)
36
39
  end
40
+
41
+ def inspect_source(cop, file, source)
42
+ tokens, sexp, correlations = Rubocop::CLI.rip_source(source)
43
+ cop.correlations = correlations
44
+ cop.inspect(file, source, tokens, sexp)
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,16 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-20 00:00:00.000000000 Z
12
+ date: 2013-01-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
15
+ name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.8.0
21
+ version: 10.0.0
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,15 +26,15 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.8.0
29
+ version: 10.0.0
30
30
  - !ruby/object:Gem::Dependency
31
- name: yard
31
+ name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0.7'
37
+ version: 2.12.0
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,39 +42,23 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0.7'
45
+ version: 2.12.0
46
46
  - !ruby/object:Gem::Dependency
47
- name: redcarpet
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: cucumber
47
+ name: yard
64
48
  requirement: !ruby/object:Gem::Requirement
65
49
  none: false
66
50
  requirements:
67
- - - ! '>='
51
+ - - ~>
68
52
  - !ruby/object:Gem::Version
69
- version: '0'
53
+ version: 0.8.0
70
54
  type: :development
71
55
  prerelease: false
72
56
  version_requirements: !ruby/object:Gem::Requirement
73
57
  none: false
74
58
  requirements:
75
- - - ! '>='
59
+ - - ~>
76
60
  - !ruby/object:Gem::Version
77
- version: '0'
61
+ version: 0.8.0
78
62
  - !ruby/object:Gem::Dependency
79
63
  name: bundler
80
64
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +66,7 @@ dependencies:
82
66
  requirements:
83
67
  - - ~>
84
68
  - !ruby/object:Gem::Version
85
- version: 1.1.0
69
+ version: 1.2.0
86
70
  type: :development
87
71
  prerelease: false
88
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +74,7 @@ dependencies:
90
74
  requirements:
91
75
  - - ~>
92
76
  - !ruby/object:Gem::Version
93
- version: 1.1.0
77
+ version: 1.2.0
94
78
  - !ruby/object:Gem::Dependency
95
79
  name: jeweler
96
80
  requirement: !ruby/object:Gem::Requirement
@@ -134,8 +118,11 @@ extra_rdoc_files:
134
118
  - README.md
135
119
  files:
136
120
  - .document
121
+ - .rbenv-version
137
122
  - .rspec
138
123
  - .rvmrc
124
+ - .travis.yml
125
+ - CONTRIBUTING.md
139
126
  - Gemfile
140
127
  - Gemfile.lock
141
128
  - LICENSE.txt
@@ -148,16 +135,26 @@ files:
148
135
  - features/support/env.rb
149
136
  - lib/rubocop.rb
150
137
  - lib/rubocop/cli.rb
138
+ - lib/rubocop/cop/align_parameters.rb
139
+ - lib/rubocop/cop/blocks.rb
151
140
  - lib/rubocop/cop/cop.rb
141
+ - lib/rubocop/cop/def_parentheses.rb
152
142
  - lib/rubocop/cop/empty_lines.rb
153
143
  - lib/rubocop/cop/encoding.rb
144
+ - lib/rubocop/cop/end_of_line.rb
154
145
  - lib/rubocop/cop/grammar.rb
146
+ - lib/rubocop/cop/hash_syntax.rb
147
+ - lib/rubocop/cop/if_then_else.rb
155
148
  - lib/rubocop/cop/indentation.rb
156
149
  - lib/rubocop/cop/line_length.rb
150
+ - lib/rubocop/cop/numeric_literals.rb
157
151
  - lib/rubocop/cop/offence.rb
152
+ - lib/rubocop/cop/parameter_lists.rb
158
153
  - lib/rubocop/cop/space_after_comma_etc.rb
154
+ - lib/rubocop/cop/string_literals.rb
159
155
  - lib/rubocop/cop/surrounding_space.rb
160
156
  - lib/rubocop/cop/tab.rb
157
+ - lib/rubocop/cop/ternary_operator.rb
161
158
  - lib/rubocop/cop/trailing_whitespace.rb
162
159
  - lib/rubocop/report/emacs_style.rb
163
160
  - lib/rubocop/report/plain_text.rb
@@ -165,15 +162,25 @@ files:
165
162
  - lib/rubocop/version.rb
166
163
  - rubocop.gemspec
167
164
  - spec/rubocop/cli_spec.rb
165
+ - spec/rubocop/cops/align_parameters_spec.rb
166
+ - spec/rubocop/cops/blocks_spec.rb
168
167
  - spec/rubocop/cops/cop_spec.rb
168
+ - spec/rubocop/cops/def_parentheses_spec.rb
169
169
  - spec/rubocop/cops/empty_lines_spec.rb
170
+ - spec/rubocop/cops/end_of_line_spec.rb
170
171
  - spec/rubocop/cops/grammar_spec.rb
172
+ - spec/rubocop/cops/hash_syntax_spec.rb
173
+ - spec/rubocop/cops/if_then_else_spec.rb
171
174
  - spec/rubocop/cops/indentation_spec.rb
172
175
  - spec/rubocop/cops/line_length_spec.rb
176
+ - spec/rubocop/cops/numeric_literals_spec.rb
173
177
  - spec/rubocop/cops/offence_spec.rb
178
+ - spec/rubocop/cops/parameter_lists_spec.rb
174
179
  - spec/rubocop/cops/space_after_comma_etc_spec.rb
180
+ - spec/rubocop/cops/string_literals_spec.rb
175
181
  - spec/rubocop/cops/surrounding_space_spec.rb
176
182
  - spec/rubocop/cops/tab_spec.rb
183
+ - spec/rubocop/cops/ternary_operator_spec.rb
177
184
  - spec/rubocop/cops/trailing_whitespace_spec.rb
178
185
  - spec/rubocop/reports/emacs_style_spec.rb
179
186
  - spec/rubocop/reports/report_spec.rb
@@ -193,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
200
  version: '0'
194
201
  segments:
195
202
  - 0
196
- hash: 3628988712986097770
203
+ hash: 3978981872359853745
197
204
  required_rubygems_version: !ruby/object:Gem::Requirement
198
205
  none: false
199
206
  requirements: