rubocop 0.36.0 → 0.37.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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +62 -2
  3. data/README.md +10 -1
  4. data/assets/output.html.erb +55 -1
  5. data/config/default.yml +9 -3
  6. data/config/disabled.yml +21 -0
  7. data/config/enabled.yml +11 -10
  8. data/lib/rubocop.rb +9 -2
  9. data/lib/rubocop/ast_node.rb +67 -19
  10. data/lib/rubocop/ast_node/builder.rb +1 -0
  11. data/lib/rubocop/ast_node/sexp.rb +1 -0
  12. data/lib/rubocop/ast_node/traversal.rb +171 -0
  13. data/lib/rubocop/cached_data.rb +4 -1
  14. data/lib/rubocop/cli.rb +1 -1
  15. data/lib/rubocop/config.rb +36 -20
  16. data/lib/rubocop/config_loader.rb +6 -5
  17. data/lib/rubocop/cop/commissioner.rb +27 -18
  18. data/lib/rubocop/cop/cop.rb +7 -6
  19. data/lib/rubocop/cop/lint/duplicated_key.rb +1 -8
  20. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
  21. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +18 -1
  22. data/lib/rubocop/cop/lint/nested_method_definition.rb +5 -1
  23. data/lib/rubocop/cop/lint/unneeded_disable.rb +1 -1
  24. data/lib/rubocop/cop/mixin/array_hash_indentation.rb +1 -0
  25. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +9 -2
  26. data/lib/rubocop/cop/mixin/check_assignment.rb +1 -1
  27. data/lib/rubocop/cop/mixin/classish_length.rb +3 -4
  28. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +8 -4
  29. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  30. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +2 -1
  31. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +35 -0
  32. data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
  33. data/lib/rubocop/cop/mixin/min_body_length.rb +1 -1
  34. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +58 -0
  35. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  36. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  37. data/lib/rubocop/cop/mixin/trailing_comma.rb +3 -2
  38. data/lib/rubocop/cop/performance/case_when_splat.rb +7 -0
  39. data/lib/rubocop/cop/performance/casecmp.rb +56 -17
  40. data/lib/rubocop/cop/performance/redundant_block_call.rb +17 -3
  41. data/lib/rubocop/cop/performance/redundant_merge.rb +7 -1
  42. data/lib/rubocop/cop/performance/times_map.rb +3 -4
  43. data/lib/rubocop/cop/severity.rb +1 -1
  44. data/lib/rubocop/cop/style/align_hash.rb +1 -1
  45. data/lib/rubocop/cop/style/align_parameters.rb +1 -1
  46. data/lib/rubocop/cop/style/and_or.rb +1 -1
  47. data/lib/rubocop/cop/style/block_comments.rb +2 -0
  48. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -0
  49. data/lib/rubocop/cop/style/copyright.rb +2 -2
  50. data/lib/rubocop/cop/style/documentation.rb +19 -29
  51. data/lib/rubocop/cop/style/each_with_object.rb +1 -1
  52. data/lib/rubocop/cop/style/else_alignment.rb +2 -2
  53. data/lib/rubocop/cop/style/encoding.rb +1 -1
  54. data/lib/rubocop/cop/style/first_parameter_indentation.rb +1 -1
  55. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +2 -12
  56. data/lib/rubocop/cop/style/guard_clause.rb +2 -1
  57. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -8
  58. data/lib/rubocop/cop/style/indent_assignment.rb +1 -1
  59. data/lib/rubocop/cop/style/indentation_width.rb +3 -7
  60. data/lib/rubocop/cop/style/method_call_parentheses.rb +2 -1
  61. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  62. data/lib/rubocop/cop/style/multiline_array_brace_layout.rb +3 -41
  63. data/lib/rubocop/cop/style/multiline_hash_brace_layout.rb +57 -0
  64. data/lib/rubocop/cop/style/multiline_method_call_brace_layout.rb +65 -0
  65. data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +5 -4
  66. data/lib/rubocop/cop/style/multiline_method_definition_brace_layout.rb +62 -0
  67. data/lib/rubocop/cop/style/multiline_operation_indentation.rb +9 -3
  68. data/lib/rubocop/cop/style/mutable_constant.rb +18 -3
  69. data/lib/rubocop/cop/style/nested_modifier.rb +5 -2
  70. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -1
  71. data/lib/rubocop/cop/style/next.rb +32 -11
  72. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  73. data/lib/rubocop/cop/style/redundant_freeze.rb +13 -3
  74. data/lib/rubocop/cop/style/redundant_parentheses.rb +33 -7
  75. data/lib/rubocop/cop/style/send.rb +1 -1
  76. data/lib/rubocop/cop/style/space_around_keyword.rb +198 -0
  77. data/lib/rubocop/cop/style/space_around_operators.rb +2 -12
  78. data/lib/rubocop/cop/style/space_inside_block_braces.rb +1 -1
  79. data/lib/rubocop/cop/style/special_global_vars.rb +4 -4
  80. data/lib/rubocop/cop/style/symbol_array.rb +1 -1
  81. data/lib/rubocop/cop/style/trailing_blank_lines.rb +1 -1
  82. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +1 -0
  83. data/lib/rubocop/cop/style/trailing_comma_in_literal.rb +1 -0
  84. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  85. data/lib/rubocop/cop/style/zero_length_predicate.rb +55 -0
  86. data/lib/rubocop/cop/team.rb +30 -5
  87. data/lib/rubocop/cop/util.rb +16 -1
  88. data/lib/rubocop/cop/variable_force.rb +3 -12
  89. data/lib/rubocop/cop/variable_force/assignment.rb +3 -3
  90. data/lib/rubocop/cop/variable_force/locatable.rb +25 -6
  91. data/lib/rubocop/cop/variable_force/reference.rb +3 -3
  92. data/lib/rubocop/cop/variable_force/scope.rb +8 -7
  93. data/lib/rubocop/cop/variable_force/variable.rb +3 -3
  94. data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
  95. data/lib/rubocop/formatter/formatter_set.rb +2 -2
  96. data/lib/rubocop/node_pattern.rb +1 -1
  97. data/lib/rubocop/options.rb +10 -10
  98. data/lib/rubocop/path_util.rb +5 -0
  99. data/lib/rubocop/processed_source.rb +8 -2
  100. data/lib/rubocop/result_cache.rb +1 -1
  101. data/lib/rubocop/runner.rb +1 -1
  102. data/lib/rubocop/token.rb +2 -2
  103. data/lib/rubocop/version.rb +1 -1
  104. data/relnotes/v0.30.1.md +1 -0
  105. data/relnotes/v0.33.0.md +1 -1
  106. data/relnotes/v0.36.0.md +2 -1
  107. data/relnotes/v0.37.0.md +200 -0
  108. data/rubocop.gemspec +2 -1
  109. metadata +28 -7
  110. data/lib/rubocop/cop/style/space_after_control_keyword.rb +0 -35
  111. data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +0 -38
@@ -40,9 +40,10 @@ Gem::Specification.new do |s|
40
40
  s.summary = 'Automatic Ruby code style checking tool.'
41
41
 
42
42
  s.add_runtime_dependency('rainbow', '>= 1.99.1', '< 3.0')
43
- s.add_runtime_dependency('parser', '>= 2.3.0.0', '< 3.0')
43
+ s.add_runtime_dependency('parser', '>= 2.3.0.2', '< 3.0')
44
44
  s.add_runtime_dependency('powerpack', '~> 0.1')
45
45
  s.add_runtime_dependency('ruby-progressbar', '~> 1.7')
46
+ s.add_runtime_dependency('unicode-display_width', '~> 0.3')
46
47
 
47
48
  s.add_development_dependency('bundler', '~> 1.3')
48
49
  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.36.0
4
+ version: 0.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-14 00:00:00.000000000 Z
13
+ date: 2016-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rainbow
@@ -38,7 +38,7 @@ dependencies:
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 2.3.0.0
41
+ version: 2.3.0.2
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
44
  version: '3.0'
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 2.3.0.0
51
+ version: 2.3.0.2
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: unicode-display_width
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.3'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.3'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +134,7 @@ files:
120
134
  - lib/rubocop/ast_node.rb
121
135
  - lib/rubocop/ast_node/builder.rb
122
136
  - lib/rubocop/ast_node/sexp.rb
137
+ - lib/rubocop/ast_node/traversal.rb
123
138
  - lib/rubocop/cached_data.rb
124
139
  - lib/rubocop/cli.rb
125
140
  - lib/rubocop/comment_config.rb
@@ -205,12 +220,14 @@ files:
205
220
  - lib/rubocop/cop/mixin/empty_lines_around_body.rb
206
221
  - lib/rubocop/cop/mixin/end_keyword_alignment.rb
207
222
  - lib/rubocop/cop/mixin/first_element_line_break.rb
223
+ - lib/rubocop/cop/mixin/frozen_string_literal.rb
208
224
  - lib/rubocop/cop/mixin/hash_node.rb
209
225
  - lib/rubocop/cop/mixin/if_node.rb
210
226
  - lib/rubocop/cop/mixin/method_complexity.rb
211
227
  - lib/rubocop/cop/mixin/method_preference.rb
212
228
  - lib/rubocop/cop/mixin/min_body_length.rb
213
229
  - lib/rubocop/cop/mixin/multiline_expression_indentation.rb
230
+ - lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb
214
231
  - lib/rubocop/cop/mixin/negative_conditional.rb
215
232
  - lib/rubocop/cop/mixin/on_method_def.rb
216
233
  - lib/rubocop/cop/mixin/on_normal_if_unless.rb
@@ -358,8 +375,11 @@ files:
358
375
  - lib/rubocop/cop/style/multiline_assignment_layout.rb
359
376
  - lib/rubocop/cop/style/multiline_block_chain.rb
360
377
  - lib/rubocop/cop/style/multiline_block_layout.rb
378
+ - lib/rubocop/cop/style/multiline_hash_brace_layout.rb
361
379
  - lib/rubocop/cop/style/multiline_if_then.rb
380
+ - lib/rubocop/cop/style/multiline_method_call_brace_layout.rb
362
381
  - lib/rubocop/cop/style/multiline_method_call_indentation.rb
382
+ - lib/rubocop/cop/style/multiline_method_definition_brace_layout.rb
363
383
  - lib/rubocop/cop/style/multiline_operation_indentation.rb
364
384
  - lib/rubocop/cop/style/multiline_ternary_operator.rb
365
385
  - lib/rubocop/cop/style/mutable_constant.rb
@@ -402,18 +422,17 @@ files:
402
422
  - lib/rubocop/cop/style/single_line_methods.rb
403
423
  - lib/rubocop/cop/style/space_after_colon.rb
404
424
  - lib/rubocop/cop/style/space_after_comma.rb
405
- - lib/rubocop/cop/style/space_after_control_keyword.rb
406
425
  - lib/rubocop/cop/style/space_after_method_name.rb
407
426
  - lib/rubocop/cop/style/space_after_not.rb
408
427
  - lib/rubocop/cop/style/space_after_semicolon.rb
409
428
  - lib/rubocop/cop/style/space_around_block_parameters.rb
410
429
  - lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb
430
+ - lib/rubocop/cop/style/space_around_keyword.rb
411
431
  - lib/rubocop/cop/style/space_around_operators.rb
412
432
  - lib/rubocop/cop/style/space_before_block_braces.rb
413
433
  - lib/rubocop/cop/style/space_before_comma.rb
414
434
  - lib/rubocop/cop/style/space_before_comment.rb
415
435
  - lib/rubocop/cop/style/space_before_first_arg.rb
416
- - lib/rubocop/cop/style/space_before_modifier_keyword.rb
417
436
  - lib/rubocop/cop/style/space_before_semicolon.rb
418
437
  - lib/rubocop/cop/style/space_inside_block_braces.rb
419
438
  - lib/rubocop/cop/style/space_inside_brackets.rb
@@ -447,6 +466,7 @@ files:
447
466
  - lib/rubocop/cop/style/while_until_do.rb
448
467
  - lib/rubocop/cop/style/while_until_modifier.rb
449
468
  - lib/rubocop/cop/style/word_array.rb
469
+ - lib/rubocop/cop/style/zero_length_predicate.rb
450
470
  - lib/rubocop/cop/team.rb
451
471
  - lib/rubocop/cop/util.rb
452
472
  - lib/rubocop/cop/variable_force.rb
@@ -518,6 +538,7 @@ files:
518
538
  - relnotes/v0.34.2.md
519
539
  - relnotes/v0.35.0.md
520
540
  - relnotes/v0.36.0.md
541
+ - relnotes/v0.37.0.md
521
542
  - rubocop.gemspec
522
543
  homepage: http://github.com/bbatsov/rubocop
523
544
  licenses:
@@ -539,7 +560,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
539
560
  version: '0'
540
561
  requirements: []
541
562
  rubyforge_project:
542
- rubygems_version: 2.4.5
563
+ rubygems_version: 2.2.2
543
564
  signing_key:
544
565
  specification_version: 4
545
566
  summary: Automatic Ruby code style checking tool.
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
-
4
- module RuboCop
5
- module Cop
6
- module Style
7
- # Checks for various control keywords missing a space after them.
8
- class SpaceAfterControlKeyword < Cop
9
- MSG = 'Use space after control keywords.'.freeze
10
- # elsif and unless are handled by on_if.
11
- KEYWORDS = %w(if case when while until).freeze
12
-
13
- def on_keyword(node)
14
- return if node.loc.is_a?(Parser::Source::Map::Ternary)
15
-
16
- kw = node.loc.keyword
17
- kw_offset = kw.begin_pos - node.source_range.begin_pos
18
- return unless node.source[kw_offset..-1].start_with?(kw.source + '(')
19
-
20
- add_offense(node, kw)
21
- end
22
-
23
- KEYWORDS.each do |keyword|
24
- define_method(:"on_#{keyword}") do |node|
25
- on_keyword(node)
26
- end
27
- end
28
-
29
- def autocorrect(node)
30
- ->(corrector) { corrector.insert_after(node.loc.keyword, ' ') }
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
-
4
- module RuboCop
5
- module Cop
6
- module Style
7
- # Here we check if modifier keywords are preceded by a space.
8
- class SpaceBeforeModifierKeyword < Cop
9
- MSG = 'Put a space before the modifier keyword.'.freeze
10
-
11
- def on_if(node)
12
- return unless modifier?(node)
13
-
14
- kw = node.loc.keyword
15
- b = kw.begin_pos
16
- left_of_kw = Parser::Source::Range.new(kw.source_buffer, b - 1, b)
17
- add_offense(node, left_of_kw) unless left_of_kw.is?(' ')
18
- end
19
- alias on_while on_if
20
- alias on_until on_if
21
-
22
- private
23
-
24
- def modifier?(node)
25
- node.loc.respond_to?(:end) && node.loc.end.nil? && !elsif?(node)
26
- end
27
-
28
- def elsif?(node)
29
- node.loc.keyword.is?('elsif')
30
- end
31
-
32
- def autocorrect(node)
33
- ->(corrector) { corrector.insert_before(node.loc.keyword, ' ') }
34
- end
35
- end
36
- end
37
- end
38
- end