rubocop 0.11.1 → 0.12.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.

Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -1
  3. data/README.md +28 -3
  4. data/config/default.yml +14 -12
  5. data/config/disabled.yml +1 -1
  6. data/config/enabled.yml +190 -118
  7. data/lib/rubocop.rb +9 -1
  8. data/lib/rubocop/cli.rb +49 -13
  9. data/lib/rubocop/config.rb +5 -5
  10. data/lib/rubocop/cop/cop.rb +34 -1
  11. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +47 -0
  12. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -4
  13. data/lib/rubocop/cop/lint/useless_assignment.rb +39 -11
  14. data/lib/rubocop/cop/lint/useless_comparison.rb +2 -4
  15. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +20 -0
  16. data/lib/rubocop/cop/rails/read_attribute.rb +28 -0
  17. data/lib/rubocop/cop/style/access_control.rb +12 -1
  18. data/lib/rubocop/cop/style/attr.rb +7 -0
  19. data/lib/rubocop/cop/style/collection_methods.rb +13 -1
  20. data/lib/rubocop/cop/style/constant_name.rb +1 -1
  21. data/lib/rubocop/cop/style/def_parentheses.rb +18 -0
  22. data/lib/rubocop/cop/style/documentation.rb +1 -1
  23. data/lib/rubocop/cop/style/empty_literal.rb +14 -0
  24. data/lib/rubocop/cop/style/even_odd.rb +56 -0
  25. data/lib/rubocop/cop/style/favor_modifier.rb +2 -2
  26. data/lib/rubocop/cop/style/hash_methods.rb +40 -0
  27. data/lib/rubocop/cop/style/indentation_width.rb +148 -0
  28. data/lib/rubocop/cop/style/method_and_variable_snake_case.rb +40 -25
  29. data/lib/rubocop/cop/style/method_call_parentheses.rb +8 -0
  30. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  31. data/lib/rubocop/cop/style/nil_comparison.rb +38 -0
  32. data/lib/rubocop/cop/style/signal_exception.rb +11 -0
  33. data/lib/rubocop/cop/style/space_after_method_name.rb +34 -0
  34. data/lib/rubocop/cop/util.rb +17 -0
  35. data/lib/rubocop/formatter/emacs_style_formatter.rb +2 -2
  36. data/lib/rubocop/formatter/file_list_formatter.rb +3 -2
  37. data/lib/rubocop/formatter/formatter_set.rb +3 -11
  38. data/lib/rubocop/formatter/offence_count_formatter.rb +50 -0
  39. data/lib/rubocop/formatter/progress_formatter.rb +0 -2
  40. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -6
  41. data/lib/rubocop/version.rb +1 -1
  42. data/spec/project_spec.rb +7 -0
  43. data/spec/rubocop/cli_spec.rb +119 -57
  44. data/spec/rubocop/config_spec.rb +23 -17
  45. data/spec/rubocop/cop/commissioner_spec.rb +8 -8
  46. data/spec/rubocop/cop/cop_spec.rb +80 -0
  47. data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +63 -0
  48. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +59 -0
  49. data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +19 -0
  50. data/spec/rubocop/cop/rails/read_attribute_spec.rb +19 -0
  51. data/spec/rubocop/cop/rails/validation_spec.rb +5 -5
  52. data/spec/rubocop/cop/style/access_control_spec.rb +28 -0
  53. data/spec/rubocop/cop/style/attr_spec.rb +6 -1
  54. data/spec/rubocop/cop/style/collection_methods_spec.rb +5 -0
  55. data/spec/rubocop/cop/style/constant_name_spec.rb +9 -0
  56. data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +14 -9
  57. data/spec/rubocop/cop/style/def_without_parentheses_spec.rb +12 -7
  58. data/spec/rubocop/cop/style/empty_literal_spec.rb +42 -27
  59. data/spec/rubocop/cop/style/even_odd_spec.rb +47 -0
  60. data/spec/rubocop/cop/style/favor_modifier_spec.rb +15 -14
  61. data/spec/rubocop/cop/style/hash_methods_spec.rb +51 -0
  62. data/spec/rubocop/cop/style/indentation_width_spec.rb +390 -0
  63. data/spec/rubocop/cop/style/method_and_variable_snake_case_spec.rb +58 -50
  64. data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +6 -1
  65. data/spec/rubocop/cop/style/nil_comparison_spec.rb +31 -0
  66. data/spec/rubocop/cop/style/signal_exception_spec.rb +28 -0
  67. data/spec/rubocop/cop/style/space_after_method_name_spec.rb +61 -0
  68. data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +9 -2
  69. data/spec/rubocop/formatter/file_list_formatter_spec.rb +3 -3
  70. data/spec/rubocop/formatter/offence_count_formatter_spec.rb +52 -0
  71. data/spec/rubocop/formatter/progress_formatter_spec.rb +70 -84
  72. data/spec/rubocop/source_parser_spec.rb +1 -1
  73. metadata +29 -5
  74. data/lib/rubocop/cop/style/line_continuation.rb +0 -27
  75. data/spec/rubocop/cop/style/line_continuation_spec.rb +0 -26
@@ -25,7 +25,7 @@ module Rubocop
25
25
  create_file(file, source)
26
26
  end
27
27
 
28
- let (:processed_source) do
28
+ let(:processed_source) do
29
29
  SourceParser.parse_file(file)
30
30
  end
31
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-12 00:00:00.000000000 Z
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -179,6 +179,7 @@ files:
179
179
  - lib/rubocop/cop/lint/handle_exceptions.rb
180
180
  - lib/rubocop/cop/lint/literal_in_condition.rb
181
181
  - lib/rubocop/cop/lint/loop.rb
182
+ - lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
182
183
  - lib/rubocop/cop/lint/rescue_exception.rb
183
184
  - lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
184
185
  - lib/rubocop/cop/lint/unreachable_code.rb
@@ -187,6 +188,8 @@ files:
187
188
  - lib/rubocop/cop/lint/useless_comparison.rb
188
189
  - lib/rubocop/cop/lint/void.rb
189
190
  - lib/rubocop/cop/offence.rb
191
+ - lib/rubocop/cop/rails/has_and_belongs_to_many.rb
192
+ - lib/rubocop/cop/rails/read_attribute.rb
190
193
  - lib/rubocop/cop/rails/validation.rb
191
194
  - lib/rubocop/cop/style/access_control.rb
192
195
  - lib/rubocop/cop/style/alias.rb
@@ -222,22 +225,25 @@ files:
222
225
  - lib/rubocop/cop/style/encoding.rb
223
226
  - lib/rubocop/cop/style/end_block.rb
224
227
  - lib/rubocop/cop/style/end_of_line.rb
228
+ - lib/rubocop/cop/style/even_odd.rb
225
229
  - lib/rubocop/cop/style/favor_join.rb
226
230
  - lib/rubocop/cop/style/favor_modifier.rb
227
231
  - lib/rubocop/cop/style/favor_sprintf.rb
228
232
  - lib/rubocop/cop/style/favor_unless_over_negated_if.rb
233
+ - lib/rubocop/cop/style/hash_methods.rb
229
234
  - lib/rubocop/cop/style/hash_syntax.rb
230
235
  - lib/rubocop/cop/style/if_then_else.rb
231
236
  - lib/rubocop/cop/style/if_with_semicolon.rb
237
+ - lib/rubocop/cop/style/indentation_width.rb
232
238
  - lib/rubocop/cop/style/lambda.rb
233
239
  - lib/rubocop/cop/style/leading_comment_space.rb
234
- - lib/rubocop/cop/style/line_continuation.rb
235
240
  - lib/rubocop/cop/style/line_length.rb
236
241
  - lib/rubocop/cop/style/method_and_variable_snake_case.rb
237
242
  - lib/rubocop/cop/style/method_call_parentheses.rb
238
243
  - lib/rubocop/cop/style/method_length.rb
239
244
  - lib/rubocop/cop/style/module_function.rb
240
245
  - lib/rubocop/cop/style/multiline_if_then.rb
246
+ - lib/rubocop/cop/style/nil_comparison.rb
241
247
  - lib/rubocop/cop/style/not.rb
242
248
  - lib/rubocop/cop/style/numeric_literals.rb
243
249
  - lib/rubocop/cop/style/one_line_conditional.rb
@@ -256,6 +262,7 @@ files:
256
262
  - lib/rubocop/cop/style/single_line_methods.rb
257
263
  - lib/rubocop/cop/style/space_after_comma_etc.rb
258
264
  - lib/rubocop/cop/style/space_after_control_keyword.rb
265
+ - lib/rubocop/cop/style/space_after_method_name.rb
259
266
  - lib/rubocop/cop/style/string_literals.rb
260
267
  - lib/rubocop/cop/style/surrounding_space.rb
261
268
  - lib/rubocop/cop/style/symbol_array.rb
@@ -278,6 +285,7 @@ files:
278
285
  - lib/rubocop/formatter/file_list_formatter.rb
279
286
  - lib/rubocop/formatter/formatter_set.rb
280
287
  - lib/rubocop/formatter/json_formatter.rb
288
+ - lib/rubocop/formatter/offence_count_formatter.rb
281
289
  - lib/rubocop/formatter/progress_formatter.rb
282
290
  - lib/rubocop/formatter/simple_text_formatter.rb
283
291
  - lib/rubocop/processed_source.rb
@@ -305,6 +313,7 @@ files:
305
313
  - spec/rubocop/cop/lint/handle_exceptions_spec.rb
306
314
  - spec/rubocop/cop/lint/literal_in_condition_spec.rb
307
315
  - spec/rubocop/cop/lint/loop_spec.rb
316
+ - spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb
308
317
  - spec/rubocop/cop/lint/rescue_exception_spec.rb
309
318
  - spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb
310
319
  - spec/rubocop/cop/lint/unreachable_code_spec.rb
@@ -313,6 +322,8 @@ files:
313
322
  - spec/rubocop/cop/lint/useless_comparison_spec.rb
314
323
  - spec/rubocop/cop/lint/void_spec.rb
315
324
  - spec/rubocop/cop/offence_spec.rb
325
+ - spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb
326
+ - spec/rubocop/cop/rails/read_attribute_spec.rb
316
327
  - spec/rubocop/cop/rails/validation_spec.rb
317
328
  - spec/rubocop/cop/style/access_control_spec.rb
318
329
  - spec/rubocop/cop/style/alias_spec.rb
@@ -349,22 +360,25 @@ files:
349
360
  - spec/rubocop/cop/style/encoding_spec.rb
350
361
  - spec/rubocop/cop/style/end_block_spec.rb
351
362
  - spec/rubocop/cop/style/end_of_line_spec.rb
363
+ - spec/rubocop/cop/style/even_odd_spec.rb
352
364
  - spec/rubocop/cop/style/favor_join_spec.rb
353
365
  - spec/rubocop/cop/style/favor_modifier_spec.rb
354
366
  - spec/rubocop/cop/style/favor_sprintf_spec.rb
355
367
  - spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb
356
368
  - spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb
369
+ - spec/rubocop/cop/style/hash_methods_spec.rb
357
370
  - spec/rubocop/cop/style/hash_syntax_spec.rb
358
371
  - spec/rubocop/cop/style/if_with_semicolon_spec.rb
372
+ - spec/rubocop/cop/style/indentation_width_spec.rb
359
373
  - spec/rubocop/cop/style/lambda_spec.rb
360
374
  - spec/rubocop/cop/style/leading_comment_space_spec.rb
361
- - spec/rubocop/cop/style/line_continuation_spec.rb
362
375
  - spec/rubocop/cop/style/line_length_spec.rb
363
376
  - spec/rubocop/cop/style/method_and_variable_snake_case_spec.rb
364
377
  - spec/rubocop/cop/style/method_call_parentheses_spec.rb
365
378
  - spec/rubocop/cop/style/method_length_spec.rb
366
379
  - spec/rubocop/cop/style/module_function_spec.rb
367
380
  - spec/rubocop/cop/style/multiline_if_then_spec.rb
381
+ - spec/rubocop/cop/style/nil_comparison_spec.rb
368
382
  - spec/rubocop/cop/style/not_spec.rb
369
383
  - spec/rubocop/cop/style/numeric_literals_spec.rb
370
384
  - spec/rubocop/cop/style/one_line_conditional_spec.rb
@@ -384,6 +398,7 @@ files:
384
398
  - spec/rubocop/cop/style/space_after_colon_spec.rb
385
399
  - spec/rubocop/cop/style/space_after_comma_spec.rb
386
400
  - spec/rubocop/cop/style/space_after_control_keyword_spec.rb
401
+ - spec/rubocop/cop/style/space_after_method_name_spec.rb
387
402
  - spec/rubocop/cop/style/space_after_semicolon_spec.rb
388
403
  - spec/rubocop/cop/style/space_around_braces_spec.rb
389
404
  - spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb
@@ -411,6 +426,7 @@ files:
411
426
  - spec/rubocop/formatter/file_list_formatter_spec.rb
412
427
  - spec/rubocop/formatter/formatter_set_spec.rb
413
428
  - spec/rubocop/formatter/json_formatter_spec.rb
429
+ - spec/rubocop/formatter/offence_count_formatter_spec.rb
414
430
  - spec/rubocop/formatter/progress_formatter_spec.rb
415
431
  - spec/rubocop/formatter/simple_text_formatter_spec.rb
416
432
  - spec/rubocop/processed_source_spec.rb
@@ -465,6 +481,7 @@ test_files:
465
481
  - spec/rubocop/cop/lint/handle_exceptions_spec.rb
466
482
  - spec/rubocop/cop/lint/literal_in_condition_spec.rb
467
483
  - spec/rubocop/cop/lint/loop_spec.rb
484
+ - spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb
468
485
  - spec/rubocop/cop/lint/rescue_exception_spec.rb
469
486
  - spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb
470
487
  - spec/rubocop/cop/lint/unreachable_code_spec.rb
@@ -473,6 +490,8 @@ test_files:
473
490
  - spec/rubocop/cop/lint/useless_comparison_spec.rb
474
491
  - spec/rubocop/cop/lint/void_spec.rb
475
492
  - spec/rubocop/cop/offence_spec.rb
493
+ - spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb
494
+ - spec/rubocop/cop/rails/read_attribute_spec.rb
476
495
  - spec/rubocop/cop/rails/validation_spec.rb
477
496
  - spec/rubocop/cop/style/access_control_spec.rb
478
497
  - spec/rubocop/cop/style/alias_spec.rb
@@ -509,22 +528,25 @@ test_files:
509
528
  - spec/rubocop/cop/style/encoding_spec.rb
510
529
  - spec/rubocop/cop/style/end_block_spec.rb
511
530
  - spec/rubocop/cop/style/end_of_line_spec.rb
531
+ - spec/rubocop/cop/style/even_odd_spec.rb
512
532
  - spec/rubocop/cop/style/favor_join_spec.rb
513
533
  - spec/rubocop/cop/style/favor_modifier_spec.rb
514
534
  - spec/rubocop/cop/style/favor_sprintf_spec.rb
515
535
  - spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb
516
536
  - spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb
537
+ - spec/rubocop/cop/style/hash_methods_spec.rb
517
538
  - spec/rubocop/cop/style/hash_syntax_spec.rb
518
539
  - spec/rubocop/cop/style/if_with_semicolon_spec.rb
540
+ - spec/rubocop/cop/style/indentation_width_spec.rb
519
541
  - spec/rubocop/cop/style/lambda_spec.rb
520
542
  - spec/rubocop/cop/style/leading_comment_space_spec.rb
521
- - spec/rubocop/cop/style/line_continuation_spec.rb
522
543
  - spec/rubocop/cop/style/line_length_spec.rb
523
544
  - spec/rubocop/cop/style/method_and_variable_snake_case_spec.rb
524
545
  - spec/rubocop/cop/style/method_call_parentheses_spec.rb
525
546
  - spec/rubocop/cop/style/method_length_spec.rb
526
547
  - spec/rubocop/cop/style/module_function_spec.rb
527
548
  - spec/rubocop/cop/style/multiline_if_then_spec.rb
549
+ - spec/rubocop/cop/style/nil_comparison_spec.rb
528
550
  - spec/rubocop/cop/style/not_spec.rb
529
551
  - spec/rubocop/cop/style/numeric_literals_spec.rb
530
552
  - spec/rubocop/cop/style/one_line_conditional_spec.rb
@@ -544,6 +566,7 @@ test_files:
544
566
  - spec/rubocop/cop/style/space_after_colon_spec.rb
545
567
  - spec/rubocop/cop/style/space_after_comma_spec.rb
546
568
  - spec/rubocop/cop/style/space_after_control_keyword_spec.rb
569
+ - spec/rubocop/cop/style/space_after_method_name_spec.rb
547
570
  - spec/rubocop/cop/style/space_after_semicolon_spec.rb
548
571
  - spec/rubocop/cop/style/space_around_braces_spec.rb
549
572
  - spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb
@@ -571,6 +594,7 @@ test_files:
571
594
  - spec/rubocop/formatter/file_list_formatter_spec.rb
572
595
  - spec/rubocop/formatter/formatter_set_spec.rb
573
596
  - spec/rubocop/formatter/json_formatter_spec.rb
597
+ - spec/rubocop/formatter/offence_count_formatter_spec.rb
574
598
  - spec/rubocop/formatter/progress_formatter_spec.rb
575
599
  - spec/rubocop/formatter/simple_text_formatter_spec.rb
576
600
  - spec/rubocop/processed_source_spec.rb
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Rubocop
4
- module Cop
5
- module Style
6
- # This cop checks for uses of the line continuation character.
7
- #
8
- # This check has to be refined or retired, since it doesn't make a lot
9
- # of sense without inspection of its context.
10
- class LineContinuation < Cop
11
- MSG = 'Avoid the use of the line continuation character(\).'
12
-
13
- def investigate(processed_source)
14
- processed_source.lines.each_with_index do |line, index|
15
- if line =~ /.*\\\z/
16
- add_offence(:convention,
17
- source_range(processed_source.buffer,
18
- processed_source[0...index],
19
- line.length - 1, 1),
20
- MSG)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,26 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module Rubocop
6
- module Cop
7
- module Style
8
- describe LineContinuation do
9
- let(:lc) { LineContinuation.new }
10
-
11
- it 'registers an offence for line continuation char' do
12
- inspect_source(lc,
13
- ['test = 5 \\', '+ 5'])
14
- expect(lc.offences.size).to eq(1)
15
- end
16
-
17
- it 'does not register an offence for cont char in a string' do
18
- inspect_source(lc,
19
- ['result = "test string\\\n"',
20
- 'more'])
21
- expect(lc.offences).to be_empty
22
- end
23
- end
24
- end
25
- end
26
- end