rubocop 0.57.1 → 0.57.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e577b73a80f270f2f18699b1b34a563a60565d5c
4
- data.tar.gz: 364776f0704be1ae1e85e158623f5ded6f81cc14
3
+ metadata.gz: '059456c464bec007ceecf522ade27bd7cf5e7c5a'
4
+ data.tar.gz: cfe7d827a44e1a84835870f38d25c4f9b13a4a00
5
5
  SHA512:
6
- metadata.gz: ee89c88fe1ad2bca660483e3e47bd7a59783f0989ff9e5b67d51cf182bfc9cbe9ea8d82e26ae5da2215ddbf23cb5c5bbbb84c28c9831da5d1ae8e34d9ba6e464
7
- data.tar.gz: f6d4fbf74aff8a775ed6ff8f0336de11c40885c270aece677d8e45ebb0dbe3079b13b3015979734650f6fb4de7bbd80897ecf1f34004176115a3383a4e11823c
6
+ metadata.gz: bdd27ccbc33113527d0d6bfbdc83cc48cf83d1a00b1162328b25fa67b062b7d13330bb5011628aab74dacbcb690610f26e4e209361c1565c4ff9341c4e32cb48
7
+ data.tar.gz: '092c870e83c677788d8d314a1869a84a2a505090fc5c703f10145d1ad513231087d539a497050d985e483cf869a46b8fb96424b3465933796683972f9b02928a'
data/README.md CHANGED
@@ -51,7 +51,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
51
51
  might want to use a conservative version locking in your `Gemfile`:
52
52
 
53
53
  ```rb
54
- gem 'rubocop', '~> 0.57.1', require: false
54
+ gem 'rubocop', '~> 0.57.2', require: false
55
55
  ```
56
56
 
57
57
  ## Quickstart
@@ -92,7 +92,7 @@ Layout/CaseIndentation:
92
92
  Enabled: true
93
93
 
94
94
  Layout/ClosingHeredocIndentation:
95
- Description: 'Checks the indenation of here document closings.'
95
+ Description: 'Checks the indentation of here document closings.'
96
96
  Enabled: true
97
97
 
98
98
  Layout/ClosingParenthesisIndentation:
@@ -467,7 +467,7 @@ module RuboCop
467
467
  end
468
468
 
469
469
  def parenthesized_call?
470
- loc.begin && loc.begin.is?('(')
470
+ loc.respond_to?(:begin) && loc.begin && loc.begin.is?('(')
471
471
  end
472
472
 
473
473
  def chained?
@@ -49,18 +49,18 @@ module RuboCop
49
49
  class ClosingHeredocIndentation < Cop
50
50
  include Heredoc
51
51
 
52
+ SIMPLE_HEREDOC = '<<'.freeze
52
53
  MSG = '`%<closing>s` is not aligned with `%<opening>s`.'.freeze
53
54
  MSG_ARG = '`%<closing>s` is not aligned with `%<opening>s` or ' \
54
55
  'beginning of method definition.'.freeze
55
56
 
56
57
  def on_heredoc(node)
57
- if node.loc.heredoc_body.source.empty? ||
58
+ return if heredoc_type(node) == SIMPLE_HEREDOC
59
+
60
+ if empty_heredoc?(node) ||
58
61
  contents_indentation(node) >= closing_indentation(node)
59
62
  return if opening_indentation(node) == closing_indentation(node)
60
- return if node.argument? &&
61
- opening_indentation(
62
- find_node_used_heredoc_argument(node.parent)
63
- ) == closing_indentation(node)
63
+ return if argument_indentation_correct?(node)
64
64
  end
65
65
 
66
66
  add_offense(node, location: :heredoc_end)
@@ -78,6 +78,17 @@ module RuboCop
78
78
  indent_level(heredoc_opening(node))
79
79
  end
80
80
 
81
+ def empty_heredoc?(node)
82
+ node.loc.heredoc_body.source.empty? || !contents_indentation(node)
83
+ end
84
+
85
+ def argument_indentation_correct?(node)
86
+ node.argument? &&
87
+ opening_indentation(
88
+ find_node_used_heredoc_argument(node.parent)
89
+ ) == closing_indentation(node)
90
+ end
91
+
81
92
  def contents_indentation(node)
82
93
  source_lines = node.loc.heredoc_body.source.split("\n")
83
94
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
+ # rubocop:disable Metrics/LineLength
5
6
  module Layout
6
7
  # This cop checks the indentation of the first parameter in a method call.
7
8
  # Parameters after the first one are checked by Layout/AlignParameters,
@@ -31,7 +32,9 @@ module RuboCop
31
32
  # nested_first_param),
32
33
  # second_param
33
34
  #
34
- # # Style: consistent
35
+ # @example EnforcedStyle: consistent
36
+ # # The first parameter should always be indented one step more than the
37
+ # # preceding line.
35
38
  #
36
39
  # # good
37
40
  # some_method(
@@ -55,7 +58,9 @@ module RuboCop
55
58
  # nested_first_param),
56
59
  # second_param
57
60
  #
58
- # # Style: consistent_relative_to_receiver
61
+ # @example EnforcedStyle: consistent_relative_to_receiver
62
+ # # The first parameter should always be indented one level relative to
63
+ # # the parent that is receiving the parameter
59
64
  #
60
65
  # # good
61
66
  # some_method(
@@ -79,7 +84,11 @@ module RuboCop
79
84
  # nested_first_param),
80
85
  # second_params
81
86
  #
82
- # # Style: special_for_inner_method_call
87
+ # @example EnforcedStyle: special_for_inner_method_call
88
+ # # The first parameter should normally be indented one step more than
89
+ # # the preceding line, but if it's a parameter for a method call that
90
+ # # is itself a parameter in a method call, then the inner parameter
91
+ # # should be indented relative to the inner method.
83
92
  #
84
93
  # # good
85
94
  # some_method(
@@ -103,7 +112,10 @@ module RuboCop
103
112
  # nested_first_param),
104
113
  # second_param
105
114
  #
106
- # # Style: special_for_inner_method_call_in_parentheses
115
+ # @example EnforcedStyle: special_for_inner_method_call_in_parentheses (default)
116
+ # # Same as `special_for_inner_method_call` except that the special rule
117
+ # # only applies if the outer method call encloses its arguments in
118
+ # # parentheses.
107
119
  #
108
120
  # # good
109
121
  # some_method(
@@ -128,6 +140,7 @@ module RuboCop
128
140
  # second_param
129
141
  #
130
142
  class FirstParameterIndentation < Cop
143
+ # rubocop:enable Metrics/LineLength
131
144
  include Alignment
132
145
  include ConfigurableEnforcedStyle
133
146
  include RangeHelp
@@ -149,7 +149,7 @@ module RuboCop
149
149
  # is not an access modifier.
150
150
  def base_column_for_normal_style(node)
151
151
  first_child = node.children.first
152
- return unless bare_access_modifier?(first_child)
152
+ return unless first_child && bare_access_modifier?(first_child)
153
153
 
154
154
  # If, as is most common, the access modifier is indented deeper than
155
155
  # the module (`access_modifier_indent > module_indent`) then the
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Cop
5
5
  # Common functionality for working with heredoc strings.
6
6
  module Heredoc
7
- OPENING_DELIMITER = /<<[~-]?['"`]?([^'"`]+)['"`]?/
7
+ OPENING_DELIMITER = /(<<[~-]?)['"`]?([^'"`]+)['"`]?/
8
8
 
9
9
  def on_str(node)
10
10
  return unless node.heredoc?
@@ -21,7 +21,11 @@ module RuboCop
21
21
  private
22
22
 
23
23
  def delimiter_string(node)
24
- node.source.match(OPENING_DELIMITER).captures.first
24
+ node.source.match(OPENING_DELIMITER).captures[1]
25
+ end
26
+
27
+ def heredoc_type(node)
28
+ node.source.match(OPENING_DELIMITER).captures[0]
25
29
  end
26
30
  end
27
31
  end
@@ -37,7 +37,7 @@ module RuboCop
37
37
  private
38
38
 
39
39
  def meaningful_delimiters?(node)
40
- delimiters = delimiters(node)
40
+ delimiters = delimiter_string(node)
41
41
 
42
42
  return false unless delimiters =~ /\w/
43
43
 
@@ -46,10 +46,6 @@ module RuboCop
46
46
  end
47
47
  end
48
48
 
49
- def delimiters(node)
50
- node.source.match(OPENING_DELIMITER).captures.first
51
- end
52
-
53
49
  def blacklisted_delimiters
54
50
  cop_config['Blacklist'] || []
55
51
  end
@@ -91,7 +91,8 @@ module RuboCop
91
91
  end
92
92
 
93
93
  def args_parenthesized?(node)
94
- return false unless node.arguments.length == 1
94
+ return false unless node.arguments.one?
95
+
95
96
  node.arguments.first.parenthesized_call?
96
97
  end
97
98
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.57.1'.freeze
6
+ STRING = '0.57.2'.freeze
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
9
9
  '%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'.freeze
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.57.1
4
+ version: 0.57.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-06-06 00:00:00.000000000 Z
13
+ date: 2018-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler