rubocop 0.20.1 → 0.21.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +16 -4
- data/config/default.yml +37 -10
- data/config/enabled.yml +25 -7
- data/lib/rubocop.rb +15 -19
- data/lib/rubocop/cli.rb +2 -2
- data/lib/rubocop/config.rb +40 -3
- data/lib/rubocop/config_loader.rb +6 -37
- data/lib/rubocop/config_store.rb +0 -1
- data/lib/rubocop/cop/commissioner.rb +12 -9
- data/lib/rubocop/cop/cop.rb +17 -5
- data/lib/rubocop/cop/force.rb +41 -0
- data/lib/rubocop/cop/ignored_node.rb +10 -10
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -2
- data/lib/rubocop/cop/lint/block_alignment.rb +2 -2
- data/lib/rubocop/cop/lint/condition_position.rb +2 -0
- data/lib/rubocop/cop/lint/debugger.rb +17 -3
- data/lib/rubocop/cop/lint/end_alignment.rb +3 -11
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +11 -0
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -6
- data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +39 -0
- data/lib/rubocop/cop/lint/unused_block_argument.rb +81 -0
- data/lib/rubocop/cop/lint/unused_method_argument.rb +52 -0
- data/lib/rubocop/cop/lint/useless_assignment.rb +6 -8
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +6 -0
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +1 -1
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +2 -2
- data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +7 -3
- data/lib/rubocop/cop/mixin/check_assignment.rb +11 -0
- data/lib/rubocop/cop/mixin/check_methods.rb +12 -0
- data/lib/rubocop/cop/mixin/percent_literal.rb +26 -0
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +2 -2
- data/lib/rubocop/cop/mixin/string_help.rb +0 -4
- data/lib/rubocop/cop/rails/delegate.rb +109 -0
- data/lib/rubocop/cop/style/align_hash.rb +3 -3
- data/lib/rubocop/cop/style/class_and_module_children.rb +2 -2
- data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
- data/lib/rubocop/cop/style/dot_position.rb +1 -1
- data/lib/rubocop/cop/style/encoding.rb +44 -16
- data/lib/rubocop/cop/style/indentation_width.rb +29 -19
- data/lib/rubocop/cop/style/lambda_call.rb +1 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -1
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +3 -21
- data/lib/rubocop/cop/style/predicate_name.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +18 -2
- data/lib/rubocop/cop/style/redundant_self.rb +2 -2
- data/lib/rubocop/cop/style/regexp_literal.rb +29 -37
- data/lib/rubocop/cop/style/space_after_method_name.rb +1 -1
- data/lib/rubocop/cop/style/string_literals.rb +1 -1
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +37 -23
- data/lib/rubocop/cop/style/trailing_comma.rb +2 -3
- data/lib/rubocop/cop/style/trivial_accessors.rb +40 -4
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +29 -0
- data/lib/rubocop/cop/team.rb +10 -2
- data/lib/rubocop/cop/util.rb +2 -2
- data/lib/rubocop/cop/{variable_inspector.rb → variable_force.rb} +45 -37
- data/lib/rubocop/cop/{variable_inspector → variable_force}/assignment.rb +1 -1
- data/lib/rubocop/cop/{variable_inspector → variable_force}/locatable.rb +1 -1
- data/lib/rubocop/cop/{variable_inspector → variable_force}/reference.rb +13 -1
- data/lib/rubocop/cop/{variable_inspector → variable_force}/scope.rb +9 -1
- data/lib/rubocop/cop/{variable_inspector → variable_force}/variable.rb +14 -4
- data/lib/rubocop/cop/{variable_inspector → variable_force}/variable_table.rb +1 -1
- data/lib/rubocop/file_inspector.rb +3 -1
- data/lib/rubocop/formatter/base_formatter.rb +1 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +2 -2
- data/lib/rubocop/formatter/offense_count_formatter.rb +11 -10
- data/lib/rubocop/formatter/progress_formatter.rb +2 -2
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/options.rb +74 -58
- data/lib/rubocop/path_util.rb +17 -2
- data/lib/rubocop/rake_task.rb +23 -5
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.21.0.md +45 -0
- data/rubocop-todo.yml +6 -6
- data/rubocop.gemspec +1 -1
- data/spec/rubocop/cli_spec.rb +170 -59
- data/spec/rubocop/config_spec.rb +48 -3
- data/spec/rubocop/config_store_spec.rb +3 -3
- data/spec/rubocop/cop/commissioner_spec.rb +9 -7
- data/spec/rubocop/cop/cop_spec.rb +0 -2
- data/spec/rubocop/cop/force_spec.rb +29 -0
- data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +2 -2
- data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +1 -1
- data/spec/rubocop/cop/lint/block_alignment_spec.rb +24 -24
- data/spec/rubocop/cop/lint/condition_position_spec.rb +7 -5
- data/spec/rubocop/cop/lint/debugger_spec.rb +26 -9
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +6 -3
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +7 -6
- data/spec/rubocop/cop/lint/rescue_exception_spec.rb +36 -0
- data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +4 -4
- data/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb +179 -0
- data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +147 -0
- data/spec/rubocop/cop/lint/unused_method_argument_spec.rb +140 -0
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +50 -48
- data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +1 -1
- data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +2 -0
- data/spec/rubocop/cop/rails/delegate_spec.rb +152 -0
- data/spec/rubocop/cop/style/encoding_spec.rb +131 -36
- data/spec/rubocop/cop/style/indentation_width_spec.rb +79 -0
- data/spec/rubocop/cop/style/redundant_begin_spec.rb +32 -0
- data/spec/rubocop/cop/style/regexp_literal_spec.rb +83 -13
- data/spec/rubocop/cop/style/string_literals_spec.rb +9 -3
- data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +65 -25
- data/spec/rubocop/cop/style/trivial_accessors_spec.rb +76 -0
- data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +85 -0
- data/spec/rubocop/cop/team_spec.rb +43 -0
- data/spec/rubocop/cop/{variable_inspector → variable_force}/assignment_spec.rb +3 -3
- data/spec/rubocop/cop/{variable_inspector → variable_force}/locatable_spec.rb +3 -3
- data/spec/rubocop/cop/{variable_inspector → variable_force}/scope_spec.rb +30 -2
- data/spec/rubocop/cop/{variable_inspector → variable_force}/variable_spec.rb +12 -27
- data/spec/rubocop/cop/{variable_inspector → variable_force}/variable_table_spec.rb +1 -1
- data/spec/rubocop/cop/{variable_inspector_spec.rb → variable_force_spec.rb} +4 -8
- data/spec/rubocop/formatter/base_formatter_spec.rb +2 -2
- data/spec/rubocop/formatter/offense_count_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/progress_formatter_spec.rb +1 -1
- data/spec/rubocop/options_spec.rb +2 -2
- data/spec/rubocop/path_util_spec.rb +47 -14
- data/spec/spec_helper.rb +9 -3
- data/spec/support/file_helper.rb +2 -0
- metadata +43 -26
- data/lib/rubocop/cop/style/final_newline.rb +0 -29
- data/spec/rubocop/cop/style/final_newline_spec.rb +0 -30
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.
|
4
|
+
version: 0.21.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: 2014-04-
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2.1.
|
39
|
+
version: 2.1.9
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.1.
|
46
|
+
version: 2.1.9
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: powerpack
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/rubocop/cop/commissioner.rb
|
198
198
|
- lib/rubocop/cop/cop.rb
|
199
199
|
- lib/rubocop/cop/corrector.rb
|
200
|
+
- lib/rubocop/cop/force.rb
|
200
201
|
- lib/rubocop/cop/ignored_node.rb
|
201
202
|
- lib/rubocop/cop/lint/ambiguous_operator.rb
|
202
203
|
- lib/rubocop/cop/lint/ambiguous_regexp_literal.rb
|
@@ -224,7 +225,10 @@ files:
|
|
224
225
|
- lib/rubocop/cop/lint/space_before_first_arg.rb
|
225
226
|
- lib/rubocop/cop/lint/string_conversion_in_interpolation.rb
|
226
227
|
- lib/rubocop/cop/lint/syntax.rb
|
228
|
+
- lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb
|
227
229
|
- lib/rubocop/cop/lint/unreachable_code.rb
|
230
|
+
- lib/rubocop/cop/lint/unused_block_argument.rb
|
231
|
+
- lib/rubocop/cop/lint/unused_method_argument.rb
|
228
232
|
- lib/rubocop/cop/lint/useless_access_modifier.rb
|
229
233
|
- lib/rubocop/cop/lint/useless_assignment.rb
|
230
234
|
- lib/rubocop/cop/lint/useless_comparison.rb
|
@@ -245,6 +249,7 @@ files:
|
|
245
249
|
- lib/rubocop/cop/mixin/if_then_else.rb
|
246
250
|
- lib/rubocop/cop/mixin/negative_conditional.rb
|
247
251
|
- lib/rubocop/cop/mixin/parser_diagnostic.rb
|
252
|
+
- lib/rubocop/cop/mixin/percent_literal.rb
|
248
253
|
- lib/rubocop/cop/mixin/safe_assignment.rb
|
249
254
|
- lib/rubocop/cop/mixin/space_after_punctuation.rb
|
250
255
|
- lib/rubocop/cop/mixin/space_inside.rb
|
@@ -254,6 +259,7 @@ files:
|
|
254
259
|
- lib/rubocop/cop/offense.rb
|
255
260
|
- lib/rubocop/cop/rails/action_filter.rb
|
256
261
|
- lib/rubocop/cop/rails/default_scope.rb
|
262
|
+
- lib/rubocop/cop/rails/delegate.rb
|
257
263
|
- lib/rubocop/cop/rails/has_and_belongs_to_many.rb
|
258
264
|
- lib/rubocop/cop/rails/output.rb
|
259
265
|
- lib/rubocop/cop/rails/read_write_attribute.rb
|
@@ -304,7 +310,6 @@ files:
|
|
304
310
|
- lib/rubocop/cop/style/end_of_line.rb
|
305
311
|
- lib/rubocop/cop/style/even_odd.rb
|
306
312
|
- lib/rubocop/cop/style/file_name.rb
|
307
|
-
- lib/rubocop/cop/style/final_newline.rb
|
308
313
|
- lib/rubocop/cop/style/flip_flop.rb
|
309
314
|
- lib/rubocop/cop/style/for.rb
|
310
315
|
- lib/rubocop/cop/style/format_string.rb
|
@@ -382,6 +387,7 @@ files:
|
|
382
387
|
- lib/rubocop/cop/style/trailing_whitespace.rb
|
383
388
|
- lib/rubocop/cop/style/trivial_accessors.rb
|
384
389
|
- lib/rubocop/cop/style/unless_else.rb
|
390
|
+
- lib/rubocop/cop/style/unneeded_capital_w.rb
|
385
391
|
- lib/rubocop/cop/style/variable_interpolation.rb
|
386
392
|
- lib/rubocop/cop/style/variable_name.rb
|
387
393
|
- lib/rubocop/cop/style/when_then.rb
|
@@ -390,13 +396,13 @@ files:
|
|
390
396
|
- lib/rubocop/cop/style/word_array.rb
|
391
397
|
- lib/rubocop/cop/team.rb
|
392
398
|
- lib/rubocop/cop/util.rb
|
393
|
-
- lib/rubocop/cop/
|
394
|
-
- lib/rubocop/cop/
|
395
|
-
- lib/rubocop/cop/
|
396
|
-
- lib/rubocop/cop/
|
397
|
-
- lib/rubocop/cop/
|
398
|
-
- lib/rubocop/cop/
|
399
|
-
- lib/rubocop/cop/
|
399
|
+
- lib/rubocop/cop/variable_force.rb
|
400
|
+
- lib/rubocop/cop/variable_force/assignment.rb
|
401
|
+
- lib/rubocop/cop/variable_force/locatable.rb
|
402
|
+
- lib/rubocop/cop/variable_force/reference.rb
|
403
|
+
- lib/rubocop/cop/variable_force/scope.rb
|
404
|
+
- lib/rubocop/cop/variable_force/variable.rb
|
405
|
+
- lib/rubocop/cop/variable_force/variable_table.rb
|
400
406
|
- lib/rubocop/file_inspector.rb
|
401
407
|
- lib/rubocop/formatter/base_formatter.rb
|
402
408
|
- lib/rubocop/formatter/clang_style_formatter.rb
|
@@ -423,6 +429,7 @@ files:
|
|
423
429
|
- relnotes/v0.19.1.md
|
424
430
|
- relnotes/v0.20.0.md
|
425
431
|
- relnotes/v0.20.1.md
|
432
|
+
- relnotes/v0.21.0.md
|
426
433
|
- rubocop-todo.yml
|
427
434
|
- rubocop.gemspec
|
428
435
|
- spec/.rubocop.yml
|
@@ -436,6 +443,7 @@ files:
|
|
436
443
|
- spec/rubocop/cop/commissioner_spec.rb
|
437
444
|
- spec/rubocop/cop/cop_spec.rb
|
438
445
|
- spec/rubocop/cop/corrector_spec.rb
|
446
|
+
- spec/rubocop/cop/force_spec.rb
|
439
447
|
- spec/rubocop/cop/lint/ambiguous_operator_spec.rb
|
440
448
|
- spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb
|
441
449
|
- spec/rubocop/cop/lint/assignment_in_condition_spec.rb
|
@@ -462,7 +470,10 @@ files:
|
|
462
470
|
- spec/rubocop/cop/lint/space_before_first_arg_spec.rb
|
463
471
|
- spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb
|
464
472
|
- spec/rubocop/cop/lint/syntax_spec.rb
|
473
|
+
- spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb
|
465
474
|
- spec/rubocop/cop/lint/unreachable_code_spec.rb
|
475
|
+
- spec/rubocop/cop/lint/unused_block_argument_spec.rb
|
476
|
+
- spec/rubocop/cop/lint/unused_method_argument_spec.rb
|
466
477
|
- spec/rubocop/cop/lint/useless_access_modifier_spec.rb
|
467
478
|
- spec/rubocop/cop/lint/useless_assignment_spec.rb
|
468
479
|
- spec/rubocop/cop/lint/useless_comparison_spec.rb
|
@@ -472,6 +483,7 @@ files:
|
|
472
483
|
- spec/rubocop/cop/offense_spec.rb
|
473
484
|
- spec/rubocop/cop/rails/action_filter_spec.rb
|
474
485
|
- spec/rubocop/cop/rails/default_scope_spec.rb
|
486
|
+
- spec/rubocop/cop/rails/delegate_spec.rb
|
475
487
|
- spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb
|
476
488
|
- spec/rubocop/cop/rails/output_spec.rb
|
477
489
|
- spec/rubocop/cop/rails/read_write_attribute_spec.rb
|
@@ -522,7 +534,6 @@ files:
|
|
522
534
|
- spec/rubocop/cop/style/end_of_line_spec.rb
|
523
535
|
- spec/rubocop/cop/style/even_odd_spec.rb
|
524
536
|
- spec/rubocop/cop/style/file_name_spec.rb
|
525
|
-
- spec/rubocop/cop/style/final_newline_spec.rb
|
526
537
|
- spec/rubocop/cop/style/flip_flop_spec.rb
|
527
538
|
- spec/rubocop/cop/style/for_spec.rb
|
528
539
|
- spec/rubocop/cop/style/format_string_spec.rb
|
@@ -600,6 +611,7 @@ files:
|
|
600
611
|
- spec/rubocop/cop/style/trailing_whitespace_spec.rb
|
601
612
|
- spec/rubocop/cop/style/trivial_accessors_spec.rb
|
602
613
|
- spec/rubocop/cop/style/unless_else_spec.rb
|
614
|
+
- spec/rubocop/cop/style/unneeded_capital_w_spec.rb
|
603
615
|
- spec/rubocop/cop/style/variable_interpolation_spec.rb
|
604
616
|
- spec/rubocop/cop/style/variable_name_spec.rb
|
605
617
|
- spec/rubocop/cop/style/when_then_spec.rb
|
@@ -608,12 +620,12 @@ files:
|
|
608
620
|
- spec/rubocop/cop/style/word_array_spec.rb
|
609
621
|
- spec/rubocop/cop/team_spec.rb
|
610
622
|
- spec/rubocop/cop/util_spec.rb
|
611
|
-
- spec/rubocop/cop/
|
612
|
-
- spec/rubocop/cop/
|
613
|
-
- spec/rubocop/cop/
|
614
|
-
- spec/rubocop/cop/
|
615
|
-
- spec/rubocop/cop/
|
616
|
-
- spec/rubocop/cop/
|
623
|
+
- spec/rubocop/cop/variable_force/assignment_spec.rb
|
624
|
+
- spec/rubocop/cop/variable_force/locatable_spec.rb
|
625
|
+
- spec/rubocop/cop/variable_force/scope_spec.rb
|
626
|
+
- spec/rubocop/cop/variable_force/variable_spec.rb
|
627
|
+
- spec/rubocop/cop/variable_force/variable_table_spec.rb
|
628
|
+
- spec/rubocop/cop/variable_force_spec.rb
|
617
629
|
- spec/rubocop/file_inspector_spec.rb
|
618
630
|
- spec/rubocop/formatter/base_formatter_spec.rb
|
619
631
|
- spec/rubocop/formatter/clang_style_formatter_spec.rb
|
@@ -678,6 +690,7 @@ test_files:
|
|
678
690
|
- spec/rubocop/cop/commissioner_spec.rb
|
679
691
|
- spec/rubocop/cop/cop_spec.rb
|
680
692
|
- spec/rubocop/cop/corrector_spec.rb
|
693
|
+
- spec/rubocop/cop/force_spec.rb
|
681
694
|
- spec/rubocop/cop/lint/ambiguous_operator_spec.rb
|
682
695
|
- spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb
|
683
696
|
- spec/rubocop/cop/lint/assignment_in_condition_spec.rb
|
@@ -704,7 +717,10 @@ test_files:
|
|
704
717
|
- spec/rubocop/cop/lint/space_before_first_arg_spec.rb
|
705
718
|
- spec/rubocop/cop/lint/string_conversion_in_interpolation_spec.rb
|
706
719
|
- spec/rubocop/cop/lint/syntax_spec.rb
|
720
|
+
- spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb
|
707
721
|
- spec/rubocop/cop/lint/unreachable_code_spec.rb
|
722
|
+
- spec/rubocop/cop/lint/unused_block_argument_spec.rb
|
723
|
+
- spec/rubocop/cop/lint/unused_method_argument_spec.rb
|
708
724
|
- spec/rubocop/cop/lint/useless_access_modifier_spec.rb
|
709
725
|
- spec/rubocop/cop/lint/useless_assignment_spec.rb
|
710
726
|
- spec/rubocop/cop/lint/useless_comparison_spec.rb
|
@@ -714,6 +730,7 @@ test_files:
|
|
714
730
|
- spec/rubocop/cop/offense_spec.rb
|
715
731
|
- spec/rubocop/cop/rails/action_filter_spec.rb
|
716
732
|
- spec/rubocop/cop/rails/default_scope_spec.rb
|
733
|
+
- spec/rubocop/cop/rails/delegate_spec.rb
|
717
734
|
- spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb
|
718
735
|
- spec/rubocop/cop/rails/output_spec.rb
|
719
736
|
- spec/rubocop/cop/rails/read_write_attribute_spec.rb
|
@@ -764,7 +781,6 @@ test_files:
|
|
764
781
|
- spec/rubocop/cop/style/end_of_line_spec.rb
|
765
782
|
- spec/rubocop/cop/style/even_odd_spec.rb
|
766
783
|
- spec/rubocop/cop/style/file_name_spec.rb
|
767
|
-
- spec/rubocop/cop/style/final_newline_spec.rb
|
768
784
|
- spec/rubocop/cop/style/flip_flop_spec.rb
|
769
785
|
- spec/rubocop/cop/style/for_spec.rb
|
770
786
|
- spec/rubocop/cop/style/format_string_spec.rb
|
@@ -842,6 +858,7 @@ test_files:
|
|
842
858
|
- spec/rubocop/cop/style/trailing_whitespace_spec.rb
|
843
859
|
- spec/rubocop/cop/style/trivial_accessors_spec.rb
|
844
860
|
- spec/rubocop/cop/style/unless_else_spec.rb
|
861
|
+
- spec/rubocop/cop/style/unneeded_capital_w_spec.rb
|
845
862
|
- spec/rubocop/cop/style/variable_interpolation_spec.rb
|
846
863
|
- spec/rubocop/cop/style/variable_name_spec.rb
|
847
864
|
- spec/rubocop/cop/style/when_then_spec.rb
|
@@ -850,12 +867,12 @@ test_files:
|
|
850
867
|
- spec/rubocop/cop/style/word_array_spec.rb
|
851
868
|
- spec/rubocop/cop/team_spec.rb
|
852
869
|
- spec/rubocop/cop/util_spec.rb
|
853
|
-
- spec/rubocop/cop/
|
854
|
-
- spec/rubocop/cop/
|
855
|
-
- spec/rubocop/cop/
|
856
|
-
- spec/rubocop/cop/
|
857
|
-
- spec/rubocop/cop/
|
858
|
-
- spec/rubocop/cop/
|
870
|
+
- spec/rubocop/cop/variable_force/assignment_spec.rb
|
871
|
+
- spec/rubocop/cop/variable_force/locatable_spec.rb
|
872
|
+
- spec/rubocop/cop/variable_force/scope_spec.rb
|
873
|
+
- spec/rubocop/cop/variable_force/variable_spec.rb
|
874
|
+
- spec/rubocop/cop/variable_force/variable_table_spec.rb
|
875
|
+
- spec/rubocop/cop/variable_force_spec.rb
|
859
876
|
- spec/rubocop/file_inspector_spec.rb
|
860
877
|
- spec/rubocop/formatter/base_formatter_spec.rb
|
861
878
|
- spec/rubocop/formatter/clang_style_formatter_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Rubocop
|
4
|
-
module Cop
|
5
|
-
module Style
|
6
|
-
# This cop enforces the presence of a final newline in each source file.
|
7
|
-
class FinalNewline < Cop
|
8
|
-
MSG = 'Source files should end with a newline (\n).'
|
9
|
-
|
10
|
-
def investigate(processed_source)
|
11
|
-
final_line = processed_source.raw_lines.to_a.last
|
12
|
-
|
13
|
-
unless final_line.nil? || final_line.end_with?("\n")
|
14
|
-
range = source_range(processed_source.buffer,
|
15
|
-
processed_source[0...-1],
|
16
|
-
final_line.length - 1, 1)
|
17
|
-
add_offense(range, range)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def autocorrect(range)
|
22
|
-
@corrections << lambda do |corrector|
|
23
|
-
corrector.insert_after(range, "\n")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Rubocop::Cop::Style::FinalNewline do
|
6
|
-
subject(:cop) { described_class.new }
|
7
|
-
|
8
|
-
it 'registers an offense for missing final newline' do
|
9
|
-
source = ['x = 0', 'top']
|
10
|
-
inspect_source(cop, source)
|
11
|
-
expect(cop.offenses.size).to eq(1)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'accepts a final newline' do
|
15
|
-
source = ['x = 0', 'top', '']
|
16
|
-
inspect_source(cop, source)
|
17
|
-
expect(cop.offenses).to be_empty
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'accepts an empty file' do
|
21
|
-
source = ['']
|
22
|
-
inspect_source(cop, source)
|
23
|
-
expect(cop.offenses).to be_empty
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'auto-corrects missing newline' do
|
27
|
-
new_source = autocorrect_source(cop, ['x = 0'])
|
28
|
-
expect(new_source).to eq(['x = 0', ''].join("\n"))
|
29
|
-
end
|
30
|
-
end
|