rubocop 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- data/.rbenv-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +8 -8
- data/README.md +17 -1
- data/VERSION +1 -1
- data/bin/rubocop +1 -1
- data/features/step_definitions/rubocop_steps.rb +1 -0
- data/features/support/env.rb +2 -0
- data/lib/rubocop.rb +6 -0
- data/lib/rubocop/cli.rb +37 -17
- data/lib/rubocop/cop/align_parameters.rb +112 -0
- data/lib/rubocop/cop/cop.rb +43 -21
- data/lib/rubocop/cop/def_parentheses.rb +38 -0
- data/lib/rubocop/cop/empty_lines.rb +7 -6
- data/lib/rubocop/cop/encoding.rb +1 -1
- data/lib/rubocop/cop/end_of_line.rb +17 -0
- data/lib/rubocop/cop/grammar.rb +69 -9
- data/lib/rubocop/cop/hash_syntax.rb +26 -0
- data/lib/rubocop/cop/if_then_else.rb +49 -0
- data/lib/rubocop/cop/indentation.rb +16 -27
- data/lib/rubocop/cop/line_length.rb +2 -2
- data/lib/rubocop/cop/numeric_literals.rb +19 -0
- data/lib/rubocop/cop/offence.rb +2 -3
- data/lib/rubocop/cop/space_after_comma_etc.rb +10 -9
- data/lib/rubocop/cop/surrounding_space.rb +66 -17
- data/lib/rubocop/cop/tab.rb +2 -2
- data/lib/rubocop/cop/trailing_whitespace.rb +2 -2
- data/lib/rubocop/report/emacs_style.rb +4 -3
- data/rubocop.gemspec +16 -2
- data/spec/rubocop/cli_spec.rb +20 -5
- data/spec/rubocop/cops/align_parameters_spec.rb +201 -0
- data/spec/rubocop/cops/cop_spec.rb +4 -2
- data/spec/rubocop/cops/def_parentheses_spec.rb +48 -0
- data/spec/rubocop/cops/empty_lines_spec.rb +9 -8
- data/spec/rubocop/cops/end_of_line_spec.rb +17 -0
- data/spec/rubocop/cops/grammar_spec.rb +51 -11
- data/spec/rubocop/cops/hash_syntax_spec.rb +44 -0
- data/spec/rubocop/cops/if_then_else_spec.rb +74 -0
- data/spec/rubocop/cops/indentation_spec.rb +29 -4
- data/spec/rubocop/cops/line_length_spec.rb +4 -2
- data/spec/rubocop/cops/numeric_literals_spec.rb +49 -0
- data/spec/rubocop/cops/offence_spec.rb +4 -3
- data/spec/rubocop/cops/space_after_comma_etc_spec.rb +7 -5
- data/spec/rubocop/cops/surrounding_space_spec.rb +89 -26
- data/spec/rubocop/cops/tab_spec.rb +4 -2
- data/spec/rubocop/cops/trailing_whitespace_spec.rb +5 -3
- data/spec/rubocop/reports/emacs_style_spec.rb +4 -2
- data/spec/rubocop/reports/report_spec.rb +3 -1
- data/spec/spec_helper.rb +9 -1
- metadata +17 -3
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Rubocop
|
@@ -6,12 +8,12 @@ module Rubocop
|
|
6
8
|
let (:tab) { Tab.new }
|
7
9
|
|
8
10
|
it 'registers an offence for a line indented with tab' do
|
9
|
-
tab.inspect('file.rb', ["\tx = 0"])
|
11
|
+
tab.inspect('file.rb', ["\tx = 0"], nil, nil)
|
10
12
|
tab.offences.size.should == 1
|
11
13
|
end
|
12
14
|
|
13
15
|
it 'accepts a line with tab in a string' do
|
14
|
-
tab.inspect('file.rb', [%Q(x = "\t")])
|
16
|
+
tab.inspect('file.rb', [%Q(x = "\t")], nil, nil)
|
15
17
|
tab.offences.size.should == 0
|
16
18
|
end
|
17
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Rubocop
|
@@ -7,17 +9,17 @@ module Rubocop
|
|
7
9
|
|
8
10
|
it 'registers an offence for a line ending with space' do
|
9
11
|
source = ['x = 0 ']
|
10
|
-
tws.inspect('file.rb', source)
|
12
|
+
tws.inspect('file.rb', source, nil, nil)
|
11
13
|
tws.offences.size.should == 1
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'registers an offence for a line ending with tab' do
|
15
|
-
tws.inspect('file.rb', ["x = 0\t"])
|
17
|
+
tws.inspect('file.rb', ["x = 0\t"], nil, nil)
|
16
18
|
tws.offences.size.should == 1
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'accepts a line without trailing whitespace' do
|
20
|
-
tws.inspect('file.rb', ["x = 0\n"])
|
22
|
+
tws.inspect('file.rb', ["x = 0\n"], nil, nil)
|
21
23
|
tws.offences.size.should == 0
|
22
24
|
end
|
23
25
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'stringio'
|
3
5
|
|
@@ -8,8 +10,8 @@ module Rubocop
|
|
8
10
|
|
9
11
|
it 'displays parsable text' do
|
10
12
|
cop = Cop::Cop.new
|
11
|
-
cop.add_offence(:convention,
|
12
|
-
cop.add_offence(:fatal,
|
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
|
|
@@ -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,
|
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|
|
@@ -34,3 +37,8 @@ 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 = Rubocop::CLI.rip_source(source)
|
43
|
+
cop.inspect(file, source, tokens, sexp)
|
44
|
+
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -134,8 +134,10 @@ extra_rdoc_files:
|
|
134
134
|
- README.md
|
135
135
|
files:
|
136
136
|
- .document
|
137
|
+
- .rbenv-version
|
137
138
|
- .rspec
|
138
139
|
- .rvmrc
|
140
|
+
- .travis.yml
|
139
141
|
- Gemfile
|
140
142
|
- Gemfile.lock
|
141
143
|
- LICENSE.txt
|
@@ -148,12 +150,18 @@ files:
|
|
148
150
|
- features/support/env.rb
|
149
151
|
- lib/rubocop.rb
|
150
152
|
- lib/rubocop/cli.rb
|
153
|
+
- lib/rubocop/cop/align_parameters.rb
|
151
154
|
- lib/rubocop/cop/cop.rb
|
155
|
+
- lib/rubocop/cop/def_parentheses.rb
|
152
156
|
- lib/rubocop/cop/empty_lines.rb
|
153
157
|
- lib/rubocop/cop/encoding.rb
|
158
|
+
- lib/rubocop/cop/end_of_line.rb
|
154
159
|
- lib/rubocop/cop/grammar.rb
|
160
|
+
- lib/rubocop/cop/hash_syntax.rb
|
161
|
+
- lib/rubocop/cop/if_then_else.rb
|
155
162
|
- lib/rubocop/cop/indentation.rb
|
156
163
|
- lib/rubocop/cop/line_length.rb
|
164
|
+
- lib/rubocop/cop/numeric_literals.rb
|
157
165
|
- lib/rubocop/cop/offence.rb
|
158
166
|
- lib/rubocop/cop/space_after_comma_etc.rb
|
159
167
|
- lib/rubocop/cop/surrounding_space.rb
|
@@ -165,11 +173,17 @@ files:
|
|
165
173
|
- lib/rubocop/version.rb
|
166
174
|
- rubocop.gemspec
|
167
175
|
- spec/rubocop/cli_spec.rb
|
176
|
+
- spec/rubocop/cops/align_parameters_spec.rb
|
168
177
|
- spec/rubocop/cops/cop_spec.rb
|
178
|
+
- spec/rubocop/cops/def_parentheses_spec.rb
|
169
179
|
- spec/rubocop/cops/empty_lines_spec.rb
|
180
|
+
- spec/rubocop/cops/end_of_line_spec.rb
|
170
181
|
- spec/rubocop/cops/grammar_spec.rb
|
182
|
+
- spec/rubocop/cops/hash_syntax_spec.rb
|
183
|
+
- spec/rubocop/cops/if_then_else_spec.rb
|
171
184
|
- spec/rubocop/cops/indentation_spec.rb
|
172
185
|
- spec/rubocop/cops/line_length_spec.rb
|
186
|
+
- spec/rubocop/cops/numeric_literals_spec.rb
|
173
187
|
- spec/rubocop/cops/offence_spec.rb
|
174
188
|
- spec/rubocop/cops/space_after_comma_etc_spec.rb
|
175
189
|
- spec/rubocop/cops/surrounding_space_spec.rb
|
@@ -193,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
207
|
version: '0'
|
194
208
|
segments:
|
195
209
|
- 0
|
196
|
-
hash:
|
210
|
+
hash: -2416637958385031259
|
197
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
212
|
none: false
|
199
213
|
requirements:
|