rubocop 0.58.2 → 0.59.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +22 -7
- data/config/disabled.yml +33 -4
- data/config/enabled.yml +4 -11
- data/lib/rubocop.rb +5 -0
- data/lib/rubocop/ast/builder.rb +1 -0
- data/lib/rubocop/ast/node.rb +11 -33
- data/lib/rubocop/ast/node/block_node.rb +8 -1
- data/lib/rubocop/ast/node/defined_node.rb +13 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +16 -5
- data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +21 -0
- data/lib/rubocop/ast/node/send_node.rb +3 -12
- data/lib/rubocop/ast/traversal.rb +10 -0
- data/lib/rubocop/cli.rb +4 -1
- data/lib/rubocop/config.rb +21 -5
- data/lib/rubocop/config_loader.rb +2 -0
- data/lib/rubocop/config_loader_resolver.rb +3 -1
- data/lib/rubocop/cop/autocorrect_logic.rb +1 -0
- data/lib/rubocop/cop/bundler/gem_comment.rb +64 -0
- data/lib/rubocop/cop/bundler/ordered_gems.rb +2 -0
- data/lib/rubocop/cop/commissioner.rb +2 -0
- data/lib/rubocop/cop/cop.rb +3 -0
- data/lib/rubocop/cop/corrector.rb +2 -0
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +1 -0
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -0
- data/lib/rubocop/cop/correctors/space_corrector.rb +2 -0
- data/lib/rubocop/cop/force.rb +1 -0
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -0
- data/lib/rubocop/cop/generator.rb +1 -0
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +1 -0
- data/lib/rubocop/cop/layout/class_structure.rb +4 -0
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +5 -4
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +35 -0
- data/lib/rubocop/cop/layout/else_alignment.rb +1 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -0
- data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +1 -0
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +5 -2
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -0
- data/lib/rubocop/cop/layout/end_of_line.rb +1 -0
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -0
- data/lib/rubocop/cop/layout/indent_array.rb +1 -0
- data/lib/rubocop/cop/layout/indent_heredoc.rb +3 -0
- data/lib/rubocop/cop/layout/indentation_width.rb +2 -0
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -0
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +2 -1
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +34 -11
- data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -0
- data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +3 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +1 -0
- data/lib/rubocop/cop/layout/space_before_comment.rb +1 -0
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +16 -8
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +2 -0
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +2 -0
- data/lib/rubocop/cop/layout/tab.rb +1 -0
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -0
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +9 -1
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -0
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -0
- data/lib/rubocop/cop/lint/interpolation_check.rb +2 -0
- data/lib/rubocop/cop/lint/literal_as_condition.rb +3 -6
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +1 -0
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -0
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -0
- data/lib/rubocop/cop/lint/rescue_type.rb +1 -0
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +2 -2
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -0
- data/lib/rubocop/cop/lint/script_permission.rb +1 -0
- data/lib/rubocop/cop/lint/shadowed_argument.rb +3 -0
- data/lib/rubocop/cop/lint/shadowed_exception.rb +2 -0
- data/lib/rubocop/cop/lint/unneeded_cop_disable_directive.rb +1 -0
- data/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb +1 -0
- data/lib/rubocop/cop/lint/unneeded_require_statement.rb +1 -0
- data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +2 -0
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -0
- data/lib/rubocop/cop/lint/useless_setter_call.rb +3 -0
- data/lib/rubocop/cop/lint/void.rb +1 -0
- data/lib/rubocop/cop/message_annotator.rb +1 -0
- data/lib/rubocop/cop/metrics/block_length.rb +1 -0
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -0
- data/lib/rubocop/cop/metrics/line_length.rb +6 -1
- data/lib/rubocop/cop/metrics/method_length.rb +1 -0
- data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -0
- data/lib/rubocop/cop/mixin/classish_length.rb +1 -0
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -0
- data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +12 -6
- data/lib/rubocop/cop/mixin/empty_parameter.rb +1 -0
- data/lib/rubocop/cop/mixin/ignored_methods.rb +19 -0
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +25 -1
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +5 -3
- data/lib/rubocop/cop/mixin/percent_literal.rb +2 -0
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +2 -0
- data/lib/rubocop/cop/mixin/safe_assignment.rb +2 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +6 -1
- data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -0
- data/lib/rubocop/cop/mixin/surrounding_space.rb +4 -0
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -0
- data/lib/rubocop/cop/mixin/uncommunicative_name.rb +2 -0
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -0
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -0
- data/lib/rubocop/cop/naming/file_name.rb +4 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -0
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -0
- data/lib/rubocop/cop/naming/uncommunicative_block_param_name.rb +1 -0
- data/lib/rubocop/cop/naming/uncommunicative_method_param_name.rb +1 -0
- data/lib/rubocop/cop/naming/variable_name.rb +1 -0
- data/lib/rubocop/cop/performance/case_when_splat.rb +11 -7
- data/lib/rubocop/cop/performance/casecmp.rb +33 -42
- data/lib/rubocop/cop/performance/chain_array_allocation.rb +77 -0
- data/lib/rubocop/cop/performance/compare_with_block.rb +3 -0
- data/lib/rubocop/cop/performance/regexp_match.rb +1 -0
- data/lib/rubocop/cop/performance/sample.rb +2 -0
- data/lib/rubocop/cop/performance/size.rb +8 -2
- data/lib/rubocop/cop/performance/string_replacement.rb +1 -0
- data/lib/rubocop/cop/rails/active_support_aliases.rb +1 -0
- data/lib/rubocop/cop/rails/bulk_change_table.rb +9 -2
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +1 -0
- data/lib/rubocop/cop/rails/delegate.rb +7 -2
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -0
- data/lib/rubocop/cop/rails/find_each.rb +7 -2
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +1 -1
- data/lib/rubocop/cop/rails/http_status.rb +2 -0
- data/lib/rubocop/cop/rails/inverse_of.rb +4 -0
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +1 -0
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -0
- data/lib/rubocop/cop/rails/reversible_migration.rb +1 -0
- data/lib/rubocop/cop/rails/save_bang.rb +189 -38
- data/lib/rubocop/cop/rails/time_zone.rb +1 -0
- data/lib/rubocop/cop/security/eval.rb +1 -0
- data/lib/rubocop/cop/security/json_load.rb +2 -2
- data/lib/rubocop/cop/security/open.rb +6 -3
- data/lib/rubocop/cop/severity.rb +1 -0
- data/lib/rubocop/cop/style/and_or.rb +3 -3
- data/lib/rubocop/cop/style/ascii_comments.rb +1 -0
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -4
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +2 -3
- data/lib/rubocop/cop/style/class_and_module_children.rb +3 -0
- data/lib/rubocop/cop/style/class_vars.rb +1 -1
- data/lib/rubocop/cop/style/colon_method_definition.rb +1 -0
- data/lib/rubocop/cop/style/commented_keyword.rb +2 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -0
- data/lib/rubocop/cop/style/copyright.rb +7 -2
- data/lib/rubocop/cop/style/date_time.rb +40 -7
- data/lib/rubocop/cop/style/double_negation.rb +1 -1
- data/lib/rubocop/cop/style/empty_case_condition.rb +8 -0
- data/lib/rubocop/cop/style/empty_else.rb +2 -0
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -0
- data/lib/rubocop/cop/style/eval_with_location.rb +2 -0
- data/lib/rubocop/cop/style/for.rb +56 -10
- data/lib/rubocop/cop/style/format_string_token.rb +1 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +1 -0
- data/lib/rubocop/cop/style/inverse_methods.rb +1 -0
- data/lib/rubocop/cop/style/lambda.rb +1 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -5
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +3 -5
- data/lib/rubocop/cop/style/method_def_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/missing_else.rb +1 -0
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -0
- data/lib/rubocop/cop/style/multiline_method_signature.rb +65 -0
- data/lib/rubocop/cop/style/multiple_comparison.rb +1 -0
- data/lib/rubocop/cop/style/nil_comparison.rb +45 -5
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +5 -0
- data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +2 -0
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +1 -0
- data/lib/rubocop/cop/style/redundant_begin.rb +13 -0
- data/lib/rubocop/cop/style/redundant_conditional.rb +1 -0
- data/lib/rubocop/cop/style/redundant_parentheses.rb +6 -1
- data/lib/rubocop/cop/style/redundant_return.rb +1 -0
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -0
- data/lib/rubocop/cop/style/rescue_standard_error.rb +1 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +4 -0
- data/lib/rubocop/cop/style/semicolon.rb +4 -0
- data/lib/rubocop/cop/style/signal_exception.rb +1 -0
- data/lib/rubocop/cop/style/string_hash_keys.rb +1 -0
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -8
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +1 -0
- data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -0
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -0
- data/lib/rubocop/cop/style/unneeded_condition.rb +13 -2
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +2 -0
- data/lib/rubocop/cop/style/word_array.rb +13 -1
- data/lib/rubocop/cop/team.rb +1 -0
- data/lib/rubocop/cop/variable_force.rb +5 -0
- data/lib/rubocop/cop/variable_force/assignment.rb +4 -0
- data/lib/rubocop/cop/variable_force/branch.rb +4 -0
- data/lib/rubocop/cop/variable_force/branchable.rb +2 -0
- data/lib/rubocop/cop/variable_force/scope.rb +6 -0
- data/lib/rubocop/cop/variable_force/variable_table.rb +1 -0
- data/lib/rubocop/file_finder.rb +2 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +4 -4
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -0
- data/lib/rubocop/options.rb +16 -0
- data/lib/rubocop/path_util.rb +16 -1
- data/lib/rubocop/processed_source.rb +4 -0
- data/lib/rubocop/remote_config.rb +6 -1
- data/lib/rubocop/result_cache.rb +1 -0
- data/lib/rubocop/rspec/cop_helper.rb +3 -5
- data/lib/rubocop/rspec/shared_examples.rb +1 -9
- data/lib/rubocop/runner.rb +4 -0
- data/lib/rubocop/target_finder.rb +2 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +7 -2
@@ -71,6 +71,7 @@ module RuboCop
|
|
71
71
|
|
72
72
|
def on_array(node)
|
73
73
|
return unless node.square_brackets?
|
74
|
+
|
74
75
|
left, right = array_brackets(node)
|
75
76
|
if empty_brackets?(left, right)
|
76
77
|
return empty_offenses(node, left, right, EMPTY_MSG)
|
@@ -125,6 +126,7 @@ module RuboCop
|
|
125
126
|
def end_has_own_line?(token)
|
126
127
|
line, col = line_and_column_for(token)
|
127
128
|
return true if col == -1
|
129
|
+
|
128
130
|
processed_source.lines[line][0..col].delete(' ').empty?
|
129
131
|
end
|
130
132
|
|
@@ -88,7 +88,7 @@ module RuboCop
|
|
88
88
|
# brace plus space (rather than just inserting a space), then any
|
89
89
|
# removal of the same brace will give us a clobbering error. This
|
90
90
|
# in turn will make RuboCop fall back on cop-by-cop
|
91
|
-
# auto-correction.
|
91
|
+
# auto-correction. Problem solved.
|
92
92
|
case range.source
|
93
93
|
when /\s/ then corrector.remove(range)
|
94
94
|
when '{' then corrector.replace(range, '{ ')
|
@@ -65,9 +65,11 @@ module RuboCop
|
|
65
65
|
def on_send(node)
|
66
66
|
return if node.multiline?
|
67
67
|
return unless bracket_method?(node)
|
68
|
+
|
68
69
|
tokens = tokens(node)
|
69
70
|
left_token = left_ref_bracket(node, tokens)
|
70
71
|
return unless left_token
|
72
|
+
|
71
73
|
right_token = closing_bracket(tokens, left_token)
|
72
74
|
|
73
75
|
if empty_brackets?(left_token, right_token)
|
@@ -138,6 +138,7 @@ module RuboCop
|
|
138
138
|
|
139
139
|
def found_instance_method(node, name)
|
140
140
|
return unless (scope = node.parent_module_name)
|
141
|
+
|
141
142
|
if scope =~ /\A#<Class:(.*)>\Z/
|
142
143
|
found_method(node, "#{Regexp.last_match(1)}.#{name}")
|
143
144
|
else
|
@@ -147,7 +148,12 @@ module RuboCop
|
|
147
148
|
|
148
149
|
def found_method(node, method_name)
|
149
150
|
if @definitions.key?(method_name)
|
150
|
-
loc =
|
151
|
+
loc = case node.type
|
152
|
+
when :def, :defs
|
153
|
+
node.loc.keyword.join(node.loc.name)
|
154
|
+
else
|
155
|
+
node.loc.expression
|
156
|
+
end
|
151
157
|
message = message_for_dup(node, method_name)
|
152
158
|
|
153
159
|
add_offense(node, location: loc, message: message)
|
@@ -174,6 +180,7 @@ module RuboCop
|
|
174
180
|
args.each do |arg|
|
175
181
|
name = sym_name(arg)
|
176
182
|
next unless name
|
183
|
+
|
177
184
|
found_instance_method(node, name) if readable
|
178
185
|
found_instance_method(node, "#{name}=") if writable
|
179
186
|
end
|
@@ -193,6 +200,7 @@ module RuboCop
|
|
193
200
|
end
|
194
201
|
|
195
202
|
break if namespace.nil?
|
203
|
+
|
196
204
|
namespace, mod_name = *namespace
|
197
205
|
end
|
198
206
|
end
|
@@ -104,6 +104,7 @@ module RuboCop
|
|
104
104
|
modifier = child if access_modifier?(child)
|
105
105
|
when :defs
|
106
106
|
next if correct_visibility?(child, modifier, ignored_methods)
|
107
|
+
|
107
108
|
yield child, modifier
|
108
109
|
when :kwbegin
|
109
110
|
ineffective_modifier(child, ignored_methods, modifier, &block)
|
@@ -67,6 +67,7 @@ module RuboCop
|
|
67
67
|
|
68
68
|
def on_send(node)
|
69
69
|
return unless node.negation_method?
|
70
|
+
|
70
71
|
check_for_literal(node)
|
71
72
|
end
|
72
73
|
|
@@ -98,12 +99,8 @@ module RuboCop
|
|
98
99
|
end
|
99
100
|
|
100
101
|
def check_node(node)
|
101
|
-
|
102
|
-
|
103
|
-
if node.keyword_bang?
|
104
|
-
receiver, = *node
|
105
|
-
|
106
|
-
handle_node(receiver)
|
102
|
+
if node.send_type? && node.prefix_bang?
|
103
|
+
handle_node(node.receiver)
|
107
104
|
elsif LOGICAL_OPERATOR_NODES.include?(node.type)
|
108
105
|
node.each_child_node { |op| handle_node(op) }
|
109
106
|
elsif node.begin_type? && node.children.one?
|
@@ -4,8 +4,8 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Lint
|
6
6
|
# The safe navigation operator returns nil if the receiver is
|
7
|
-
# nil.
|
8
|
-
# navigation operator, it raises NoMethodError.
|
7
|
+
# nil. If you chain an ordinary method call after a safe
|
8
|
+
# navigation operator, it raises NoMethodError. We should use a
|
9
9
|
# safe navigation operator after a safe navigation operator.
|
10
10
|
# This cop checks for the problem outlined above.
|
11
11
|
#
|
@@ -36,6 +36,7 @@ module RuboCop
|
|
36
36
|
def on_csend(node)
|
37
37
|
return unless node.parent &&
|
38
38
|
AST::Node::OPERATOR_KEYWORDS.include?(node.parent.type)
|
39
|
+
|
39
40
|
check(node)
|
40
41
|
end
|
41
42
|
|
@@ -77,6 +78,7 @@ module RuboCop
|
|
77
78
|
AST::Node::OPERATOR_KEYWORDS.include?(parent.parent.type)))
|
78
79
|
return node
|
79
80
|
end
|
81
|
+
|
80
82
|
top_conditional_ancestor(parent)
|
81
83
|
end
|
82
84
|
|
@@ -39,6 +39,7 @@ module RuboCop
|
|
39
39
|
return if Platform.windows?
|
40
40
|
return unless processed_source.start_with?(SHEBANG)
|
41
41
|
return if executable?(processed_source)
|
42
|
+
|
42
43
|
comment = processed_source.comments[0]
|
43
44
|
message = format_message_from(processed_source)
|
44
45
|
add_offense(comment, message: message)
|
@@ -83,6 +83,9 @@ module RuboCop
|
|
83
83
|
|
84
84
|
def check_argument(argument)
|
85
85
|
return unless argument.method_argument? || argument.block_argument?
|
86
|
+
# Block local variables, i.e., variables declared after ; inside
|
87
|
+
# |...| aren't really arguments.
|
88
|
+
return if argument.explicit_block_local_variable?
|
86
89
|
|
87
90
|
shadowing_assignment(argument) do |node|
|
88
91
|
message = format(MSG, argument: argument.name)
|
@@ -51,6 +51,7 @@ module RuboCop
|
|
51
51
|
|
52
52
|
def on_rescue(node)
|
53
53
|
return if rescue_modifier?(node)
|
54
|
+
|
54
55
|
_body, *rescues, _else = *node
|
55
56
|
rescued_groups = rescues.each_with_object([]) do |group, exceptions|
|
56
57
|
rescue_group, = *group
|
@@ -151,6 +152,7 @@ module RuboCop
|
|
151
152
|
klasses = *rescue_group
|
152
153
|
klasses.map do |klass|
|
153
154
|
next unless klass.const_type?
|
155
|
+
|
154
156
|
klass.source
|
155
157
|
end.compact
|
156
158
|
end
|
@@ -215,6 +215,7 @@ module RuboCop
|
|
215
215
|
def matching_range(haystack, needle)
|
216
216
|
offset = (haystack.source =~ Regexp.new(Regexp.escape(needle)))
|
217
217
|
return unless offset
|
218
|
+
|
218
219
|
offset += haystack.begin_pos
|
219
220
|
Parser::Source::Range.new(haystack.source_buffer, offset,
|
220
221
|
offset + needle.size)
|
@@ -50,7 +50,7 @@ module RuboCop
|
|
50
50
|
# baz
|
51
51
|
# end
|
52
52
|
class UnneededSplatExpansion < Cop
|
53
|
-
MSG = '
|
53
|
+
MSG = 'Replace splat expansion with comma separated values.'.freeze
|
54
54
|
ARRAY_PARAM_MSG = 'Pass array contents as separate arguments.'.freeze
|
55
55
|
PERCENT_W = '%w'.freeze
|
56
56
|
PERCENT_CAPITAL_W = '%W'.freeze
|
@@ -63,6 +63,7 @@ module RuboCop
|
|
63
63
|
|
64
64
|
def flow_expression?(node)
|
65
65
|
return true if flow_command?(node)
|
66
|
+
|
66
67
|
case node.type
|
67
68
|
when :begin, :kwbegin
|
68
69
|
expressions = *node
|
@@ -87,6 +88,7 @@ module RuboCop
|
|
87
88
|
else_branch = node.else_branch
|
88
89
|
return false unless else_branch
|
89
90
|
return false unless flow_expression?(else_branch)
|
91
|
+
|
90
92
|
node.when_branches.all? do |branch|
|
91
93
|
branch.body && flow_expression?(branch.body)
|
92
94
|
end
|
@@ -127,6 +127,7 @@ module RuboCop
|
|
127
127
|
def process_logical_operator_assignment(asgn_node)
|
128
128
|
lhs_node, rhs_node = *asgn_node
|
129
129
|
return unless ASSIGNMENT_TYPES.include?(lhs_node.type)
|
130
|
+
|
130
131
|
process_assignment(lhs_node, rhs_node)
|
131
132
|
|
132
133
|
throw :skip_children
|
@@ -135,6 +136,7 @@ module RuboCop
|
|
135
136
|
def process_binary_operator_assignment(op_asgn_node)
|
136
137
|
lhs_node, = *op_asgn_node
|
137
138
|
return unless ASSIGNMENT_TYPES.include?(lhs_node.type)
|
139
|
+
|
138
140
|
lhs_variable_name, = *lhs_node
|
139
141
|
@local[lhs_variable_name] = true
|
140
142
|
|
@@ -155,6 +157,7 @@ module RuboCop
|
|
155
157
|
def constructor?(node)
|
156
158
|
return true if node.literal?
|
157
159
|
return false unless node.send_type?
|
160
|
+
|
158
161
|
_receiver, method = *node
|
159
162
|
method == :new
|
160
163
|
end
|
@@ -38,6 +38,7 @@ module RuboCop
|
|
38
38
|
|
39
39
|
def highligh_start(line)
|
40
40
|
return max unless tab_indentation_width
|
41
|
+
|
41
42
|
max - (tab_indentation_width - 1) * line.count("\t")
|
42
43
|
end
|
43
44
|
|
@@ -76,7 +77,7 @@ module RuboCop
|
|
76
77
|
excessive_position = if uri_range && uri_range.begin < max
|
77
78
|
uri_range.end
|
78
79
|
else
|
79
|
-
|
80
|
+
highligh_start(line)
|
80
81
|
end
|
81
82
|
|
82
83
|
source_range(processed_source.buffer, index + 1,
|
@@ -97,6 +98,7 @@ module RuboCop
|
|
97
98
|
|
98
99
|
def extract_heredocs(ast)
|
99
100
|
return [] unless ast
|
101
|
+
|
100
102
|
ast.each_node(:str, :dstr, :xstr).select(&:heredoc?).map do |node|
|
101
103
|
body = node.location.heredoc_body
|
102
104
|
delimiter = node.location.heredoc_end.source.strip
|
@@ -128,8 +130,10 @@ module RuboCop
|
|
128
130
|
def find_excessive_uri_range(line)
|
129
131
|
last_uri_match = match_uris(line).last
|
130
132
|
return nil unless last_uri_match
|
133
|
+
|
131
134
|
begin_position, end_position = last_uri_match.offset(0)
|
132
135
|
return nil if begin_position < max && end_position < max
|
136
|
+
|
133
137
|
begin_position...end_position
|
134
138
|
end
|
135
139
|
|
@@ -175,6 +179,7 @@ module RuboCop
|
|
175
179
|
.detect { |e| e.location.line == source_line_number }
|
176
180
|
|
177
181
|
return false unless comment
|
182
|
+
|
178
183
|
comment.text.match(CommentConfig::COMMENT_DIRECTIVE_REGEXP)
|
179
184
|
end
|
180
185
|
|